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 btfsc divemode
|
|
132 bra gaslist_strcat_setpoint4 ; no "*" in divemode
|
95
|
133 movf gaslist_gas,W ; Number-1 into WREG
|
|
134 bnz gaslist_strcat_setpoint3 ; Not SP1
|
0
|
135 PUTC "*"
|
|
136 bra gaslist_strcat_setpoint4
|
|
137 gaslist_strcat_setpoint3:
|
|
138 PUTC " "
|
|
139 gaslist_strcat_setpoint4:
|
|
140 movf gaslist_gas,W
|
|
141 lfsr FSR1,char_I_setpoint_cbar
|
|
142 movf PLUSW1,W
|
|
143 movwf lo
|
|
144 clrf hi
|
|
145 bsf leftbind
|
|
146 output_16dp d'3'
|
|
147 btfsc divemode
|
|
148 bra gaslist_strcat_setpoint5 ; Skip text in divemode
|
|
149 STRCAT_TEXT tbar
|
|
150 gaslist_strcat_setpoint5:
|
|
151 PUTC " "
|
|
152 ; Read switch depth
|
|
153 movf gaslist_gas,W
|
|
154 lfsr FSR1,char_I_setpoint_change
|
|
155 movff PLUSW1,lo
|
|
156 bra gaslist_strcat_4 ; And return...
|
|
157
|
|
158 ;----------------------------------------------------------------------------
|
|
159 ; Append gas description to current string.
|
|
160 ; Input: PRODL : gas number (0..4)
|
|
161 ; FSR2 : Current string position.
|
|
162 ; Output: Text appended into buffer pointed by FSR2.
|
|
163 ;
|
|
164 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry.
|
|
165
|
|
166 gaslist_strcat_gas_better: ; Yes, check if this is a "better gas"
|
|
167 movlw .0
|
|
168 movff WREG,win_invert
|
160
|
169 decf better_gas_number,W ; better_gas_number-1 -> WREG
|
|
170 btfsc ccr_diluent_setup ; in CCR menus?
|
|
171 addlw .5 ; Yes, offset to gases 5-9
|
|
172 cpfseq gaslist_gas ; 0-4 for OC/Bailout, 5-9 for Diluents
|
0
|
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
|
97
|
220 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5
|
|
221 movlw .4
|
|
222 cpfsgt gaslist_gas ; >4? (-> Diluents)
|
|
223 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases
|
|
224
|
0
|
225 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents)
|
|
226 movff PLUSW1,lo
|
|
227 rcall gaslist_calc_mod ; Compute MOD into WREG
|
|
228 cpfsgt lo
|
|
229 bra gaslist_strcat_4
|
50
|
230 call TFT_warnings_color ; Turn red if bigger
|
0
|
231 gaslist_strcat_4:
|
|
232 TSTOSS opt_units ; 0=Meters, 1=Feets
|
|
233 bra gaslist_strcat_3_metric
|
|
234 ;gaslist_strcat_3_imperial:
|
|
235 movf lo,W
|
|
236 mullw .100 ; convert meters to mbar
|
|
237 movff PRODL,lo
|
|
238 movff PRODH,hi
|
|
239 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
|
|
240 bsf leftbind
|
|
241 output_16_3
|
|
242 STRCAT_TEXT tFeets ; "ft"
|
|
243 return
|
|
244
|
|
245 gaslist_strcat_3_metric:
|
|
246 output_99
|
|
247 STRCAT_TEXT tMeters ; "m"
|
|
248 return
|
|
249
|
|
250 ;----------------------------------------------------------------------------
|
|
251 ; Store current menu item, and display gas description later.
|
|
252 ; Input: PRODL : gas number (0..4)
|
|
253 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry.
|
|
254 global gaslist_setgas
|
|
255 gaslist_setgas:
|
|
256 movff PRODL,gaslist_gas
|
|
257 movlw .5
|
|
258 btfsc ccr_diluent_setup ; in CCR menus?
|
|
259 addwf gaslist_gas,F ; Yes, offset to gases 5-9
|
|
260 return
|
|
261
|
|
262
|
|
263 global gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth
|
|
264 gaslist_cleanup_list:
|
|
265 bcf ignore_last_edited_gas
|
|
266 movlw .0
|
|
267 btfsc ccr_diluent_setup ; In CCR-Menu?
|
|
268 addlw .5 ; Yes, adjust offset
|
|
269 subwf gaslist_gas,F
|
|
270 gaslist_cleanup_list1:
|
|
271 clrf lo
|
|
272 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG]
|
|
273 movlw .5 ; Check 5 gases
|
|
274 movwf hi
|
|
275 gaslist_cleanup_list2:
|
|
276 decf hi,w ; 0-4
|
|
277 btfsc ccr_diluent_setup ; In CCR-Menu?
|
|
278 addlw .5 ; Yes, adjust offset
|
|
279 movff PLUSW1,hi_temp
|
|
280 movlw .1
|
|
281 cpfseq hi_temp ; gas = first ?
|
|
282 bra gaslist_cleanup_list3 ; No
|
|
283 incf lo,F ; Yes, count "first gases"
|
|
284
|
|
285 btfss ignore_last_edited_gas ; If we are not in the second-pass mode
|
|
286 bra gaslist_cleanup_list2b
|
|
287
|
|
288 decf hi,w ; 0-4
|
|
289 cpfseq gaslist_gas ; Do not disable last edited gas
|
|
290 gaslist_cleanup_list2b:
|
|
291 movff hi,lo_temp ; Keep the last "first gas" found
|
|
292 gaslist_cleanup_list3:
|
|
293 decfsz hi,F
|
|
294 bra gaslist_cleanup_list2 ; Loop
|
|
295
|
|
296 tstfsz lo ; No gas active?
|
|
297 bra gaslist_cleanup_list4 ; No, at least one is active
|
|
298
|
|
299 btfsc ccr_diluent_setup ; In CCR-Menu?
|
|
300 bra gaslist_cleanup_list3a ; Yes.
|
|
301 ; make gas1 first and zero
|
|
302 movlw .1 ; First
|
|
303 movwf lo_temp
|
|
304 movwf INDF1
|
|
305 bra gaslist_cleanup_list5 ; Set change depth to zero
|
|
306
|
|
307 gaslist_cleanup_list3a:
|
|
308 movlw .5
|
|
309 addwf FSR1L,F
|
|
310 movlw .0
|
|
311 addwfc FSR1H,F ; Setup to Diluents
|
|
312 ; make dil1 first and zero
|
|
313 movlw .1 ; First
|
|
314 movwf lo_temp
|
|
315 movwf INDF1
|
|
316 bra gaslist_cleanup_list5 ; Set change depth to zero
|
|
317
|
|
318 gaslist_cleanup_list4:
|
|
319 movlw .1
|
|
320 cpfsgt lo ; More then one "first gas"?
|
|
321 bra gaslist_cleanup_list5 ; No, done.
|
|
322 ; More then one Gas is "first gas"
|
|
323 ; Disable last found "first gas" but keep it's change depth
|
|
324 decf lo_temp,W ; 0-4
|
|
325 cpfseq gaslist_gas ; Do not disable last edited gas
|
|
326 bra gaslist_cleanup_list4b
|
|
327 ; Do not disable last edited gas
|
|
328 ; search again but ignore last edited gas
|
|
329 bsf ignore_last_edited_gas
|
|
330 bra gaslist_cleanup_list1 ; Loop until only one "first gas" is left
|
|
331
|
|
332 gaslist_cleanup_list4b:
|
|
333 btfsc ccr_diluent_setup ; In CCR-Menu?
|
|
334 addlw .5 ; Yes, adjust offset
|
|
335 clrf PLUSW1 ; Disable gas
|
|
336 bra gaslist_cleanup_list ; Loop until only one "first gas" is left
|
|
337
|
|
338 gaslist_cleanup_list5:
|
97
|
339 ; Read switch depth
|
|
340 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5
|
|
341 btfss ccr_diluent_setup ; In CCR-Menu?
|
|
342 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases
|
0
|
343 decf lo_temp,W
|
|
344 btfsc ccr_diluent_setup ; In CCR-Menu?
|
|
345 addlw .5 ; Yes, adjust offset
|
|
346 clrf PLUSW1 ; Set First gas to zero m
|
|
347 return
|
|
348
|
|
349 ;----------------------------------------------------------------------------
|
|
350 ; Increment/Decrement O2 ratio
|
|
351 global gaslist_pO2
|
|
352 gaslist_pO2:
|
|
353 movf gaslist_gas,W
|
|
354 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG]
|
|
355 movff PLUSW1,gaslist_He
|
|
356 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
|
|
357 movff PLUSW1,gaslist_O2
|
|
358
|
|
359 incf gaslist_O2,F ; O2++
|
|
360 movf gaslist_He,W
|
|
361 addwf gaslist_O2,W
|
|
362 movwf lo
|
|
363 movlw .101
|
|
364 cpfslt lo ; O2+He<101?
|
|
365 decf gaslist_O2,F ; O2-- (Unchanged)
|
|
366
|
|
367 movf gaslist_gas,W
|
|
368 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG]
|
|
369 return
|
|
370
|
|
371 global gaslist_mO2
|
|
372 gaslist_mO2:
|
|
373 movf gaslist_gas,W
|
|
374 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
|
|
375 movff PLUSW1,gaslist_O2
|
|
376
|
|
377 decf gaslist_O2,F
|
|
378 movlw gaslist_min_o2
|
|
379 cpfslt gaslist_O2
|
|
380 bra gaslist_mO2_1
|
|
381 movlw gaslist_min_o2
|
|
382 movwf gaslist_O2
|
|
383 gaslist_mO2_1:
|
|
384 movf gaslist_gas,W
|
|
385 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG]
|
|
386 return
|
|
387
|
|
388 ;----------------------------------------------------------------------------
|
|
389 ; Increment/Decrement He ratio
|
|
390 global gaslist_pHe
|
|
391 gaslist_pHe:
|
|
392 movf gaslist_gas,W
|
|
393 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
|
|
394 movff PLUSW1,gaslist_O2
|
|
395 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG]
|
|
396 movff PLUSW1,gaslist_He
|
|
397
|
|
398 incf gaslist_He,F ; He++
|
|
399 movf gaslist_He,W
|
|
400 addwf gaslist_O2,W
|
|
401 movwf lo
|
|
402 movlw .101
|
|
403 cpfslt lo ; O2+He<101?
|
|
404 decf gaslist_He,F ; Yes, He-- (Unchanged)
|
|
405
|
|
406 movf gaslist_gas,W
|
|
407 movff gaslist_He,PLUSW1 ; And write back to opt_gas_He_ratio[WREG]
|
|
408 return
|
|
409
|
|
410 global gaslist_mHe
|
|
411 gaslist_mHe:
|
|
412 movf gaslist_gas,W
|
|
413 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG]
|
|
414 movff PLUSW1,gaslist_He
|
|
415
|
|
416 decf gaslist_He,F
|
|
417 bnn gaslist_mHe_1
|
|
418 clrf gaslist_He
|
|
419 gaslist_mHe_1:
|
|
420 movf gaslist_gas,W
|
|
421 movff gaslist_He,PLUSW1 ; And write back to opt_gas_He_ratio[WREG]
|
|
422 return
|
|
423
|
|
424 ;----------------------------------------------------------------------------
|
|
425 ; Increment/Decrement switch depth
|
|
426 global gaslist_pDepth
|
|
427 gaslist_pDepth:
|
97
|
428 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5
|
|
429 movlw .4
|
|
430 cpfsgt gaslist_gas ; >4? (-> Diluents)
|
|
431 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases
|
|
432
|
0
|
433 movf gaslist_gas,W
|
|
434 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG]
|
|
435
|
|
436 incf gaslist_O2,F
|
|
437 movlw gaslist_max_change_depth
|
|
438 cpfsgt gaslist_O2
|
|
439 bra gaslist_pDepth_1
|
|
440 movlw gaslist_max_change_depth
|
|
441 movwf gaslist_O2
|
|
442 gaslist_pDepth_1:
|
|
443 movf gaslist_gas,W
|
|
444 movff gaslist_O2,PLUSW1 ; Write back to char_I_deco_gas_change[WREG]
|
|
445 return
|
|
446
|
|
447 global gaslist_mDepth
|
|
448 gaslist_mDepth:
|
97
|
449 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5
|
|
450 movlw .4
|
|
451 cpfsgt gaslist_gas ; >4? (-> Diluents)
|
|
452 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases
|
|
453
|
0
|
454 movf gaslist_gas,W
|
|
455 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG]
|
|
456
|
|
457 decf gaslist_O2,F
|
|
458 btfsc STATUS,N
|
|
459 clrf gaslist_O2
|
|
460
|
|
461 movf gaslist_gas,W
|
|
462 movff gaslist_O2,PLUSW1 ; And write back to char_I_deco_gas_change[WREG]
|
|
463 return
|
|
464
|
|
465 global gaslist_spplus
|
|
466 gaslist_spplus:
|
|
467 movf gaslist_gas,W
|
|
468 lfsr FSR1,char_I_setpoint_cbar
|
|
469 movff PLUSW1,lo ; Read char_I_setpoint_cbar[WREG]
|
|
470 movlw gaslist_sp_stepsize
|
|
471 addwf lo,F
|
|
472 movlw gaslist_sp_max
|
|
473 cpfsgt lo
|
|
474 bra gaslist_spplus2
|
|
475 movlw gaslist_sp_min
|
|
476 movwf lo
|
|
477 gaslist_spplus2:
|
|
478 movf gaslist_gas,W
|
|
479 movff lo,PLUSW1 ; Write back to char_I_setpoint_cbar
|
|
480 return
|
|
481
|
|
482 global gaslist_spdepthplus
|
|
483 gaslist_spdepthplus:
|
|
484 movf gaslist_gas,W
|
|
485 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m
|
|
486 lfsr FSR1,char_I_setpoint_change
|
|
487 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG]
|
|
488 incf gaslist_O2,F
|
|
489 movlw gaslist_max_change_depth
|
|
490 cpfsgt gaslist_O2
|
|
491 bra gaslist_spdepthplus_1
|
|
492 movlw gaslist_max_change_depth
|
|
493 movwf gaslist_O2
|
|
494 gaslist_spdepthplus_1:
|
|
495 movf gaslist_gas,W
|
|
496 movff gaslist_O2,PLUSW1 ; Write back to char_I_deco_gas_change[WREG]
|
|
497 return
|
|
498
|
|
499 gaslist_spdepthplus3:
|
|
500 movlw .0
|
|
501 movff WREG,char_I_setpoint_change+0 ; Reset to 0m
|
|
502 return
|
|
503
|
|
504 global gaslist_spdepthminus
|
|
505 gaslist_spdepthminus:
|
|
506 movf gaslist_gas,W
|
|
507 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m
|
|
508 lfsr FSR1,char_I_setpoint_change
|
|
509 movff PLUSW1,gaslist_O2 ; Read opt_gas_O2_ratio[WREG]
|
|
510 decf gaslist_O2,F
|
|
511 btfsc STATUS,N
|
|
512 clrf gaslist_O2
|
|
513 movf gaslist_gas,W
|
|
514 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG]
|
|
515 return
|
|
516
|
|
517 ;----------------------------------------------------------------------------
|
|
518 ; Compute MOD from ppO2 Max and current O2 Ratio.
|
|
519 ;
|
|
520 ; Input: gaslist_gas = current gas index.
|
|
521 ; opt_gas_O2_ratio[gaslist_gas] = current O2 ratio
|
|
522 ; Output: WREG = MOD [m]
|
|
523 ;
|
|
524 gaslist_calc_mod:
|
|
525 movf gaslist_gas,W ; Read current gas O2 ratio
|
|
526 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG]
|
|
527 movf PLUSW1,W
|
|
528
|
|
529 btfsc divemode ; In divemode?
|
|
530 bra gaslist_calc_mod_divemode ; Yes.
|
|
531
|
|
532 ; Pamb max = ppO2 Max / O2 ratio
|
|
533 movwf xB+0
|
|
534 clrf xB+1
|
|
535
|
|
536 movff opt_ppO2_max,WREG
|
|
537 mullw .10
|
|
538 movff PRODL,xA+0
|
|
539 movff PRODH,xA+1
|
|
540 call div16x16
|
|
541
|
|
542 ; Prof = Pamb - 1bar.
|
|
543 movf xC+0,W
|
|
544 addlw -.10
|
|
545 return
|
|
546
|
|
547 gaslist_calc_mod_divemode:
|
|
548 extern TFT_color_code1
|
|
549 movwf hi ; Copy O2%
|
|
550 movlw warn_gas_in_gaslist
|
|
551 call TFT_color_code1 ; Color-code current row in Gaslist (%O2 in hi), opt_ppO2_max as threshold
|
|
552 return
|
|
553 ;----------------------------------------------------------------------------
|
154
|
554
|
|
555 global gaslist_ppo2
|
|
556 gaslist_ppo2:
|
|
557 STRCAT_TEXT tppO2 ; ppO2:
|
|
558 movf gaslist_gas,W
|
|
559 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents
|
|
560 btfss ccr_diluent_setup ; In CCR-Menu?
|
|
561 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC/Bailout Gases
|
|
562 movf PLUSW1,W
|
|
563 mullw .10 ; PROD=Depth in mbar/10 (100 = 1.00 bar)
|
|
564 movlw .100
|
|
565 addwf PRODL,F
|
|
566 movlw .0
|
|
567 addwfc PRODH,F ; add 1bar
|
|
568 movff PRODL,xA+0
|
|
569 movff PRODH,xA+1
|
|
570 movf gaslist_gas,W ; Read current gas O2 ratio
|
|
571 lfsr FSR1,opt_dil_O2_ratio-.5 ; Read dil_gas_O2_ratio[WREG]
|
|
572 btfss ccr_diluent_setup ; In CCR-Menu?
|
|
573 lfsr FSR1,opt_gas_O2_ratio ; No, read opt_gas_O2_ratio[WREG]
|
|
574 movff PLUSW1,xB+0
|
|
575 clrf xB+1
|
|
576 call mult16x16 ; char_I_O2_ratio * (p_amb/10)
|
|
577 movff xC+0,xA+0
|
|
578 movff xC+1,xA+1
|
|
579 movlw d'100'
|
|
580 movwf xB+0
|
|
581 clrf xB+1
|
|
582 call div16x16 ; xC=(char_I_O2_ratio * p_amb/10)/100
|
|
583 ; Check very high ppO2 manually
|
|
584 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar?
|
|
585 bra gaslist_ppo2_2 ; Yes, display fixed Value!
|
|
586 movff xC+0,lo
|
|
587 movff xC+1,hi
|
|
588 bcf ignore_digit4
|
|
589 bsf leftbind
|
|
590 output_16dp d'3' ; x.xx
|
|
591 STRCAT_TEXT tbar ; bar
|
|
592 return
|
|
593 gaslist_ppo2_2:
|
|
594 STRCAT ">6.6"
|
|
595 return
|
|
596
|
0
|
597 global gaslist_MOD_END
|
|
598 gaslist_MOD_END:
|
|
599 rcall gaslist_calc_mod ; Compute MOD into WREG
|
|
600 movwf lo ; Copy to lo
|
14
|
601 STRCAT_TEXT tMOD ; MOD:
|
0
|
602 TSTOSS opt_units ; 0=Meters, 1=Feets
|
|
603 bra gaslist_MOD_metric
|
|
604 ;gaslist_MOD_imperial:
|
|
605 movf lo,W
|
|
606 mullw .100 ; convert meters to mbar
|
|
607 movff PRODL,lo
|
|
608 movff PRODH,hi
|
|
609 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
|
|
610 bsf leftbind
|
|
611 output_16_3
|
|
612 STRCAT_TEXT tFeets ; "ft"
|
|
613 bra gaslist_MOD_common
|
|
614 gaslist_MOD_metric:
|
|
615 output_8
|
|
616 STRCAT_TEXT tMeters ; m
|
|
617 gaslist_MOD_common:
|
|
618 PUTC "/"
|
|
619 STRCAT_TEXT tEND ; END:
|
|
620 rcall gaslist_calc_mod ; Output: WREG = MOD [m]
|
|
621 addlw .10 ; MOD=MOD+10m
|
|
622 movwf xB+0
|
|
623 clrf xB+1
|
|
624 movlw d'100'
|
|
625 movwf xA+0
|
|
626 movf gaslist_He,W ; He value in % -> WREG
|
|
627 subwf xA+0,F ; xA+0 = 100 - He Value in %
|
|
628 clrf xA+1
|
|
629 call mult16x16 ; xA*xB=xC
|
|
630 movff xC+0,xA+0
|
|
631 movff xC+1,xA+1
|
|
632 movlw d'100'
|
|
633 movwf xB+0
|
|
634 clrf xB+1
|
|
635 call div16x16 ; xA/xB=xC with xA as remainder
|
|
636 ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100
|
|
637 movlw d'10'
|
|
638 subwf xC+0,F ; Subtract 10m...
|
|
639 movff xC+0,lo
|
|
640 ; END 8Bit only
|
|
641 ; movlw d'0'
|
|
642 ; subwfb xC+1,F
|
|
643 ; movff xC+1,hi
|
|
644 TSTOSS opt_units ; 0=Meters, 1=Feets
|
|
645 bra gaslist_END_metric
|
|
646 ;gaslist_END_imperial:
|
|
647 movf lo,W
|
|
648 mullw .100 ; convert meters to mbar
|
|
649 movff PRODL,lo
|
|
650 movff PRODH,hi
|
|
651 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
|
|
652 bsf leftbind
|
|
653 output_16_3
|
|
654 STRCAT_TEXT tFeets ; "ft"
|
|
655 return
|
|
656 gaslist_END_metric:
|
|
657 output_8
|
|
658 STRCAT_TEXT tMeters ; m
|
|
659 return
|
|
660
|
|
661 ;----------------------------------------------------------------------------
|
|
662 global gaslist_reset_mod_title
|
|
663 gaslist_reset_mod_title:
|
|
664 STRCAT_TEXT tDepthReset
|
|
665
|
|
666 gaslist_reset_mod_title2:
|
|
667 rcall gaslist_calc_mod ; Compute MOD into WREG
|
|
668 movwf lo ; Copy to lo
|
|
669
|
|
670 movf gaslist_gas,W ; Compare to switch depth
|
154
|
671 lfsr FSR1,char_I_dil_change ; Setup Diluents
|
97
|
672 btfss ccr_diluent_setup ; In CCR-Menu?
|
|
673 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases
|
0
|
674 movf PLUSW1,W
|
|
675 cpfslt lo
|
|
676 bra gaslist_strcat_4 ; And return...
|
50
|
677 call TFT_warnings_color ; Turn red if bigger !
|
0
|
678 bra gaslist_strcat_4 ; And return...
|
|
679
|
|
680 ;----------------------------------------------------------------------------
|
|
681 global gaslist_reset_mod
|
|
682 gaslist_reset_mod:
|
|
683 rcall gaslist_calc_mod ; Compute MOD
|
|
684 movwf gaslist_depth
|
|
685
|
|
686 movf gaslist_gas,W ; Read current gas O2 ratio
|
97
|
687
|
|
688 lfsr FSR1,char_I_dil_change ; Setup Diluents mH
|
|
689 btfss ccr_diluent_setup ; In CCR-Menu?
|
|
690 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases
|
|
691
|
0
|
692 movff gaslist_depth,PLUSW1 ; And save new change depth
|
|
693 return
|
|
694 ;----------------------------------------------------------------------------
|
|
695 END |