Mercurial > public > hwos_code
annotate src/gaslist.asm @ 591:146e50d2672f
BUGFIX: handle two deco gases configured to the same change depth
author | heinrichsweikamp |
---|---|
date | Thu, 15 Mar 2018 20:43:38 +0100 |
parents | b455b31ce022 |
children | ca4556fb60b9 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
582 | 3 ; File gaslist.asm ## V2.98 |
0 | 4 ; |
275 | 5 ; Managing OSTC gas list |
0 | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-08-11 : [jDG] Creation. | |
11 | |
582 | 12 #include "hwos.inc" ; Mandatory header |
13 #include "convert.inc" | |
14 #include "math.inc" ; div16x16 for MOD calculations | |
15 #include "strings.inc" | |
16 #include "tft.inc" | |
17 #include "tft_outputs.inc" | |
18 #include "shared_definitions.h" | |
0 | 19 |
582 | 20 extern convert_mbar_to_feet |
21 extern customview_show_mix | |
22 extern tGasDisabled | |
23 extern tDilDisabled | |
24 extern tbar | |
0 | 25 |
582 | 26 gui CODE |
0 | 27 |
28 ;============================================================================= | |
29 ; Append gas description to current string. | |
582 | 30 ; Input: PRODL : gas number (0..4) |
31 ; FSR2 : Current string position. | |
0 | 32 ; Output: Text appended into buffer pointed by FSR2. |
582 | 33 |
34 global gaslist_strcat_gas | |
0 | 35 gaslist_strcat_gas: |
582 | 36 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents) |
37 ; Retrieve gas definition: | |
0 | 38 gaslist_strcat_gas_0: |
582 | 39 movf gaslist_gas,W |
40 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
41 movff PLUSW1,lo ; O2 ratio | |
42 ;movf gaslist_gas,W | |
43 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | |
44 movff PLUSW1,hi ; He ratio | |
45 goto customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and RETURN | |
0 | 46 |
47 ;============================================================================= | |
48 ; Append current mix to current string (For divemode) | |
49 ; Input: FSR2 : Current string position. | |
50 ; Output: Text appended into buffer pointed by FSR2. | |
582 | 51 global gaslist_strcat_gas6 |
52 gaslist_strcat_gas6: ; Show current O2/He mix | |
53 STRCAT_TEXT tGas | |
54 STRCAT ": " | |
55 movff gas6_O2_ratio,lo | |
56 movff gas6_He_ratio,hi | |
57 goto customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and RETURN | |
0 | 58 |
582 | 59 |
60 global gaslist_show_type | |
0 | 61 gaslist_show_type: |
582 | 62 movf gaslist_gas,W |
63 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | |
64 movff PLUSW1,lo ; lo holds gas type | |
65 STRCAT_TEXT tType | |
66 lfsr FSR1,tGasDisabled ; Base text number | |
67 btfsc ccr_diluent_setup ; In CCR setup? | |
68 lfsr FSR1,tDilDisabled ; Base text number | |
69 movff lo,WREG ; 0-3 | |
70 rlncf WREG ; x2 | |
71 addwf FSR1L,F | |
72 movlw .0 | |
73 addwfc FSR1H,F | |
74 call strcat_text | |
75 return | |
0 | 76 |
582 | 77 global gaslist_toggle_type |
0 | 78 gaslist_toggle_type: |
582 | 79 movf gaslist_gas,W |
80 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | |
81 movff PLUSW1,lo ; lo holds gas type | |
82 incf lo,F ; 0-3/0-2 | |
83 btfsc ccr_diluent_setup ; In CCR setup? | |
84 bra gaslist_toggle_type2 ; Yes | |
85 btfsc lo,2 ; >3? | |
86 clrf lo ; Clear to zero | |
87 movff lo,PLUSW1 ; Copy back result | |
88 return | |
0 | 89 gaslist_toggle_type2: |
582 | 90 movlw .3 |
91 cpfslt lo ; >2? | |
92 clrf lo ; Clear to zero | |
93 movf gaslist_gas,W | |
94 movff lo,PLUSW1 ; Copy back result | |
95 return | |
0 | 96 |
582 | 97 global gaslist_setSP |
0 | 98 gaslist_setSP: |
582 | 99 movff PRODL,gaslist_gas ; 0-4 |
100 return | |
0 | 101 |
582 | 102 |
103 global gaslist_strcat_setpoint | |
104 global gaslist_strcat_setpoint_0 | |
0 | 105 gaslist_strcat_setpoint: |
582 | 106 call gaslist_setSP |
0 | 107 gaslist_strcat_setpoint_0: |
582 | 108 bsf leftbind |
109 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
110 bra gaslist_strcat_setpoint2 ; Short version | |
111 STRCAT_TEXT tSP | |
112 incf gaslist_gas,W | |
113 movwf lo | |
114 output_8 | |
115 bcf leftbind | |
116 PUTC ":" | |
117 gaslist_strcat_setpoint2: ; Short version | |
118 btfsc divemode | |
119 bra gaslist_strcat_setpoint4 ; no "*" in divemode | |
120 movf gaslist_gas,W ; Number-1 into WREG | |
121 bnz gaslist_strcat_setpoint3 ; Not SP1 | |
122 PUTC "*" | |
123 bra gaslist_strcat_setpoint4 | |
0 | 124 gaslist_strcat_setpoint3: |
582 | 125 PUTC " " |
0 | 126 gaslist_strcat_setpoint4: |
582 | 127 movf gaslist_gas,W |
128 lfsr FSR1,char_I_setpoint_cbar | |
129 movf PLUSW1,W | |
130 movwf lo | |
131 clrf hi | |
132 bsf leftbind | |
133 output_16dp d'3' | |
134 btfsc divemode | |
135 bra gaslist_strcat_setpoint5 ; Skip text in divemode | |
136 STRCAT_TEXT tbar | |
0 | 137 gaslist_strcat_setpoint5: |
582 | 138 PUTC " " |
139 ; Read switch depth | |
140 movf gaslist_gas,W | |
141 lfsr FSR1,char_I_setpoint_change | |
142 movff PLUSW1,lo | |
143 | |
144 bsf ccr_diluent_setup ; inhibit output of "----" for depth | |
145 call gaslist_strcat_5 | |
146 bcf ccr_diluent_setup | |
534 | 147 return |
0 | 148 |
149 ;---------------------------------------------------------------------------- | |
150 ; Append gas description to current string. | |
582 | 151 ; Input: PRODL : gas number (0..4) |
152 ; FSR2 : Current string position. | |
0 | 153 ; Output: Text appended into buffer pointed by FSR2. |
154 ; | |
155 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry. | |
156 | |
582 | 157 gaslist_strcat_gas_better: ; Yes, check if this is a "better gas" |
158 bcf win_invert | |
159 movff better_gas_number,WREG ; get better gas number into WREG | |
160 decf WREG,W ; better_gas_number = better_gas_number -1 | |
161 btfsc ccr_diluent_setup ; in CCR menus? | |
162 addlw .5 ; Yes, offset to gases 5-9 | |
163 cpfseq gaslist_gas ; 0-4 for OC/Bailout, 5-9 for Diluents | |
164 return | |
165 call TFT_attention_color ; show in yellow | |
166 bsf win_invert ; And invert | |
167 return | |
0 | 168 |
582 | 169 global gaslist_strcat_gas_mod |
170 gaslist_strcat_gas_mod: | |
171 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents) | |
172 bsf space_gas_decriptions ; add a space in front for gas numbers < 10 for alignment | |
173 ;bra gaslist_gastitle | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
174 |
582 | 175 global gaslist_gastitle |
176 gaslist_gastitle: | |
177 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
178 bra gaslist_gastitle1 ; Short version | |
179 STRCAT_TEXT tGas | |
180 incf gaslist_gas,W | |
181 movwf lo | |
182 btfss space_gas_decriptions ; add a space in front for gas numbers < 10 for alignment? | |
183 bra gaslist_gastitle0 ; NO | |
184 bcf space_gas_decriptions ; YES - clear flag again | |
185 movlw .10 ; load a 10 | |
186 cpfslt lo ; gas# < 10 ? | |
187 bra gaslist_gastitle0 ; NO | |
188 PUTC " " ; YES - add a space | |
189 gaslist_gastitle0: | |
190 bsf leftbind | |
191 output_8 | |
192 bcf leftbind | |
193 PUTC ":" | |
194 gaslist_gastitle1: | |
195 lfsr FSR1,opt_gas_type | |
196 btfsc divemode | |
197 bra gaslist_gastitle3 ; no "*" in divemode | |
198 movf gaslist_gas,W | |
199 decf PLUSW1,W ; Type-1 into WREG | |
200 bnz gaslist_gastitle2 ; Not "First" | |
201 PUTC "*" | |
202 bra gaslist_gastitle3 | |
203 gaslist_gastitle2: | |
540
9a17b1db095b
Re-insert Rev. 530 changes into gaslist.asm
heinrichsweikamp
parents:
534
diff
changeset
|
204 PUTC " " |
582 | 205 gaslist_gastitle3: |
206 call TFT_standard_color | |
207 btfsc divemode ; In divemode? | |
208 rcall gaslist_strcat_gas_better ; Yes, check if this is a "better gas" | |
209 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) | |
210 movf PLUSW1,W | |
211 bnz gaslist_strcat_3 | |
212 call TFT_disabled_color | |
213 bra gaslist_strcat_4 ; no MOD-check and red color for disabled gases | |
214 gaslist_strcat_3: | |
215 rcall gaslist_strcat_gas_0 | |
216 PUTC " " | |
217 ; Read switch depth | |
218 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | |
219 movlw .4 | |
220 cpfsgt gaslist_gas ; >4? (-> Diluents) | |
221 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases | |
540
9a17b1db095b
Re-insert Rev. 530 changes into gaslist.asm
heinrichsweikamp
parents:
534
diff
changeset
|
222 |
582 | 223 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) |
224 movff PLUSW1,lo | |
225 rcall gaslist_calc_mod ; Compute MOD into WREG | |
226 cpfsgt lo ; within MOD range? | |
227 bra gaslist_strcat_5 ; YES | |
228 call TFT_warnings_color ; NO - turn red | |
229 bra gaslist_strcat_5 ; skip gaslist_strcat_gas_0 here | |
230 gaslist_strcat_4: | |
231 rcall gaslist_strcat_gas_0 | |
232 PUTC " " | |
233 ; Dummy code, needs some cleanup someday... | |
234 ; Read switch depth | |
235 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | |
236 movlw .4 | |
237 cpfsgt gaslist_gas ; >4? (-> Diluents) | |
238 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases | |
239 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) | |
240 movff PLUSW1,lo | |
241 rcall gaslist_calc_mod ; Compute MOD into WREG | |
521
06e9370c6d75
CHANGE: Apply safety margin parameters to both models (GF and non-GF)
heinrichsweikamp
parents:
518
diff
changeset
|
242 gaslist_strcat_5: |
582 | 243 PUTC " " |
244 TSTOSS opt_units ; 0=Meter, 1=Feet | |
245 bra gaslist_strcat_3_metric | |
0 | 246 ;gaslist_strcat_3_imperial: |
582 | 247 btfsc ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") |
248 bra gaslist_imperial_non_travel | |
249 movf gaslist_gas,W | |
250 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | |
251 movff PLUSW1,up ; up holds gas type | |
252 movlw .2 ; 2=Travel | |
253 cpfseq up ; compare gas type with type 2=Travel | |
254 bra gaslist_imperial_non_travel ; Non-Travel Gas | |
255 bra gaslist_strcat_depth_travel ; Show "---" instead of "0m"... | |
540
9a17b1db095b
Re-insert Rev. 530 changes into gaslist.asm
heinrichsweikamp
parents:
534
diff
changeset
|
256 gaslist_imperial_non_travel: |
582 | 257 movf lo,W |
258 mullw .100 ; convert meters to mbar | |
259 movff PRODL,lo | |
260 movff PRODH,hi | |
261 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
262 bsf leftbind | |
263 output_16_3 ; limit to 999 and display only (0-999) | |
264 STRCAT_TEXT tFeets ; "ft" | |
265 return | |
0 | 266 gaslist_strcat_3_metric: |
582 | 267 btfsc ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") |
268 bra gaslist_metric_non_travel | |
269 movf gaslist_gas,W | |
270 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | |
271 movff PLUSW1,up ; up holds gas type | |
272 movlw .2 ; 2=Travel | |
273 cpfseq up ; compare gas type with type 2=Travel | |
274 bra gaslist_metric_non_travel ; Non-Travel Gas | |
275 gaslist_strcat_depth_travel: ; Show "---" instead of "0m"... | |
276 STRCAT "---" | |
277 return | |
540
9a17b1db095b
Re-insert Rev. 530 changes into gaslist.asm
heinrichsweikamp
parents:
534
diff
changeset
|
278 gaslist_metric_non_travel: |
582 | 279 output_99 |
280 STRCAT_TEXT tMeters ; "m" | |
281 return | |
0 | 282 |
283 ;---------------------------------------------------------------------------- | |
284 ; Store current menu item, and display gas description later. | |
285 ; Input: PRODL : gas number (0..4) | |
286 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry. | |
582 | 287 |
288 global gaslist_setgas | |
0 | 289 gaslist_setgas: |
582 | 290 movff PRODL,gaslist_gas |
291 movlw .5 | |
292 btfsc ccr_diluent_setup ; in CCR menus? | |
293 addwf gaslist_gas,F ; Yes, offset to gases 5-9 | |
294 return | |
0 | 295 |
296 | |
582 | 297 global gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth |
0 | 298 gaslist_cleanup_list: |
582 | 299 bcf ignore_last_edited_gas |
300 movlw .0 | |
301 btfsc ccr_diluent_setup ; In CCR-Menu? | |
302 addlw .5 ; Yes, adjust offset | |
303 subwf gaslist_gas,F | |
0 | 304 gaslist_cleanup_list1: |
582 | 305 clrf lo |
306 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | |
307 movlw .5 ; Check 5 gases | |
308 movwf hi | |
0 | 309 gaslist_cleanup_list2: |
582 | 310 decf hi,w ; 0-4 |
311 btfsc ccr_diluent_setup ; In CCR-Menu? | |
312 addlw .5 ; Yes, adjust offset | |
313 movff PLUSW1,WREG ; read gas type | |
314 decfsz WREG ; is gas = first (ex 1)? | |
315 bra gaslist_cleanup_list3 ; NO | |
316 incf lo,F ; YES - count "first gases" | |
317 btfss ignore_last_edited_gas ; If we are not in the second-pass mode | |
318 bra gaslist_cleanup_list2b | |
319 decf hi,w ; 0-4 | |
320 cpfseq gaslist_gas ; Do not disable last edited gas | |
0 | 321 gaslist_cleanup_list2b: |
582 | 322 movff hi,up ; Keep the last "first gas" found |
0 | 323 gaslist_cleanup_list3: |
582 | 324 decfsz hi,F |
325 bra gaslist_cleanup_list2 ; Loop | |
326 tstfsz lo ; No gas active? | |
327 bra gaslist_cleanup_list4 ; No, at least one is active | |
328 btfsc ccr_diluent_setup ; In CCR-Menu? | |
329 bra gaslist_cleanup_list3a ; Yes. | |
330 ; make gas1 first and zero | |
331 movlw .1 ; First | |
332 movwf up | |
333 movwf INDF1 | |
334 bra gaslist_cleanup_list5 ; Set change depth to zero | |
0 | 335 gaslist_cleanup_list3a: |
582 | 336 movlw .5 |
337 addwf FSR1L,F | |
338 movlw .0 | |
339 addwfc FSR1H,F ; Setup to Diluents | |
340 ; make dil1 first and zero | |
341 movlw .1 ; First | |
342 movwf up | |
343 movwf INDF1 | |
344 bra gaslist_cleanup_list5 ; Set change depth to zero | |
0 | 345 gaslist_cleanup_list4: |
582 | 346 movlw .1 |
347 cpfsgt lo ; More then one "first gas"? | |
348 bra gaslist_cleanup_list5 ; No, done. | |
349 ; More then one Gas is "first gas" | |
350 ; Disable last found "first gas" but keep it's change depth | |
351 decf up,W ; 0-4 | |
352 cpfseq gaslist_gas ; Do not disable last edited gas | |
353 bra gaslist_cleanup_list4b | |
354 ; Do not disable last edited gas | |
355 ; search again but ignore last edited gas | |
356 bsf ignore_last_edited_gas | |
357 bra gaslist_cleanup_list1 ; Loop until only one "first gas" is left | |
0 | 358 gaslist_cleanup_list4b: |
582 | 359 btfsc ccr_diluent_setup ; In CCR-Menu? |
360 addlw .5 ; Yes, adjust offset | |
361 clrf PLUSW1 ; Disable gas | |
362 bra gaslist_cleanup_list ; Loop until only one "first gas" is left | |
0 | 363 gaslist_cleanup_list5: |
582 | 364 ; Read switch depth |
365 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | |
366 btfss ccr_diluent_setup ; In CCR-Menu? | |
367 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases | |
368 decf up,W | |
369 btfsc ccr_diluent_setup ; In CCR-Menu? | |
370 addlw .5 ; Yes, adjust offset | |
371 clrf PLUSW1 ; Set First gas to zero m | |
372 return | |
0 | 373 |
374 ;---------------------------------------------------------------------------- | |
375 ; Increment/Decrement O2 ratio | |
582 | 376 |
377 global gaslist_pO2 | |
0 | 378 gaslist_pO2: |
582 | 379 movf gaslist_gas,W |
380 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | |
381 movff PLUSW1,hi ; hi holds He ratio | |
382 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
383 movff PLUSW1,lo ; lo holds O2 ratio | |
0 | 384 |
582 | 385 incf lo,F ; O2++ |
386 movf hi,W ; get He ratio into WREG | |
387 addwf lo,W ; add O2 ratio to WREG | |
388 movwf up ; move sum He + O2 to up | |
389 movlw .101 ; | |
390 cpfslt up ; O2 + He < 101? | |
391 decf lo,F ; O2-- (revoke ++) | |
392 movf gaslist_gas,W | |
393 movff lo,PLUSW1 ; write back O2 ratio to opt_gas_O2_ratio[WREG] | |
394 return | |
395 | |
396 global gaslist_mO2 | |
0 | 397 gaslist_mO2: |
582 | 398 movf gaslist_gas,W |
399 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
400 movff PLUSW1,lo ; lo holds O2 ratio | |
0 | 401 |
582 | 402 decf lo,F ; O2-- |
403 movlw gaslist_min_o2 ; get minimum allowed O2 ratio | |
404 cpfslt lo ; current O2 ratio below allowed minimum? | |
405 bra gaslist_mO2_1 ; NO | |
406 movlw gaslist_min_o2 ; YES - load minimum | |
407 movwf lo ; write minimum to current O2 ratio | |
0 | 408 gaslist_mO2_1: |
582 | 409 movf gaslist_gas,W |
410 movff lo,PLUSW1 ; write back O2 ratio to opt_gas_O2_ratio[WREG] | |
411 return | |
0 | 412 |
413 ;---------------------------------------------------------------------------- | |
414 ; Increment/Decrement He ratio | |
582 | 415 |
416 global gaslist_pHe | |
0 | 417 gaslist_pHe: |
582 | 418 movf gaslist_gas,W |
419 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
420 movff PLUSW1,lo ; lo holds O2 ratio | |
421 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | |
422 movff PLUSW1,hi ; hi holds He ratio | |
0 | 423 |
582 | 424 incf hi,F ; He++ |
425 movf hi,W ; get He ratio into WREG | |
426 addwf lo,W ; add O2 ratio to WREG | |
427 movwf up ; move sum He + O2 to up | |
428 movlw .101 ; | |
429 cpfslt up ; O2 + He < 101? | |
430 decf hi,F ; He-- (revoke ++) | |
431 movf gaslist_gas,W | |
432 movff hi,PLUSW1 ; write back He ratio to opt_gas_He_ratio[WREG] | |
433 return | |
0 | 434 |
582 | 435 global gaslist_mHe |
0 | 436 gaslist_mHe: |
582 | 437 movf gaslist_gas,W |
438 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | |
439 movff PLUSW1,hi ; hi holds He ratio | |
0 | 440 |
582 | 441 decf hi,F ; He-- |
442 bnn gaslist_mHe_1 ; He ratio negative? | |
443 clrf hi ; YES - set He to 0 | |
0 | 444 gaslist_mHe_1: |
582 | 445 movf gaslist_gas,W |
446 movff hi,PLUSW1 ; write back He ratio to opt_gas_He_ratio[WREG] | |
447 return | |
0 | 448 |
449 ;---------------------------------------------------------------------------- | |
450 ; Increment/Decrement switch depth | |
451 | |
582 | 452 global gaslist_pDepth |
453 gaslist_pDepth: | |
454 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | |
455 movlw .4 | |
456 cpfsgt gaslist_gas ; >4? (-> Diluents) | |
457 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases | |
458 movf gaslist_gas,W | |
459 movff PLUSW1,lo ; Read char_I_deco_gas_change[WREG] | |
460 incf lo,F | |
461 movlw gaslist_max_change_depth | |
462 cpfsgt lo | |
463 bra gaslist_pDepth_1 | |
464 movlw gaslist_max_change_depth | |
465 movwf lo | |
0 | 466 gaslist_pDepth_1: |
582 | 467 movf gaslist_gas,W |
468 movff lo,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] | |
469 return | |
470 | |
471 global gaslist_mDepth | |
0 | 472 gaslist_mDepth: |
582 | 473 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 |
474 movlw .4 | |
475 cpfsgt gaslist_gas ; >4? (-> Diluents) | |
476 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
477 |
582 | 478 movf gaslist_gas,W |
479 movff PLUSW1,lo ; Read char_I_deco_gas_change[WREG] | |
480 | |
481 decf lo,F | |
482 btfsc STATUS,N | |
483 clrf lo | |
0 | 484 |
582 | 485 movf gaslist_gas,W |
486 movff lo,PLUSW1 ; And write back to char_I_deco_gas_change[WREG] | |
487 return | |
0 | 488 |
582 | 489 global gaslist_spplus |
0 | 490 gaslist_spplus: |
582 | 491 movf gaslist_gas,W |
492 lfsr FSR1,char_I_setpoint_cbar | |
493 movff PLUSW1,lo ; Read char_I_setpoint_cbar[WREG] | |
494 movlw gaslist_sp_stepsize | |
495 addwf lo,F | |
496 movlw gaslist_sp_max | |
497 cpfsgt lo | |
498 bra gaslist_spplus2 | |
499 movlw gaslist_sp_min | |
500 movwf lo | |
0 | 501 gaslist_spplus2: |
582 | 502 movf gaslist_gas,W |
503 movff lo,PLUSW1 ; Write back to char_I_setpoint_cbar | |
504 return | |
505 | |
506 global gaslist_spdepthplus | |
0 | 507 gaslist_spdepthplus: |
582 | 508 movf gaslist_gas,W |
509 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m | |
510 lfsr FSR1,char_I_setpoint_change | |
511 movff PLUSW1,lo ; Read char_I_deco_gas_change[WREG] | |
512 incf lo,F | |
513 movlw gaslist_max_change_depth | |
514 cpfsgt lo | |
515 bra gaslist_spdepthplus_1 | |
516 movlw gaslist_max_change_depth | |
517 movwf lo | |
0 | 518 gaslist_spdepthplus_1: |
582 | 519 movf gaslist_gas,W |
520 movff lo,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] | |
521 return | |
0 | 522 |
523 gaslist_spdepthplus3: | |
582 | 524 movlw .0 |
525 movff WREG,char_I_setpoint_change+0 ; Reset to 0m | |
526 return | |
0 | 527 |
582 | 528 global gaslist_spdepthminus |
0 | 529 gaslist_spdepthminus: |
582 | 530 movf gaslist_gas,W |
531 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m | |
532 lfsr FSR1,char_I_setpoint_change | |
533 movff PLUSW1,lo ; Read char_I_deco_gas_change[WREG] | |
534 decf lo,F | |
535 btfsc STATUS,N | |
536 clrf lo | |
537 movf gaslist_gas,W | |
538 movff lo,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] | |
539 return | |
0 | 540 |
541 ;---------------------------------------------------------------------------- | |
560 | 542 ; Compute MOD from char_I_ppO2_max/char_I_ppO2_max_deco and current O2 Ratio. |
0 | 543 ; |
582 | 544 ; Input: gaslist_gas = current gas index. |
0 | 545 ; opt_gas_O2_ratio[gaslist_gas] = current O2 ratio |
582 | 546 ; Output: WREG = MOD [m] |
0 | 547 ; |
548 gaslist_calc_mod: | |
582 | 549 movf gaslist_gas,W ; get gas number (0...5) |
550 lfsr FSR1,opt_gas_O2_ratio ; read opt_gas_O2_ratio[WREG] | |
551 movf PLUSW1,W | |
552 | |
553 btfsc divemode ; in divemode? | |
554 bra gaslist_calc_mod_divemode ; YES | |
0 | 555 |
582 | 556 ; Pamb max = ppO2 Max / O2 ratio |
557 movwf xB+0 | |
0 | 558 |
582 | 559 movf gaslist_gas,W ; get gas number (0...5) |
560 lfsr FSR1,opt_gas_type ; 0=Disabled, 1=First, 2=Travel, 3=Deco for OC gases and 0=Disabled, 1=First, 2=Normal for diluents | |
561 movff PLUSW1,xA+0 ; xA+0 used as temp here -> holds type | |
0 | 562 |
582 | 563 movff char_I_ppO2_max_deco,xB+1 ; xB+1 used as temp here |
564 movlw .3 | |
565 cpfseq xA+0 ; Deco? | |
566 movff char_I_ppO2_max,xB+1 ; No, overwrite with travel/bottom max | |
567 movf xB+1,W ; Result in WREG | |
568 | |
569 clrf xB+1 ; Clear for div16x16 | |
570 mullw .10 | |
571 movff PRODL,xA+0 | |
572 movff PRODH,xA+1 | |
573 call div16x16 | |
574 | |
575 ; Prof = Pamb - 1 bar | |
576 movf xC+0,W | |
577 addlw -.10 | |
578 return | |
0 | 579 |
580 gaslist_calc_mod_divemode: | |
582 | 581 movwf hi ; Copy O2% |
582 call TFT_color_code_gaslist ; Color-code current row in Gaslist (%O2 in hi), char_I_ppO2_max/char_I_ppO2_max_deco as threshold | |
583 return | |
584 | |
0 | 585 ;---------------------------------------------------------------------------- |
154
afa31c815f24
NEW: Show ppO2 for change depth during gas setup
heinrichsweikamp
parents:
97
diff
changeset
|
586 |
582 | 587 global gaslist_ppo2 |
154
afa31c815f24
NEW: Show ppO2 for change depth during gas setup
heinrichsweikamp
parents:
97
diff
changeset
|
588 gaslist_ppo2: |
582 | 589 STRCAT_TEXT tppO2 ; ppO2: |
590 movf gaslist_gas,W | |
591 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents | |
592 btfss ccr_diluent_setup ; In CCR-Menu? | |
593 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC/Bailout Gases | |
594 movf PLUSW1,W | |
595 mullw .10 ; PROD=Depth in mbar/10 (100 = 1.00 bar) | |
596 movlw .100 | |
597 addwf PRODL,F | |
598 movlw .0 | |
599 addwfc PRODH,F ; add 1bar | |
600 movff PRODL,xA+0 | |
601 movff PRODH,xA+1 | |
602 movf gaslist_gas,W ; Read current gas O2 ratio | |
603 lfsr FSR1,opt_dil_O2_ratio-.5 ; Read dil_gas_O2_ratio[WREG] | |
604 btfss ccr_diluent_setup ; In CCR-Menu? | |
605 lfsr FSR1,opt_gas_O2_ratio ; No, read opt_gas_O2_ratio[WREG] | |
606 movff PLUSW1,xB+0 | |
607 clrf xB+1 | |
608 call mult16x16 ; char_I_O2_ratio * (p_amb/10) | |
609 movff xC+0,xA+0 | |
610 movff xC+1,xA+1 | |
611 movlw d'100' | |
612 movwf xB+0 | |
613 clrf xB+1 | |
614 call div16x16 ; xC=(char_I_O2_ratio * p_amb/10)/100 | |
615 ; Check very high ppO2 manually | |
616 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? | |
617 bra gaslist_ppo2_2 ; Yes, display fixed Value! | |
618 movff xC+0,lo | |
619 movff xC+1,hi | |
620 bcf ignore_digit4 | |
621 bsf leftbind | |
622 output_16dp d'3' ; x.xx | |
623 STRCAT_TEXT tbar ; bar | |
624 return | |
154
afa31c815f24
NEW: Show ppO2 for change depth during gas setup
heinrichsweikamp
parents:
97
diff
changeset
|
625 gaslist_ppo2_2: |
582 | 626 STRCAT ">6.6" |
627 return | |
154
afa31c815f24
NEW: Show ppO2 for change depth during gas setup
heinrichsweikamp
parents:
97
diff
changeset
|
628 |
582 | 629 global gaslist_MOD_END |
0 | 630 gaslist_MOD_END: |
582 | 631 rcall gaslist_calc_mod ; Compute MOD into WREG |
632 movwf lo ; Copy to lo | |
633 STRCAT_TEXT tMOD ; MOD: | |
634 TSTOSS opt_units ; 0=Meters, 1=Feets | |
635 bra gaslist_MOD_metric | |
636 ;gaslist_MOD_imperial: | |
637 movf lo,W | |
638 mullw .100 ; convert meters to mbar | |
639 movff PRODL,lo | |
640 movff PRODH,hi | |
641 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
642 bsf leftbind | |
643 output_16_3 ; limit to 999 and display only (0-999) | |
644 STRCAT_TEXT tFeets ; "ft" | |
645 bra gaslist_MOD_common | |
0 | 646 gaslist_MOD_metric: |
582 | 647 output_8 |
648 STRCAT_TEXT tMeters ; m | |
0 | 649 gaslist_MOD_common: |
582 | 650 PUTC "/" |
651 STRCAT_TEXT tEND ; END: | |
652 rcall gaslist_calc_mod ; Output: WREG = MOD [m] | |
653 addlw .10 ; MOD=MOD+10m | |
654 movwf xB+0 | |
655 clrf xB+1 | |
656 movlw d'100' | |
657 movwf xA+0 | |
658 movf gaslist_gas,W ; get gas number (0...5) | |
659 lfsr FSR1,opt_gas_He_ratio ; read opt_gas_O2_ratio[WREG] | |
660 movf PLUSW1,W ; He value in % | |
661 subwf xA+0,F ; xA+0 = 100 - He Value in % | |
662 clrf xA+1 | |
663 call mult16x16 ; xA*xB=xC | |
664 movff xC+0,xA+0 | |
665 movff xC+1,xA+1 | |
666 movlw d'100' | |
667 movwf xB+0 | |
668 clrf xB+1 | |
669 call div16x16 ; xA/xB=xC with xA as remainder | |
670 ; ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100 | |
671 movlw d'10' | |
672 subwf xC+0,F ; Subtract 10m... | |
673 movff xC+0,lo | |
674 ;; END 8Bit only | |
675 ;movlw d'0' | |
676 ;subwfb xC+1,F | |
677 ;movff xC+1,hi | |
678 TSTOSS opt_units ; 0=Meter, 1=Feet | |
679 bra gaslist_END_metric | |
680 ;gaslist_END_imperial: | |
681 movf lo,W | |
682 mullw .100 ; convert meters to mbar | |
683 movff PRODL,lo | |
684 movff PRODH,hi | |
685 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
686 bsf leftbind | |
687 output_16_3 ; limit to 999 and display only (0-999) | |
688 STRCAT_TEXT tFeets ; "ft" | |
689 return | |
0 | 690 gaslist_END_metric: |
582 | 691 output_8 |
692 STRCAT_TEXT tMeters ; m | |
693 return | |
0 | 694 |
695 ;---------------------------------------------------------------------------- | |
582 | 696 global gaslist_reset_mod_title |
0 | 697 gaslist_reset_mod_title: |
582 | 698 STRCAT_TEXT tDepthReset |
0 | 699 |
700 gaslist_reset_mod_title2: | |
582 | 701 rcall gaslist_calc_mod ; Compute MOD into WREG |
702 movwf lo ; Copy to lo | |
0 | 703 |
582 | 704 movf gaslist_gas,W ; Compare to switch depth |
705 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents | |
706 btfss ccr_diluent_setup ; In CCR-Menu? | |
707 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases | |
708 movf PLUSW1,W | |
709 cpfslt lo | |
710 bra gaslist_strcat_5 ; and return... | |
711 call TFT_warnings_color ; turn red if bigger ! | |
712 bra gaslist_strcat_5 ; and return... | |
0 | 713 |
714 ;---------------------------------------------------------------------------- | |
582 | 715 global gaslist_reset_mod |
0 | 716 gaslist_reset_mod: |
582 | 717 rcall gaslist_calc_mod ; Compute MOD, it is returned in WREG |
718 movwf lo ; buffer MOD to lo | |
719 movf gaslist_gas,W ; Read current gas O2 ratio | |
720 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents | |
721 btfss ccr_diluent_setup ; In CCR-Menu? | |
722 lfsr FSR1,opt_OC_bail_gas_change ; NO - setup OC Gases | |
723 movff lo,PLUSW1 ; write back new change depth | |
724 return | |
0 | 725 ;---------------------------------------------------------------------------- |
582 | 726 END |