# HG changeset patch # User jDG # Date 1436975857 -7200 # Node ID fca4f9de5f4a476319cb3d7a314643dfa67e0e33 # Parent 7e5772df60cdc9d54151f037f86419d24fbaf99f [FIX] GasVolume: missing gas changes w/o stops. diff -r 7e5772df60cd -r fca4f9de5f4a src/p2_deco.c --- a/src/p2_deco.c Wed Jul 22 10:42:15 2015 +0200 +++ b/src/p2_deco.c Wed Jul 15 17:57:37 2015 +0200 @@ -2169,6 +2169,7 @@ overlay float bottom_usage, deco_usage; overlay unsigned char i; overlay unsigned char gas, depth; + overlay unsigned char lastGasStop; RESET_C_STACK //---- initialize -------------------------------------------------------- @@ -2193,28 +2194,74 @@ * bottom_usage; // In liter/minutes. //---- Ascent usage ------------------------------------------------------ - depth = char_I_bottom_depth; + depth = lastGasStop = char_I_bottom_depth; for(i=0; i= newStop ) + { + newGas = j; + newStop = char_I_deco_gas_change[j]; + } + } + } - //---- usage BEFORE gas switch (if any), at 10m/min: - volumes[gas] += ((depth+newDepth)*0.05 + 1.0) // average depth --> bar. - * (depth-newDepth)*0.1 // metre --> min - * deco_usage; + // Did we find something ? + if( !newStop ) + break; + + //---- usage BEFORE gas switch (if any), at 10m/min : + if( depth > newStop ) + // Plus usage during ascent to the next stop, at 10m/min. + volumes[gas] += ((depth+newStop)*0.05 + 1.0) // average depth --> bar. + * (depth-newStop)*0.1 // metre --> min + * deco_usage; + + //---- Do gas switch: + gas = newGas; - //---- Do gas switch, at new depth: - gas = newGas; + lastGasStop = newStop; // Mark last used gas + if( newStop < depth ) // ascent to gas switch, + depth = newStop; + } + + // Are we back to gas from the deco list (just in case): + assert(gas == char_O_deco_gas[i]-1); + + //---- usage AFTER gas switch (if any), at 10m/min : + if( depth > newDepth ) + volumes[gas] += ((depth+newDepth)*0.05 + 1.0) // average depth --> bar. + * (depth-newDepth)*0.1 // metre --> min + * deco_usage; + + //---- Do stop: depth = newDepth; //---- Usage at stop: