changeset 353:b5b030c1ae7e

Avoid spurious switch-depth stops with 3 or more gas.
author JeanDo
date Tue, 07 Jun 2011 01:16:55 +0200
parents ed137d66ac65
children cec312042b94
files code_part1/OSTC_code_asm_part1/MAIN.ASM code_part1/OSTC_code_asm_part1/changelog.txt code_part1/OSTC_code_asm_part1/divemode.asm code_part1/OSTC_code_asm_part1/divemode_menu.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 code_part1/OSTC_code_c_part2/shared_definitions.h
diffstat 8 files changed, 29 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/MAIN.ASM	Mon May 30 19:28:59 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/MAIN.ASM	Tue Jun 07 01:16:55 2011 +0200
@@ -38,7 +38,7 @@
 inter_v	code	0x0008
 		bra		HighInt						;High Priority Interrups
 
-inter_asm	code	0x0018							;Low Priority Interrups
+inter_asm	code	0x0018                  ;Low Priority Interrups
 ;	*** low priority interrupts not used
 		bra		HighInt						;High Priority Interrups
 
--- a/code_part1/OSTC_code_asm_part1/changelog.txt	Mon May 30 19:28:59 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/changelog.txt	Tue Jun 07 01:16:55 2011 +0200
@@ -1,6 +1,7 @@
 New in 1.91 beta:
 BETA Version - Do NOT use for diving!
 BUGFIX: Ignore depths>130m in PC simulation
+BUGFIX: Avoid spurious CF55 stops with 3 gas or more.
 
 New in 1.90 Stable:
 Stable release
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Mon May 30 19:28:59 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Tue Jun 07 01:16:55 2011 +0200
@@ -1777,6 +1777,7 @@
 set_first_gas:
 	read_int_eeprom 	d'33'			; Read byte (stored in EEDATA)
 	movff	EEDATA,active_gas			; Read start gas (1-5)
+    movff   EEDATA,char_I_current_gas
 
 	decf	active_gas,W				; Gas 0-4
 	mullw	d'4'
--- a/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Mon May 30 19:28:59 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Tue Jun 07 01:16:55 2011 +0200
@@ -560,7 +560,9 @@
 	bsf		event_occured				; set global event flag
     bsf		is_bailout					;=1: CC mode, but bailout active!		
 	clrf	lo							; clear Setpoint, PLED_const_ppO2_value now displayes "Bail"
-	movff	lo,char_I_const_ppO2		
+	movff	lo,char_I_const_ppO2
+    movlw   6
+    movff   WREG,char_I_current_gas     ; Current gas is Gas6 (manual setting).
 	bra		timeout_divemenu2			; quit underwater menu!
 
 divemenu_set_gas:
@@ -627,6 +629,7 @@
 	cpfseq	menupos						; At the "Gas 6.." position?		
 	bra		divemenu_set_gas2b			; No, select Gas1-5 (Stored in Menupos)
 	bra		divemode_set_xgas			; Configure the extra gas
+
 divemenu_set_gas2b:
 	bsf		is_bailout					;=1: CC mode, but bailout active!		
 	clrf	lo							; clear Setpoint, PLED_const_ppO2_value now displayes "Bail"
@@ -657,6 +660,8 @@
 	movff	EEDATA, char_I_N2_ratio		; = N2!
 	bsf		stored_gas_changed			; set event flag
 	bsf		event_occured				; set global event flag
+
+    movff   menupos,char_I_current_gas  ; Inform deco code too.
 	bra		timeout_divemenu2			; quit menu!
 	
 timeout_divemenu:
--- a/code_part1/OSTC_code_asm_part1/surfmode.asm	Mon May 30 19:28:59 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/surfmode.asm	Tue Jun 07 01:16:55 2011 +0200
@@ -273,16 +273,17 @@
 	btg		LED_blue
 	return	
 
+;=============================================================================
+
 calc_deko_surfmode:
 	ostc_debug	'I'		; Sends debug-information to screen if debugmode active
 
 	movff	last_surfpressure+0,int_I_pres_surface+0	; copy surface air pressure to deco routine
 	movff	last_surfpressure+1,int_I_pres_surface+1		
-	clrf	wait_temp						; Use as buffer
-	movff	wait_temp,char_I_He_ratio		; No He at the Surface
-	movlw	d'79'							; 79% N2
-	movwf	wait_temp						; Use as buffer
-	movff	wait_temp,char_I_N2_ratio		; No He at the Surface
+	clrf	WREG                        ; Use as buffer
+	movff	WREG,char_I_He_ratio        ; No He at the Surface
+	movlw	d'79'                       ; 79% N2
+	movff	WREG,char_I_N2_ratio        ; Air at the Surface
 
     SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine
 	GETCUSTOM8	d'11'									; Saturation multiplier %
