0
|
1 ;=============================================================================
|
|
2 ;
|
|
3 ; File gaslist.asm
|
|
4 ;
|
|
5 ; Managing OSTC3 gas list
|
|
6 ;
|
|
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
|
|
8 ;=============================================================================
|
|
9 ; HISTORY
|
|
10 ; 2011-08-11 : [jDG] Creation.
|
|
11
|
|
12 #include "ostc3.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
|
|
19 #include "shared_definitions.h"
|
|
20
|
|
21 CBLOCK tmp+0x40 ; Keep space for menu processor
|
|
22 gaslist_gas
|
|
23 gaslist_O2
|
|
24 gaslist_He
|
|
25 gaslist_depth
|
|
26 gaslist_Type
|
|
27 ; Reserved to tmp+0x5F
|
|
28 ENDC
|
|
29
|
|
30 extern convert_mbar_to_feet
|
|
31
|
|
32 gui CODE
|
|
33 ;=============================================================================
|
|
34 ; Append gas description to current string.
|
|
35 ; Input: PRODL : gas number (0..4)
|
|
36 ; FSR2 : Current string position.
|
|
37 ; Output: Text appended into buffer pointed by FSR2.
|
|
38 extern customview_show_mix
|
|
39 global gaslist_strcat_gas
|
|
40 gaslist_strcat_gas:
|
|
41 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents)
|
|
42 ; Retrieve gas definition:
|
|
43 gaslist_strcat_gas_0:
|
|
44 movf gaslist_gas,W
|
|
45 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
|
|
46 movff PLUSW1,gaslist_O2
|
|
47 movf gaslist_gas,W
|
|
48 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG]
|
|
49 movff PLUSW1,gaslist_He
|
|
50
|
|
51 movff gaslist_O2,lo
|
|
52 movff gaslist_He,hi
|
|
53 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2
|
|
54 return
|
|
55
|
|
56
|
|
57 ;=============================================================================
|
|
58 ; Append current mix to current string (For divemode)
|
|
59 ; Input: FSR2 : Current string position.
|
|
60 ; Output: Text appended into buffer pointed by FSR2.
|
|
61 global gaslist_strcat_gasx
|
|
62 gaslist_strcat_gasx: ; Show current O2/He mix
|
|
63 STRCAT_TEXT tGas
|
|
64 STRCAT ": "
|
|
65 movff char_I_O2_ratio,lo
|
|
66 movff char_I_He_ratio,hi
|
|
67 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2
|
|
68 return
|
|
69
|
|
70 global gaslist_show_type
|
|
71 extern tGasDisabled
|
|
72 extern tDilDisabled
|
|
73 gaslist_show_type:
|
|
74 movf gaslist_gas,W
|
|
75 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG]
|
|
76 movff PLUSW1,gaslist_Type
|
|
77 STRCAT_TEXT tType
|
|
78 lfsr FSR1,tGasDisabled ; Base text number
|
|
79 btfsc ccr_diluent_setup ; In CCR setup?
|
|
80 lfsr FSR1,tDilDisabled ; Base text number
|
|
81 movff gaslist_Type,WREG ; 0-3
|
|
82 rlncf WREG ; x2
|
|
83 addwf FSR1L,F
|
|
84 movlw .0
|
|
85 addwfc FSR1H,F
|
|
86 call strcat_text
|
|
87 return
|
|
88
|
|
89 global gaslist_toggle_type
|
|
90 gaslist_toggle_type:
|
|
91 movf gaslist_gas,W
|
|
92 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG]
|
|
93 movff PLUSW1,gaslist_Type
|
|
94 incf gaslist_Type,F ; 0-3/0-2
|
|
95 btfsc ccr_diluent_setup ; In CCR setup?
|
|
96 bra gaslist_toggle_type2 ; Yes
|
|
97 btfsc gaslist_Type,2 ; >3?
|
|
98 clrf gaslist_Type ; Clear to zero
|
|
99 movff gaslist_Type,PLUSW1 ; Copy back result
|
|
100 return
|
|
101
|
|
102 gaslist_toggle_type2:
|
|
103 movlw .3
|
|
104 cpfslt gaslist_Type ; >2?
|
|
105 clrf gaslist_Type ; Clear to zero
|
|
106 movf gaslist_gas,W
|
|
107 movff gaslist_Type,PLUSW1 ; Copy back result
|
|
108 return
|
|
109
|
|
110 global gaslist_setSP
|
|
111 gaslist_setSP:
|
|
112 movff PRODL,gaslist_gas ; 0-4
|
|
113 return
|
|
114
|
|
115 extern tbar
|
|
116 global gaslist_strcat_setpoint
|
|
117 global gaslist_strcat_setpoint_0
|
|
118 gaslist_strcat_setpoint:
|
|
119 call gaslist_setSP
|
|
120 gaslist_strcat_setpoint_0:
|
|
121 bsf leftbind
|
|
122 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint
|
|
123 bra gaslist_strcat_setpoint2 ; Short version
|
|
124 STRCAT_TEXT tSP
|
|
125 incf gaslist_gas,W
|
|
126 movwf lo
|
|
127 output_8
|
|
128 bcf leftbind
|
|
129 PUTC ":"
|
|
130 gaslist_strcat_setpoint2: ; Short version
|
|
131 lfsr FSR1,opt_gas_type
|
|
132 btfsc divemode
|
|
133 bra gaslist_strcat_setpoint4 ; no "*" in divemode
|
|
134 movf gaslist_gas,W
|
|
135 decf PLUSW1,W ; Type-1 into WREG
|
|
136 bnz gaslist_strcat_setpoint3 ; Not "first"
|
|
137 PUTC "*"
|
|
138 bra gaslist_strcat_setpoint4
|
|
139 gaslist_strcat_setpoint3:
|
|
140 PUTC " "
|
|
141 gaslist_strcat_setpoint4:
|
|
142 movf gaslist_gas,W
|
|
143 lfsr FSR1,char_I_setpoint_cbar
|
|
144 movf PLUSW1,W
|
|
145 movwf lo
|
|
146 clrf hi
|
|
147 bsf leftbind
|
|
148 output_16dp d'3'
|
|
149 btfsc divemode
|
|
150 bra gaslist_strcat_setpoint5 ; Skip text in divemode
|
|
151 STRCAT_TEXT tbar
|
|
152 gaslist_strcat_setpoint5:
|
|
153 PUTC " "
|
|
154 ; Read switch depth
|
|
155 movf gaslist_gas,W
|
|
156 lfsr FSR1,char_I_setpoint_change
|
|
157 movff PLUSW1,lo
|
|
158 bra gaslist_strcat_4 ; And return...
|
|
159
|
|
160 ;----------------------------------------------------------------------------
|
|
161 ; Append gas description to current string.
|
|
162 ; Input: PRODL : gas number (0..4)
|
|
163 ; FSR2 : Current string position.
|
|
164 ; Output: Text appended into buffer pointed by FSR2.
|
|
165 ;
|
|
166 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry.
|
|
167
|
|
168 gaslist_strcat_gas_better: ; Yes, check if this is a "better gas"
|
|
169 movlw .0
|
|
170 movff WREG,win_invert
|
|
171 incf gaslist_gas,W ; gaslist_gas+1 -> WREG
|
|
172 cpfseq better_gas_number ; 1-5 for OC/Bailout and 6-10 for diluents
|
|
173 return
|
50
|
174 call TFT_attention_color ; show in yellow
|
0
|
175 movlw .1
|
|
176 movff WREG,win_invert ; and invert
|
|
177 return
|
|
178
|
|
179 global gaslist_strcat_gas_mod
|
|
180 gaslist_strcat_gas_mod:
|
|
181 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents)
|
|
182
|
|
183 global gaslist_gastitle
|
|
184 gaslist_gastitle:
|
|
185 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint
|
|
186 bra gaslist_gastitle2 ; Short version
|
|
187 STRCAT_TEXT tGas
|
|
188 incf gaslist_gas,W
|
|
189 movwf lo
|
|
190 bsf leftbind
|
|
191 output_8
|
|
192 bcf leftbind
|
|
193 PUTC ":"
|
|
194
|
|
195 gaslist_gastitle2: ; Short version
|
|
196 lfsr FSR1,opt_gas_type
|
|
197 btfsc divemode
|
|
198 bra gaslist_gastitle3 ; no "*" in divemode
|
|
199 movf gaslist_gas,W
|
|
200 decf PLUSW1,W ; Type-1 into WREG
|
|
201 bnz gaslist_gastitle1 ; Not "First"
|
|
202 PUTC "*"
|
|
203 bra gaslist_gastitle3
|
|
204 gaslist_gastitle1:
|
|
205 PUTC " "
|
|
206 gaslist_gastitle3: ; Short version
|
|
207 call TFT_standard_color
|
|
208
|
|
209 btfsc divemode ; In divemode?
|
|
210 rcall gaslist_strcat_gas_better ; Yes, check if this is a "better gas"
|
|
211
|
|
212 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents)
|
|
213 movf PLUSW1,W
|
|
214 bnz gaslist_strcat_3
|
|
215 call TFT_disabled_color
|
|
216 gaslist_strcat_3:
|
|
217 rcall gaslist_strcat_gas_0
|
|
218 PUTC " "
|
|
219 ; Read switch depth
|
|
220 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents)
|
|
221 lfsr FSR1,char_I_deco_gas_change
|
|
222 movff PLUSW1,lo
|
|
223 rcall gaslist_calc_mod ; Compute MOD into WREG
|
|
224 cpfsgt lo
|
|
225 bra gaslist_strcat_4
|
50
|
226 call TFT_warnings_color ; Turn red if bigger
|
0
|
227 gaslist_strcat_4:
|
|
228 TSTOSS opt_units ; 0=Meters, 1=Feets
|
|
229 bra gaslist_strcat_3_metric
|
|
230 ;gaslist_strcat_3_imperial:
|
|
231 movf lo,W
|
|
232 mullw .100 ; convert meters to mbar
|
|
233 movff PRODL,lo
|
|
234 movff PRODH,hi
|
|
235 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
|
|
236 bsf leftbind
|
|
237 output_16_3
|
|
238 STRCAT_TEXT tFeets ; "ft"
|
|
239 return
|
|
240
|
|
241 gaslist_strcat_3_metric:
|
|
242 output_99
|
|
243 STRCAT_TEXT tMeters ; "m"
|
|
244 return
|
|
245
|
|
246 ;----------------------------------------------------------------------------
|
|
247 ; Store current menu item, and display gas description later.
|
|
248 ; Input: PRODL : gas number (0..4)
|
|
249 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry.
|
|
250 global gaslist_setgas
|
|
251 gaslist_setgas:
|
|
252 movff PRODL,gaslist_gas
|
|
253 movlw .5
|
|
254 btfsc ccr_diluent_setup ; in CCR menus?
|
|
255 addwf gaslist_gas,F ; Yes, offset to gases 5-9
|
|
256 return
|
|
257
|
|
258
|
|
259 global gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth
|
|
260 gaslist_cleanup_list:
|
|
261 bcf ignore_last_edited_gas
|
|
262 movlw .0
|
|
263 btfsc ccr_diluent_setup ; In CCR-Menu?
|
|
264 addlw .5 ; Yes, adjust offset
|
|
265 subwf gaslist_gas,F
|
|
266 gaslist_cleanup_list1:
|
|
267 clrf lo
|
|
268 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG]
|
|
269 movlw .5 ; Check 5 gases
|
|
270 movwf hi
|
|
271 gaslist_cleanup_list2:
|
|
272 decf hi,w ; 0-4
|
|
273 btfsc ccr_diluent_setup ; In CCR-Menu?
|
|
274 addlw .5 ; Yes, adjust offset
|
|
275 movff PLUSW1,hi_temp
|
|
276 movlw .1
|
|
277 cpfseq hi_temp ; gas = first ?
|
|
278 bra gaslist_cleanup_list3 ; No
|
|
279 incf lo,F ; Yes, count "first gases"
|
|
280
|
|
281 btfss ignore_last_edited_gas ; If we are not in the second-pass mode
|
|
282 bra gaslist_cleanup_list2b
|
|
283
|
|
284 decf hi,w ; 0-4
|
|
285 cpfseq gaslist_gas ; Do not disable last edited gas
|
|
286 gaslist_cleanup_list2b:
|
|
287 movff hi,lo_temp ; Keep the last "first gas" found
|
|
288 gaslist_cleanup_list3:
|
|
289 decfsz hi,F
|
|
290 bra gaslist_cleanup_list2 ; Loop
|
|
291
|
|
292 tstfsz lo ; No gas active?
|
|
293 bra gaslist_cleanup_list4 ; No, at least one is active
|
|
294
|
|
295 btfsc ccr_diluent_setup ; In CCR-Menu?
|
|
296 bra gaslist_cleanup_list3a ; Yes.
|
|
297 ; make gas1 first and zero
|
|
298 movlw .1 ; First
|
|
299 movwf lo_temp
|
|
300 movwf INDF1
|
|
301 bra gaslist_cleanup_list5 ; Set change depth to zero
|
|
302
|
|
303 gaslist_cleanup_list3a:
|
|
304 movlw .5
|
|
305 addwf FSR1L,F
|
|
306 movlw .0
|
|
307 addwfc FSR1H,F ; Setup to Diluents
|
|
308 ; make dil1 first and zero
|
|
309 movlw .1 ; First
|
|
310 movwf lo_temp
|
|
311 movwf INDF1
|
|
312 bra gaslist_cleanup_list5 ; Set change depth to zero
|
|
313
|
|
314 gaslist_cleanup_list4:
|
|
315 movlw .1
|
|
316 cpfsgt lo ; More then one "first gas"?
|
|
317 bra gaslist_cleanup_list5 ; No, done.
|
|
318 ; More then one Gas is "first gas"
|
|
319 ; Disable last found "first gas" but keep it's change depth
|
|
320 decf lo_temp,W ; 0-4
|
|
321 cpfseq gaslist_gas ; Do not disable last edited gas
|
|
322 bra gaslist_cleanup_list4b
|
|
323 ; Do not disable last edited gas
|
|
324 ; search again but ignore last edited gas
|
|
325 bsf ignore_last_edited_gas
|
|
326 bra gaslist_cleanup_list1 ; Loop until only one "first gas" is left
|
|
327
|
|
328 gaslist_cleanup_list4b:
|
|
329 btfsc ccr_diluent_setup ; In CCR-Menu?
|
|
330 addlw .5 ; Yes, adjust offset
|
|
331 clrf PLUSW1 ; Disable gas
|
|
332 bra gaslist_cleanup_list ; Loop until only one "first gas" is left
|
|
333
|
|
334 gaslist_cleanup_list5:
|
|
335 lfsr FSR1,char_I_deco_gas_change
|
|
336 decf lo_temp,W
|
|
337 btfsc ccr_diluent_setup ; In CCR-Menu?
|
|
338 addlw .5 ; Yes, adjust offset
|
|
339 clrf PLUSW1 ; Set First gas to zero m
|
|
340 return
|
|
341
|
|
342 ;----------------------------------------------------------------------------
|
|
343 ; Increment/Decrement O2 ratio
|
|
344 global gaslist_pO2
|
|
345 gaslist_pO2:
|
|
346 movf gaslist_gas,W
|
|
347 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG]
|
|
348 movff PLUSW1,gaslist_He
|
|
349 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
|
|
350 movff PLUSW1,gaslist_O2
|
|
351
|
|
352 incf gaslist_O2,F ; O2++
|
|
353 movf gaslist_He,W
|
|
354 addwf gaslist_O2,W
|
|
355 movwf lo
|
|
356 movlw .101
|
|
357 cpfslt lo ; O2+He<101?
|
|
358 decf gaslist_O2,F ; O2-- (Unchanged)
|
|
359
|
|
360 movf gaslist_gas,W
|
|
361 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG]
|
|
362 return
|
|
363
|
|
364 global gaslist_mO2
|
|
365 gaslist_mO2:
|
|
366 movf gaslist_gas,W
|
|
367 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
|
|
368 movff PLUSW1,gaslist_O2
|
|
369
|
|
370 decf gaslist_O2,F
|
|
371 movlw gaslist_min_o2
|
|
372 cpfslt gaslist_O2
|
|
373 bra gaslist_mO2_1
|
|
374 movlw gaslist_min_o2
|
|
375 movwf gaslist_O2
|
|
376 gaslist_mO2_1:
|
|
377 movf gaslist_gas,W
|
|
378 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG]
|
|
379 return
|
|
380
|
|
381 ;----------------------------------------------------------------------------
|
|
382 ; Increment/Decrement He ratio
|
|
383 global gaslist_pHe
|
|
384 gaslist_pHe:
|
|
385 movf gaslist_gas,W
|
|
386 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
|
|
387 movff PLUSW1,gaslist_O2
|
|
388 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG]
|
|
389 movff PLUSW1,gaslist_He
|
|
390
|
|
391 incf gaslist_He,F ; He++
|
|
392 movf gaslist_He,W
|
|
393 addwf gaslist_O2,W
|
|
394 movwf lo
|
|
395 movlw .101
|
|
396 cpfslt lo ; O2+He<101?
|
|
397 decf gaslist_He,F ; Yes, He-- (Unchanged)
|
|
398
|
|
399 movf gaslist_gas,W
|
|
400 movff gaslist_He,PLUSW1 ; And write back to opt_gas_He_ratio[WREG]
|
|
401 return
|
|
402
|
|
403 global gaslist_mHe
|
|
404 gaslist_mHe:
|
|
405 movf gaslist_gas,W
|
|
406 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG]
|
|
407 movff PLUSW1,gaslist_He
|
|
408
|
|
409 decf gaslist_He,F
|
|
410 bnn gaslist_mHe_1
|
|
411 clrf gaslist_He
|
|
412 gaslist_mHe_1:
|
|
413 movf gaslist_gas,W
|
|
414 movff gaslist_He,PLUSW1 ; And write back to opt_gas_He_ratio[WREG]
|
|
415 return
|
|
416
|
|
417 ;----------------------------------------------------------------------------
|
|
418 ; Increment/Decrement switch depth
|
|
419 global gaslist_pDepth
|
|
420 gaslist_pDepth:
|
|
421 movf gaslist_gas,W
|
|
422 lfsr FSR1,char_I_deco_gas_change
|
|
423 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG]
|
|
424
|
|
425 incf gaslist_O2,F
|
|
426 movlw gaslist_max_change_depth
|
|
427 cpfsgt gaslist_O2
|
|
428 bra gaslist_pDepth_1
|
|
429 movlw gaslist_max_change_depth
|
|
430 movwf gaslist_O2
|
|
431 gaslist_pDepth_1:
|
|
432 movf gaslist_gas,W
|
|
433 movff gaslist_O2,PLUSW1 ; Write back to char_I_deco_gas_change[WREG]
|
|
434 return
|
|
435
|
|
436 global gaslist_mDepth
|
|
437 gaslist_mDepth:
|
|
438 movf gaslist_gas,W
|
|
439 lfsr FSR1,char_I_deco_gas_change
|
|
440 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG]
|
|
441
|
|
442 decf gaslist_O2,F
|
|
443 btfsc STATUS,N
|
|
444 clrf gaslist_O2
|
|
445
|
|
446 movf gaslist_gas,W
|
|
447 movff gaslist_O2,PLUSW1 ; And write back to char_I_deco_gas_change[WREG]
|
|
448 return
|
|
449
|
|
450 global gaslist_spplus
|
|
451 gaslist_spplus:
|
|
452 movf gaslist_gas,W
|
|
453 lfsr FSR1,char_I_setpoint_cbar
|
|
454 movff PLUSW1,lo ; Read char_I_setpoint_cbar[WREG]
|
|
455 movlw gaslist_sp_stepsize
|
|
456 addwf lo,F
|
|
457 movlw gaslist_sp_max
|
|
458 cpfsgt lo
|
|
459 bra gaslist_spplus2
|
|
460 movlw gaslist_sp_min
|
|
461 movwf lo
|
|
462 gaslist_spplus2:
|
|
463 movf gaslist_gas,W
|
|
464 movff lo,PLUSW1 ; Write back to char_I_setpoint_cbar
|
|
465 return
|
|
466
|
|
467 global gaslist_spdepthplus
|
|
468 gaslist_spdepthplus:
|
|
469 movf gaslist_gas,W
|
|
470 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m
|
|
471 lfsr FSR1,char_I_setpoint_change
|
|
472 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG]
|
|
473 incf gaslist_O2,F
|
|
474 movlw gaslist_max_change_depth
|
|
475 cpfsgt gaslist_O2
|
|
476 bra gaslist_spdepthplus_1
|
|
477 movlw gaslist_max_change_depth
|
|
478 movwf gaslist_O2
|
|
479 gaslist_spdepthplus_1:
|
|
480 movf gaslist_gas,W
|
|
481 movff gaslist_O2,PLUSW1 ; Write back to char_I_deco_gas_change[WREG]
|
|
482 return
|
|
483
|
|
484 gaslist_spdepthplus3:
|
|
485 movlw .0
|
|
486 movff WREG,char_I_setpoint_change+0 ; Reset to 0m
|
|
487 return
|
|
488
|
|
489 global gaslist_spdepthminus
|
|
490 gaslist_spdepthminus:
|
|
491 movf gaslist_gas,W
|
|
492 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m
|
|
493 lfsr FSR1,char_I_setpoint_change
|
|
494 movff PLUSW1,gaslist_O2 ; Read opt_gas_O2_ratio[WREG]
|
|
495 decf gaslist_O2,F
|
|
496 btfsc STATUS,N
|
|
497 clrf gaslist_O2
|
|
498 movf gaslist_gas,W
|
|
499 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG]
|
|
500 return
|
|
501
|
|
502 ;----------------------------------------------------------------------------
|
|
503 ; Compute MOD from ppO2 Max and current O2 Ratio.
|
|
504 ;
|
|
505 ; Input: gaslist_gas = current gas index.
|
|
506 ; opt_gas_O2_ratio[gaslist_gas] = current O2 ratio
|
|
507 ; Output: WREG = MOD [m]
|
|
508 ;
|
|
509 gaslist_calc_mod:
|
|
510 movf gaslist_gas,W ; Read current gas O2 ratio
|
|
511 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
|
|
512 movf PLUSW1,W
|
|
513
|
|
514 btfsc divemode ; In divemode?
|
|
515 bra gaslist_calc_mod_divemode ; Yes.
|
|
516
|
|
517 ; Pamb max = ppO2 Max / O2 ratio
|
|
518 movwf xB+0
|
|
519 clrf xB+1
|
|
520
|
|
521 movff opt_ppO2_max,WREG
|
|
522 mullw .10
|
|
523 movff PRODL,xA+0
|
|
524 movff PRODH,xA+1
|
|
525 call div16x16
|
|
526
|
|
527 ; Prof = Pamb - 1bar.
|
|
528 movf xC+0,W
|
|
529 addlw -.10
|
|
530 return
|
|
531
|
|
532 gaslist_calc_mod_divemode:
|
|
533 extern TFT_color_code1
|
|
534 movwf hi ; Copy O2%
|
|
535 movlw warn_gas_in_gaslist
|
|
536 call TFT_color_code1 ; Color-code current row in Gaslist (%O2 in hi), opt_ppO2_max as threshold
|
|
537 return
|
|
538 ;----------------------------------------------------------------------------
|
|
539 global gaslist_MOD_END
|
|
540 gaslist_MOD_END:
|
|
541 rcall gaslist_calc_mod ; Compute MOD into WREG
|
|
542 movwf lo ; Copy to lo
|
14
|
543 STRCAT_TEXT tMOD ; MOD:
|
0
|
544 TSTOSS opt_units ; 0=Meters, 1=Feets
|
|
545 bra gaslist_MOD_metric
|
|
546 ;gaslist_MOD_imperial:
|
|
547 movf lo,W
|
|
548 mullw .100 ; convert meters to mbar
|
|
549 movff PRODL,lo
|
|
550 movff PRODH,hi
|
|
551 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
|
|
552 bsf leftbind
|
|
553 output_16_3
|
|
554 STRCAT_TEXT tFeets ; "ft"
|
|
555 bra gaslist_MOD_common
|
|
556 gaslist_MOD_metric:
|
|
557 output_8
|
|
558 STRCAT_TEXT tMeters ; m
|
|
559 gaslist_MOD_common:
|
|
560 PUTC "/"
|
|
561 STRCAT_TEXT tEND ; END:
|
|
562 rcall gaslist_calc_mod ; Output: WREG = MOD [m]
|
|
563 addlw .10 ; MOD=MOD+10m
|
|
564 movwf xB+0
|
|
565 clrf xB+1
|
|
566 movlw d'100'
|
|
567 movwf xA+0
|
|
568 movf gaslist_He,W ; He value in % -> WREG
|
|
569 subwf xA+0,F ; xA+0 = 100 - He Value in %
|
|
570 clrf xA+1
|
|
571 call mult16x16 ; xA*xB=xC
|
|
572 movff xC+0,xA+0
|
|
573 movff xC+1,xA+1
|
|
574 movlw d'100'
|
|
575 movwf xB+0
|
|
576 clrf xB+1
|
|
577 call div16x16 ; xA/xB=xC with xA as remainder
|
|
578 ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100
|
|
579 movlw d'10'
|
|
580 subwf xC+0,F ; Subtract 10m...
|
|
581 movff xC+0,lo
|
|
582 ; END 8Bit only
|
|
583 ; movlw d'0'
|
|
584 ; subwfb xC+1,F
|
|
585 ; movff xC+1,hi
|
|
586 TSTOSS opt_units ; 0=Meters, 1=Feets
|
|
587 bra gaslist_END_metric
|
|
588 ;gaslist_END_imperial:
|
|
589 movf lo,W
|
|
590 mullw .100 ; convert meters to mbar
|
|
591 movff PRODL,lo
|
|
592 movff PRODH,hi
|
|
593 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
|
|
594 bsf leftbind
|
|
595 output_16_3
|
|
596 STRCAT_TEXT tFeets ; "ft"
|
|
597 return
|
|
598 gaslist_END_metric:
|
|
599 output_8
|
|
600 STRCAT_TEXT tMeters ; m
|
|
601 return
|
|
602
|
|
603 ;----------------------------------------------------------------------------
|
|
604 global gaslist_reset_mod_title
|
|
605 gaslist_reset_mod_title:
|
|
606 STRCAT_TEXT tDepthReset
|
|
607
|
|
608 gaslist_reset_mod_title2:
|
|
609 rcall gaslist_calc_mod ; Compute MOD into WREG
|
|
610 movwf lo ; Copy to lo
|
|
611
|
|
612 movf gaslist_gas,W ; Compare to switch depth
|
|
613 lfsr FSR1,char_I_deco_gas_change
|
|
614 movf PLUSW1,W
|
|
615 cpfslt lo
|
|
616 bra gaslist_strcat_4 ; And return...
|
50
|
617 call TFT_warnings_color ; Turn red if bigger !
|
0
|
618 bra gaslist_strcat_4 ; And return...
|
|
619
|
|
620 ;----------------------------------------------------------------------------
|
|
621 global gaslist_reset_mod
|
|
622 gaslist_reset_mod:
|
|
623 rcall gaslist_calc_mod ; Compute MOD
|
|
624 movwf gaslist_depth
|
|
625
|
|
626 movf gaslist_gas,W ; Read current gas O2 ratio
|
|
627 lfsr FSR1,char_I_deco_gas_change
|
|
628 movff gaslist_depth,PLUSW1 ; And save new change depth
|
|
629 return
|
|
630 ;----------------------------------------------------------------------------
|
|
631 END |