changeset 233:2cbaa01dac26

Hunting for NoFly (bug BB13)... not found yet... + In DEBUG compile, keep simulated dives in logbook, desat and nofly time, etc.
author JeanDo
date Tue, 15 Mar 2011 19:16:34 +0100
parents 59c479181724
children bb8940caebe1
files code_part1/OSTC_code_asm_part1/divemode.asm code_part1/OSTC_code_asm_part1/start.asm code_part1/OSTC_code_asm_part1/surfmode.asm code_part1/OSTC_code_c_part2/p2_deco.c code_part1/OSTC_code_c_part2/p2_deco.o
diffstat 5 files changed, 45 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Wed Mar 16 19:03:01 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Tue Mar 15 19:16:34 2011 +0100
@@ -491,8 +491,10 @@
 	bcf		store_sample				; update only any CF20 seconds
 	bsf		update_divetime				; update divemins every CF20 seconds
 
-	btfsc	simulatormode_active		; Are we in simulator mode?
-	return								; Yes, discard everything
+    ifndef __DEBUG
+    	btfsc	simulatormode_active    ; Are we in simulator mode?
+    	return                          ; Yes, discard everything
+    endif
 
 	btfsc	header_stored				; Header already stored?
 	bra		store_dive_data2			; Yes, store only profile data
@@ -1019,8 +1021,11 @@
 	btfss	realdive					; dive longer then one minute
 	goto	end_dive_common				; No, discard everything
 
-	btfsc	simulatormode_active		; Are we in simulator mode?
-	goto	end_dive_common				; Yes, discard everything
+; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc...
+    ifndef __DEBUG
+    	btfsc	simulatormode_active		; Are we in simulator mode?
+    	goto	end_dive_common				; Yes, discard everything
+    endif
 
 	; Dive finished (and longer then one minute or Apnoe timeout occured)
 
@@ -1291,8 +1296,10 @@
 	btfsc	FLAG_apnoe_mode				; In Apnoe mode?
 	bra		timeout_divemode2			; Yes, use CF30 [min] for timeout
 
-	btfsc	simulatormode_active		; In Simulator mode?
-	bra		timeout_divemode3			; Yes, use fixed 5 seconds timeout			
+    ifndef __DEBUG
+    	btfsc	simulatormode_active    ; In Simulator mode?
+    	bra		timeout_divemode3       ; Yes, use fixed 5 seconds timeout			
+    endif
 	
 	bcf		divemode
 	incf	timeout_counter,F
--- a/code_part1/OSTC_code_asm_part1/start.asm	Wed Mar 16 19:03:01 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/start.asm	Tue Mar 15 19:16:34 2011 +0100
@@ -41,11 +41,6 @@
 	call	disable_rs232			; disable UART module
 	call	RTCinit					; reset RTC
 
-; Extra power-up reset (JeanDo)
-	ifdef	TESTING
-		call 	do_menu_reset_all2
-	endif
-
 ; Air pressure compensation	after reset
 	call	get_calibration_data	; Get calibration data from pressure sensor
 
@@ -62,7 +57,7 @@
 	bsf		sleepmode				; Routine only works in sleepmode...
 	call	pressuretest_sleep_fast	; Gets pressure without averaging (faster!)
 	bcf		sleepmode				; Normal mode again
-	
+
 	movff	amb_pressure+0,last_surfpressure+0
 	movff	amb_pressure+1,last_surfpressure+1
 	movff	amb_pressure+0,last_surfpressure_15min+0
@@ -70,6 +65,11 @@
 	movff	amb_pressure+0,last_surfpressure_30min+0
 	movff	amb_pressure+1,last_surfpressure_30min+1	; Rests all airpressure registers
 
+; Extra power-up reset (JeanDo)
+	ifdef	TESTING
+		call 	do_menu_reset_all2
+	endif
+
 ; reset deco data
 	clrf	WREG                            ; Use as buffer
 	movff	WREG,char_I_He_ratio            ; No He at the Surface
--- a/code_part1/OSTC_code_asm_part1/surfmode.asm	Wed Mar 16 19:03:01 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/surfmode.asm	Tue Mar 15 19:16:34 2011 +0100
@@ -97,12 +97,13 @@
 	call	PLED_custom_text			; Displays custom text
 	clrf	cf_checker_counter			; next cf to check
 	ostc_debug	'G'						; Sends debug-information to screen if debugmode active
+
+    ; Desaturation time needs:
+    ;   int_I_pres_surface
+    ;   char_I_desaturation_multiplier
 	GETCUSTOM8	d'12'					; Desaturation multiplier %
