changeset 488:7c48692dd17c

BUGFIX Missed surface pressure for CNS in decoplan.
author JeanDo
date Mon, 17 Oct 2011 21:39:48 +0200
parents 4c93c2154f18
children b8edb7362870
files code_part1/OSTC_code_asm_part1/changelog.txt code_part1/OSTC_code_c_part2/p2_deco.c code_part1/OSTC_code_c_part2/p2_definitions.h
diffstat 3 files changed, 27 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/changelog.txt	Sun Oct 16 13:37:14 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/changelog.txt	Mon Oct 17 21:39:48 2011 +0200
@@ -1,3 +1,7 @@
+New in 2.04 beta:
+BETA Version - Do NOT use for diving!
+BUGFIX: Missed surface pressure for CNS in decoplan
+
 New in 2.03 beta:
 BETA Version - Do NOT use for diving!
 BUGFIX: Logbook write
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Sun Oct 16 13:37:14 2011 +0200
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Mon Oct 17 21:39:48 2011 +0200
@@ -518,11 +518,16 @@
 //////////////////////////////////////////////////////////////////////////////
 // Read CF values from the C code.
 
+#ifdef CROSS_COMPILE
+// Full description of the OSTC EEPROM map, including CF values.
+#   include "OSTC_eeprom.h"
+#endif
+
 static short read_custom_function(PARAMETER unsigned char cf)
 {
 #ifdef CROSS_COMPILE
-    extern unsigned short custom_functions[];
-    return custom_functions[cf];
+    return (cf & 32) ? eeprom.bank1_CF[cf-32].value
+                     : eeprom.bank0_CF[cf   ].value;
 #else
     extern unsigned char hi, lo;
     extern void getcustom15();
@@ -2384,8 +2389,15 @@
 //////////////////////////////////////////////////////////////////////////////
 // deco_calc_CNS_planning
 //
-// Input:
-// Output:
+// Compute CNS during predicetd ascent.
+//
+// Note:    Needs a call to deco_push_tissues_to_vault(), 
+//          deco_pull_tissues_from_vault() to avoid trashing everything...
+//
+// Input:   CNS_fraction, char_O_deco_time[], char_O_deco_depth[]
+// Output:  CNS_fraction, char_O_CNS_fraction
+// Trashed: char_I_actual_ppO2
+//
 void deco_calc_CNS_planning(void)
 {
     RESET_C_STACK
@@ -2415,7 +2427,7 @@
         //---- Ascent to surface delay
         // NOTE: count as if time is spent with bottom pressure,
         //       AND the bottom gas
-        actual_ppO2 = (char_I_bottom_depth * METER_TO_BAR - ppWater)
+        actual_ppO2 = (pres_surface + char_I_bottom_depth * METER_TO_BAR - ppWater)
                     * (1.0 - calc_N2_ratio - calc_He_ratio);
         if( actual_ppO2 < 0.0  ) actual_ppO2 = 0.0;
         if( actual_ppO2 > 2.50 ) actual_ppO2 = 2.55;
@@ -2440,7 +2452,7 @@
                 gas_switch_deepest();
         
             //---- Convert Depth and N2_ratio to ppO2
-            actual_ppO2 = (temp_depth_limit * METER_TO_BAR - ppWater)
+            actual_ppO2 = (pres_surface + temp_depth_limit * METER_TO_BAR - ppWater)
                         * (1.0 - calc_N2_ratio - calc_He_ratio);
             if( actual_ppO2 < 0.0  ) actual_ppO2 = 0.0;
             if( actual_ppO2 > 2.50 ) actual_ppO2 = 2.55;
@@ -2450,7 +2462,10 @@
             for(t=0; t<time; ++t)
                 deco_calc_CNS_fraction();
         }
-    }    
+    }
+
+    // Back to normal mode...
+    char_I_step_is_1min = 0;
 }    
 
 //////////////////////////////////////////////////////////////////////////////
--- a/code_part1/OSTC_code_c_part2/p2_definitions.h	Sun Oct 16 13:37:14 2011 +0200
+++ b/code_part1/OSTC_code_c_part2/p2_definitions.h	Mon Oct 17 21:39:48 2011 +0200
@@ -92,6 +92,7 @@
 extern void deco_clear_CNS_fraction(void);
 extern void deco_push_tissues_to_vault(void);
 extern void deco_pull_tissues_from_vault(void);
+extern void deco_calc_CNS_planning(void);
 extern void deco_gas_volumes(void);
 
 // ***********************************************