changeset 240:d995e220ddac

BUGFIX Gas Usage when first gas is not #1 (bug BB22).
author JeanDo
date Mon, 21 Mar 2011 23:27:46 +0100
parents 3ed240d60341
children f44274d8440a
files code_part1/OSTC_code_asm_part1/simulator.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 4 files changed, 23 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/simulator.asm	Mon Mar 21 13:31:38 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/simulator.asm	Mon Mar 21 23:27:46 2011 +0100
@@ -240,10 +240,15 @@
     btfsc   FLAG_const_ppO2_mode        ; In CCR mode ?
     bra     simulator_show_decoplan4    ; YES: finished.
 
-   ; Re-read gas change depth, from the unsorted list.
+    ; Re-read gas change depth, from the unsorted list.
+    movlw   .33                         ; First gas.
+    movwf   EEADR
+    clrf    EEADRH
+    call    read_eeprom
+    movff   EEDATA,char_I_first_gas
+    
     movlw   .27                         ; Active flags.
     movwf   EEADR
-    clrf    EEADRH
     call    read_eeprom
     movff   EEDATA,waitms_temp          ; Save activity flags.
     incf    EEADR,F                     ; 28 == Gas#1's change depth.
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Mon Mar 21 13:31:38 2011 +0100
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Mon Mar 21 23:27:46 2011 +0100
@@ -2157,7 +2157,8 @@
 // calculates volumes for each gas.
 //
 // Input:   char_I_bottom_depth, char_I_bottom_time for planned dive.
-///         Gas list. First gas is the bottom gas.
+//          Gas list.
+//          char_I_first_gas is the bottom gas.
 //          decoplan (char_O_deco_depth, char_O_deco_time).
 //          CF#54 == TRUE if shallowest stop first.
 //          CF#56 == bottom deci-liters/minutes (0.5 .. 50.0)
@@ -2172,27 +2173,30 @@
     RESET_C_STACK
 
     //---- initialize with bottom consumption --------------------------------
-    volumes[0] = (char_I_bottom_depth*0.1 + 1.0)    // Use Psurface = 1.0 bar.
-               * char_I_bottom_time                 // in minutes.
-               * read_custom_function(56)           // In deci-liter/minutes.
-               * 0.1;                               // deci-liters --> liters.
+    for(i=0; i<5; ++i)                              // Nothing yet...
+        volumes[i] = 0.0;
 
-    for(i=1; i<5; ++i)                              // Nothing yet...
-        volumes[i] = 0.0;
+    assert( 1 <= char_I_first_gas && char_I_first_gas <= 5);
+    volumes[char_I_first_gas - 1]
+        = (char_I_bottom_depth*0.1 + 1.0)           // Use Psurface = 1.0 bar.
+        * char_I_bottom_time                        // in minutes.
+        * read_custom_function(56)                  // In deci-liter/minutes.
+        * 0.1;                                      // deci-liters --> liters.
 
     //---- Ascent usage ------------------------------------------------------
 
     deepest_first = read_custom_function(54) == 0;
-    ascent_usage  = read_custom_function(57) * 0.1;  // In litter/minutes.
+    ascent_usage  = read_custom_function(57) * 0.1; // In liter/minutes.
 
     // Usage up to the first stop:
     //  - computed at MAX depth (easier, safer),
     //  - with an ascent speed of 10m/min.
     //  - with ascent litter / minutes.
     //  - still using bottom gas:
-    volumes[0] += (char_I_bottom_depth*0.1 + 1.0)   // Depth -> bar
-               * (char_I_bottom_depth - char_O_first_deco_depth) * 0.1  // ascent time (min)
-               * ascent_usage;                      // Consumption ( xxx / min @ 1 bar)
+    volumes[char_I_first_gas - 1]
+        += (char_I_bottom_depth*0.1 + 1.0)          // Depth -> bar
+         * (char_I_bottom_depth - char_O_first_deco_depth) * 0.1  // ascent time (min)
+         * ascent_usage;                            // Consumption ( xxx / min @ 1 bar)
 
     for(i=0; i<32; ++i)
     {
Binary file code_part1/OSTC_code_c_part2/p2_deco.o has changed
--- a/code_part1/OSTC_code_c_part2/shared_definitions.h	Mon Mar 21 13:31:38 2011 +0100
+++ b/code_part1/OSTC_code_c_part2/shared_definitions.h	Mon Mar 21 23:27:46 2011 +0100
@@ -121,6 +121,7 @@
 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_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