-	movwf	wait_temp
-	movff	wait_temp,char_I_desaturation_multiplier
-	GETCUSTOM8	d'11'					; Saturation multiplier %
-	movwf	wait_temp
-	movff	wait_temp,char_I_saturation_multiplier
+	movff	WREG,char_I_desaturation_multiplier
+
 	call	deco_calc_desaturation_time ; calculate desaturation time
 	movlb	b'00000001'					; select ram bank 1
 	ostc_debug	'H'						; Sends debug-information to screen if debugmode active
@@ -119,7 +120,6 @@
 
 	bra		surfloop_loop1				; Do not search for sensor in CC mode
 
-
 surfloop_loop1:
 ; One Second tasks for all modes
 	call	PLED_clock					; update clock
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Wed Mar 16 19:03:01 2011 +0100
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Tue Mar 15 19:16:34 2011 +0100
@@ -98,7 +98,7 @@
 #include "shared_definitions.h"
 
 // Water vapour partial pressure in the lumb.
-static const float ppWVapour = 0.0627;
+#define ppWVapour 0.0627
 
 // *************************
 // ** P R O T O T Y P E S **
@@ -1782,6 +1782,8 @@
 //
 // FIXED N2_ratio
 // unchanged in v.101
+// Inputs:  int_I_pres_surface, ppWVapour, char_I_desaturation_multiplier
+// Outputs: int_O_desaturation_time, char_O_tissue_saturation[0..31]
 //
 void deco_calc_desaturation_time(void)
 {
@@ -1792,12 +1794,15 @@
     overlay float temp4;
     RESET_C_STACK
 
+    assert( 800 < int_I_pres_surface && int_I_pres_surface < 1100 );
+    assert( 0 < char_I_desaturation_multiplier && char_I_desaturation_multiplier <= 100 );
+
     N2_ratio = 0.7902; // FIXED sum as stated in b"uhlmann
-    pres_surface = (float)int_I_pres_surface / 1000.0;
+    pres_surface = int_I_pres_surface * 0.001;
     ppO2 = N2_ratio * (pres_surface - ppWVapour);
     int_O_desaturation_time = 0;
     float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101	(70,42%/100.=142)
-    
+
     for (ci=0;ci<16;ci++)
     {
         overlay float var_N2_halftime = buhlmann_ht[ci];
@@ -1813,8 +1818,8 @@
         temp2 = ppO2 - pres_tissue[ci];
         if (temp2 >= 0.0)
         {
-            temp1 = 0;
-            temp2 = 0;
+            temp1 = 0.0;
+            temp2 = 0.0;
         }
         else
             temp1 = temp1 / temp2;
@@ -1828,16 +1833,16 @@
         }
         else
         {
-            temp1 = 0;
-            temp2 = 0;
+            temp1 = 0.0;
+            temp2 = 0.0;
         }
 
         // He
         temp3 = 0.1 - (pres_tissue+16)[ci];
         if (temp3 >= 0.0)
         {
-            temp3 = 0;
-            temp4 = 0;
+            temp3 = 0.0;
+            temp4 = 0.0;
         }
         else
             temp3 = -1.0 * temp3 / (pres_tissue+16)[ci];
@@ -1851,8 +1856,8 @@
     	}
         else
     	{
-        	temp3 = 0;
-        	temp4 = 0;
+        	temp3 = 0.0;
+        	temp4 = 0.0;
     	}
 
         // saturation_time (for flight)
@@ -1871,6 +1876,7 @@
         if (temp2 > 255.0)
             temp2 = 255.0;
         char_O_tissue_saturation[ci] = (char)temp2;
+
         // He saturation in multiples of halftime for display purposes
         temp4 = temp3 * 20.0;  // 0 = 1/8, 120 = 0, 249 = 8
         temp4 = temp4 + 80.0; // set center
@@ -1898,9 +1904,9 @@
 	}
 
     N2_ratio = 0.7902; // FIXED, sum lt. buehlmann
-    pres_respiration = int_I_pres_respiration * 0.001; // assembler code uses different digit system
-    pres_surface = int_I_pres_surface * 0.001;  // the b"uhlmann formula using pres_surface does not use the N2_ratio
-    ppO2 = N2_ratio * (pres_respiration - ppWVapour); // ppWVapour is the extra pressure in the body
+    pres_respiration = int_I_pres_respiration * 0.001;  // assembler code uses different digit system
+    pres_surface = int_I_pres_surface * 0.001;          // the b"uhlmann formula using pres_surface does not use the N2_ratio
+    ppO2 = N2_ratio * (pres_respiration - ppWVapour);   // ppWVapour is the extra pressure in the body
     ppHe = 0.0;
     float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101	(70,42%/100.=142)
     float_saturation_multiplier   = char_I_saturation_multiplier   * 0.01;
Binary file code_part1/OSTC_code_c_part2/p2_deco.o has changed