| 
					
				 | 
			
			
				@@ -139,7 +139,7 @@ public class MainActivity extends Activity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Shot timer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private long startTime = 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private Handler customHandler = new Handler(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    int preinfusionDelay = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    float preinfusionDelay = 0, preinfusionPump = 0; // This is a float because SliderPreference returns a float 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Video 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // http://stackoverflow.com/questions/1817742/how-can-i-capture-a-video-recording-on-android 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -283,9 +283,25 @@ public class MainActivity extends Activity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private Runnable updateTimerThread = new Runnable() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         public void run() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            float shotTime = (SystemClock.uptimeMillis() - startTime) / 1000.0f; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            meter2.setValue(clamp(shotTime - preinfusionDelay, 0, 30)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            customHandler.postDelayed(this, 500); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            float st_secs = (SystemClock.uptimeMillis() - startTime) /* 1000.0f */; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if( sharedPrefs.getBoolean("pref_pinbl", false) ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if( st_secs >= preinfusionPump && st_secs <= preinfusionPump + preinfusionDelay ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    st_secs = preinfusionPump; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if( st_secs > preinfusionPump + preinfusionDelay ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    st_secs -= preinfusionDelay; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            st_secs /= 1000.0f; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            meter2.setValue( clamp( st_secs, 0, 45) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            customHandler.postDelayed( this, 500 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -451,7 +467,7 @@ public class MainActivity extends Activity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     if (message.startsWith("sht ")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        /* try { */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             int shottime = Integer.parseInt(parts[2]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             if (shottime == 0) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -461,19 +477,49 @@ public class MainActivity extends Activity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 // Setting can be changed from multiple locations: get it here 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 preinfusionDelay = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                preinfusionPump = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 if (sharedPrefs.getBoolean("pref_pinbl", false)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    preinfusionDelay = sharedPrefs.getInt("pref_piprd", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    preinfusionPump = sharedPrefs.getFloat( "pref_pistrt", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    preinfusionDelay = sharedPrefs.getFloat("pref_piprd", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if( mBoundService.legacy ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        preinfusionDelay = preinfusionDelay * 1000; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        preinfusionPump = preinfusionPump * 1000; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                System.out.println("PI Delay" + preinfusionDelay); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                System.out.println("PI Delay " + preinfusionDelay); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 customHandler.postDelayed(updateTimerThread, 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 customHandler.removeCallbacks(updateTimerThread); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                float st_secs = shottime / time_scale - preinfusionDelay; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                // if shottime <= pipump : check setting if to increase 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                // if shottime > pipump : check setting for piprd 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                System.out.println( "Shot timer update " + shottime ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                // Init with normal use case : no PI 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                float st_secs = shottime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                // Adjust for PI 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if( sharedPrefs.getBoolean("pref_pinbl", false) ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if( st_secs >= preinfusionPump && st_secs <= preinfusionPump + preinfusionDelay ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        st_secs = preinfusionPump; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                meter2.setValue(clamp(st_secs, 0, 30)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if( st_secs > preinfusionPump + preinfusionDelay ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        st_secs -= preinfusionDelay; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                // Convert millisecs to seconds 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                st_secs /= 1000.0f; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                meter2.setValue( clamp(st_secs, 0, 45) ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                // Set timer to hide gauge after 30 secs 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 customHandler.postDelayed(new Runnable() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     public void run() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         ShotTimer_hide(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -481,9 +527,9 @@ public class MainActivity extends Activity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 }, 30 * 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            Log.e(TAG, "Failed to parse SHT message"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        /* } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            Log.e(TAG, "Failed to parse SHT message" + e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |