Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 757:50ed645c251d
CHANGE: save gas used during deco
author | jDG |
---|---|
date | Sun, 03 Nov 2013 13:37:04 +0100 |
parents | 6724df41d4f1 |
children | 3b1af9891019 |
comparison
equal
deleted
inserted
replaced
756:a98365da41d3 | 757:50ed645c251d |
---|---|
169 static float locked_GF_step; // GF_delta / low_depth | 169 static float locked_GF_step; // GF_delta / low_depth |
170 | 170 |
171 static unsigned char temp_depth_limit; | 171 static unsigned char temp_depth_limit; |
172 float low_depth; // Depth of deepest stop | 172 float low_depth; // Depth of deepest stop |
173 | 173 |
174 // Simulation context: used to predict ascent. | 174 static unsigned char internal_deco_time [NUM_STOPS]; |
175 unsigned char sim_lead_tissue_no; // Leading compatiment number. | |
176 float sim_lead_tissue_limit; // Buhlmann tolerated pressure. | |
177 | |
178 // Real context: what we are doing now. | |
179 static float calc_lead_tissue_limit; // | |
180 | |
181 static unsigned char internal_deco_time[NUM_STOPS]; | |
182 static unsigned char internal_deco_depth[NUM_STOPS]; | 175 static unsigned char internal_deco_depth[NUM_STOPS]; |
176 static unsigned char internal_deco_gas [NUM_STOPS]; | |
183 | 177 |
184 static float cns_vault; | 178 static float cns_vault; |
185 static float low_depth_vault; | 179 static float low_depth_vault; |
186 static float pres_tissue_N2_vault[NUM_COMP]; | 180 static float pres_tissue_N2_vault[NUM_COMP]; |
187 static float pres_tissue_He_vault[NUM_COMP]; | 181 static float pres_tissue_He_vault[NUM_COMP]; |
221 static float float_saturation_multiplier; // new in v.101 | 215 static float float_saturation_multiplier; // new in v.101 |
222 static float float_desaturation_multiplier; // new in v.101 | 216 static float float_desaturation_multiplier; // new in v.101 |
223 static float float_deco_distance; // new in v.101 | 217 static float float_deco_distance; // new in v.101 |
224 | 218 |
225 static unsigned char deco_gas_change[NUM_GAS]; // new in v.109 | 219 static unsigned char deco_gas_change[NUM_GAS]; // new in v.109 |
220 | |
221 // Simulation context: used to predict ascent. | |
222 unsigned char sim_lead_tissue_no; // Leading compatiment number. | |
223 float sim_lead_tissue_limit; // Buhlmann tolerated pressure. | |
224 | |
225 // Real context: what we are doing now. | |
226 static float calc_lead_tissue_limit; // | |
226 | 227 |
227 //---- Bank 6 parameters ----------------------------------------------------- | 228 //---- Bank 6 parameters ----------------------------------------------------- |
228 #ifndef UNIX | 229 #ifndef UNIX |
229 # pragma udata bank6=0x600 | 230 # pragma udata bank6=0x600 |
230 #endif | 231 #endif |
683 for(y=0; y<NUM_STOPS; y++, --x) | 684 for(y=0; y<NUM_STOPS; y++, --x) |
684 { | 685 { |
685 char_O_deco_depth[y] = internal_deco_depth[x]; | 686 char_O_deco_depth[y] = internal_deco_depth[x]; |
686 char_O_deco_time_for_log[y] = internal_deco_time [x]; | 687 char_O_deco_time_for_log[y] = internal_deco_time [x]; |
687 char_O_deco_time [y] = internal_deco_time [x]; | 688 char_O_deco_time [y] = internal_deco_time [x]; |
689 char_O_deco_gas [y] = internal_deco_gas [x]; | |
688 | 690 |
689 // Stop only once the last transfer is done. | 691 // Stop only once the last transfer is done. |
690 if( x == 0 ) break; | 692 if( x == 0 ) break; |
691 } | 693 } |
692 | 694 |
694 for(y++; y<NUM_STOPS; y++) | 696 for(y++; y<NUM_STOPS; y++) |
695 { | 697 { |
696 char_O_deco_time [y] = 0; | 698 char_O_deco_time [y] = 0; |
697 char_O_deco_depth[y] = 0; | 699 char_O_deco_depth[y] = 0; |
698 char_O_deco_time_for_log[y] = 0; | 700 char_O_deco_time_for_log[y] = 0; |
701 char_O_deco_gas [y] = 0; | |
699 } | 702 } |
700 } | 703 } |
701 else //---- Straight copy ------------------------------------------------ | 704 else //---- Straight copy ------------------------------------------------ |
702 { | 705 { |
703 overlay unsigned char x, y; | 706 overlay unsigned char x, y; |
704 | 707 |
705 for(x=0; x<NUM_STOPS; x++) | 708 for(x=0; x<NUM_STOPS; x++) |
706 { | 709 { |
707 char_O_deco_depth[x] = internal_deco_depth[x]; | 710 char_O_deco_depth[x] = internal_deco_depth[x]; |
708 char_O_deco_time [x] = internal_deco_time [x]; | 711 char_O_deco_time [x] = internal_deco_time [x]; |
712 char_O_deco_gas [x] = internal_deco_gas [x]; | |
709 } | 713 } |
710 | 714 |
711 //Now fill the char_O_deco_time_for_log array | 715 //Now fill the char_O_deco_time_for_log array |
712 //---- First: search the first non-null depth | 716 //---- First: search the first non-null depth |
713 for(x=(NUM_STOPS-1); x != 0; --x) | 717 for(x=(NUM_STOPS-1); x != 0; --x) |
725 //---- Third: fill table end with null | 729 //---- Third: fill table end with null |
726 for(y++; y<NUM_STOPS; y++) | 730 for(y++; y<NUM_STOPS; y++) |
727 { | 731 { |
728 char_O_deco_time_for_log [y] = 0; | 732 char_O_deco_time_for_log [y] = 0; |
729 } | 733 } |
730 | |
731 } | 734 } |
732 } | 735 } |
733 | 736 |
734 ////////////////////////////////////////////////////////////////////////////// | 737 ////////////////////////////////////////////////////////////////////////////// |
735 // temp_tissue_safety // | 738 // temp_tissue_safety // |
1248 // Limit loops to 512ms, using the RTC timer 3: | 1251 // Limit loops to 512ms, using the RTC timer 3: |
1249 if( tmr3() & (512*32) ) | 1252 if( tmr3() & (512*32) ) |
1250 break; | 1253 break; |
1251 | 1254 |
1252 if( calc_nextdecodepth() ) | 1255 if( calc_nextdecodepth() ) |
1253 { | 1256 { |
1254 if( temp_depth_limit == 0 ) | 1257 if( temp_depth_limit == 0 ) |
1255 goto Surface; | 1258 goto Surface; |
1256 | 1259 |
1257 //---- We hit a stop at temp_depth_limit --------------------- | 1260 //---- We hit a stop at temp_depth_limit --------------------- |
1258 temp_deco = temp_depth_limit * METER_TO_BAR // Convert to relative bar, | 1261 temp_deco = temp_depth_limit * METER_TO_BAR // Convert to relative bar, |
1259 + pres_surface; // To absolute. | 1262 + pres_surface; // To absolute. |
1260 if( !update_deco_table() ) // Adds a one minute stops. | 1263 if( !update_deco_table() ) // Adds a one minute stops. |
1261 goto Surface; // Deco table full: abort... | 1264 goto Surface; // Deco table full: abort... |
1262 } | 1265 } |
1263 else | 1266 else |
1264 { | 1267 { |
1723 if( internal_deco_depth[x] == 0 ) | 1726 if( internal_deco_depth[x] == 0 ) |
1724 { | 1727 { |
1725 internal_deco_depth[x] = temp_depth_limit; | 1728 internal_deco_depth[x] = temp_depth_limit; |
1726 | 1729 |
1727 internal_deco_time[x] = 1; | 1730 internal_deco_time[x] = 1; |
1731 internal_deco_gas[x] = sim_gas_last_used; | |
1728 return 1; | 1732 return 1; |
1729 } | 1733 } |
1730 } | 1734 } |
1731 | 1735 |
1732 // Can't store stops at more than 96m. | 1736 // Can't store stops at more than 96m. |