@@ -299,6 +300,7 @@
 
 	return
 
+;=============================================================================
 
 test_charger:
 	bcf		TRISC,1						; CHRG_OUT output
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Mon May 30 19:28:59 2011 +0200
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Tue Jun 07 01:16:55 2011 +0200
@@ -972,63 +972,21 @@
 //////////////////////////////////////////////////////////////////////////////
 // Find current gas in the list (if any).
 // 
-// Input:  char_I_deco_N2_ratio[] and He, to detect breathed gas.
+// Input:  char_I_current_gas.
 //
-// Output: sim_gas_depth_used
+// Output: sim_gas_last_depth, temp_depth_limit.
 //
 static void gas_switch_find_current(void)
 {
-    overlay unsigned char j;
-    overlay unsigned char N2 = (unsigned char)(N2_ratio * 100 + 0.5);
-    overlay unsigned char He = (unsigned char)(He_ratio * 100 + 0.5);
-
-    for(j=0; j<NUM_GAS; ++j)
-    {
-        // Make sure to detect if we are already breathing some gas in
-        // the current list (happends when first gas do have a depth).
-        if( N2 == char_I_deco_N2_ratio[j] 
-         && He == char_I_deco_He_ratio[j] 
-        )                                 
-        {
-            if( char_I_deco_gas_change[j] )
-                temp_depth_limit = sim_gas_last_depth = char_I_deco_gas_change[j];
-            sim_gas_last_used  = j+1;
-            break;
-        }
-    }
-
-    // If there is no gas-switch-delay running ?
-    if( sim_gas_delay <= sim_dive_mins)
-    {
-        // Compute current depth:
-        overlay unsigned char depth = (unsigned char)(0.5 + (pres_respiration - pres_surface) * BAR_TO_METER);
-        assert( depth < 130 );
+    assert( 0 <= char_I_current_gas && char_I_current_gas <= (NUM_GAS+1) );
 
-        // And if I'm above the last decostop (with the 3m margin) ?
-        if( (sim_gas_last_depth-3) > depth )
-        {
-            for(j=0; j<NUM_GAS; ++j)
-            {
-                // And If I am in the range of a valide stop ?
-                // (again, with the same 3m margin)
-                if( char_I_deco_gas_change[j]
-                 && depth <= char_I_deco_gas_change[j]
-                 && depth >= (char_I_deco_gas_change[j] - 3)
-                )
-                {
-                    // Then start gas-switch timer there,
-                    sim_gas_delay = sim_dive_mins 
-                                  + read_custom_function(55);
-
-                    // And make sure decostop will be recorded at the right depth.
-                    temp_depth_limit = char_I_deco_gas_change[j];
-                    break;
-                }
-            }
-        }
-        else
-            // Make clear there is no deay anymore.
-            sim_gas_delay = 0;
+    if( (char_I_current_gas <= NUM_GAS)                 // Gas6 == manual set.
+     && char_I_deco_gas_change[char_I_current_gas-1]
+    )
+    {
+        sim_gas_last_used  = char_I_current_gas-1;
+        sim_gas_last_depth = char_I_deco_gas_change[sim_gas_last_used];
+        // temp_depth_limit = ???
     }
 }
 
@@ -1063,7 +1021,7 @@
             if( temp_depth_limit > deco_gas_change[j] )
                 continue;
 
-            // Gas deeper than the current/previous one ? Skip !
+            // Gas deeper (or equal) than the current one ? Skip !
             if( sim_gas_last_depth && deco_gas_change[j] >= sim_gas_last_depth )
                 continue;
 
Binary file code_part1/OSTC_code_c_part2/p2_deco.o has changed
--- a/code_part1/OSTC_code_c_part2/shared_definitions.h	Mon May 30 19:28:59 2011 +0200
+++ b/code_part1/OSTC_code_c_part2/shared_definitions.h	Tue Jun 07 01:16:55 2011 +0200
@@ -142,7 +142,8 @@
 VAR_UINT  (int_I_divemins);                // Dive time (minutes)
 VAR_UCHAR (char_I_temp);                   // new in v101
 VAR_UCHAR (char_I_actual_ppO2);            // 
-VAR_UCHAR (char_I_first_gas);              // Gas used at start of dive.
+VAR_UCHAR (char_I_first_gas);              // Gas used at start of dive (bottom mix)
+VAR_UCHAR (char_I_current_gas);            // Current gas breathed (1..6).
 VAR_UCHAR (char_I_N2_ratio);               //
 VAR_UCHAR (char_I_He_ratio);               //
 VAR_UCHAR (char_I_saturation_multiplier);  // for conservatism/safety values 1.0  no conservatism to 1.5  50% faster saturation