Mercurial > public > hwos_code
annotate src/gaslist.asm @ 106:bc7c022d2c74
minor
author | heinrichsweikamp |
---|---|
date | Tue, 03 Jun 2014 13:20:44 +0200 |
parents | 53a99a2dc6a1 |
children | afa31c815f24 |
rev | line source |
---|---|
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
3dfc2b7ced6d
BUGFIX: Show "*" always in front of the initial Setpoint 1
heinrichsweikamp
parents:
50
diff
changeset
|
133 movf gaslist_gas,W ; Number-1 into WREG |
3dfc2b7ced6d
BUGFIX: Show "*" always in front of the initial Setpoint 1
heinrichsweikamp
parents:
50
diff
changeset
|
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 | |
169 incf gaslist_gas,W ; gaslist_gas+1 -> WREG | |
170 cpfseq better_gas_number ; 1-5 for OC/Bailout and 6-10 for diluents | |
171 return | |
50 | 172 call TFT_attention_color ; show in yellow |
0 | 173 movlw .1 |
174 movff WREG,win_invert ; and invert | |
175 return | |
176 | |
177 global gaslist_strcat_gas_mod | |
178 gaslist_strcat_gas_mod: | |
179 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents) | |
180 | |
181 global gaslist_gastitle | |
182 gaslist_gastitle: | |
183 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
184 bra gaslist_gastitle2 ; Short version | |
185 STRCAT_TEXT tGas | |
186 incf gaslist_gas,W | |
187 movwf lo | |
188 bsf leftbind | |
189 output_8 | |
190 bcf leftbind | |
191 PUTC ":" | |
192 | |
193 gaslist_gastitle2: ; Short version | |
194 lfsr FSR1,opt_gas_type | |
195 btfsc divemode | |
196 bra gaslist_gastitle3 ; no "*" in divemode | |
197 movf gaslist_gas,W | |
198 decf PLUSW1,W ; Type-1 into WREG | |
199 bnz gaslist_gastitle1 ; Not "First" | |
200 PUTC "*" | |
201 bra gaslist_gastitle3 | |
202 gaslist_gastitle1: | |
203 PUTC " " | |
204 gaslist_gastitle3: ; Short version | |
205 call TFT_standard_color | |
206 | |
207 btfsc divemode ; In divemode? | |
208 rcall gaslist_strcat_gas_better ; Yes, check if this is a "better gas" | |
209 | |
210 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) | |
211 movf PLUSW1,W | |
212 bnz gaslist_strcat_3 | |
213 call TFT_disabled_color | |
214 gaslist_strcat_3: | |
215 rcall gaslist_strcat_gas_0 | |
216 PUTC " " | |
217 ; Read switch depth | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
218 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
219 movlw .4 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
220 cpfsgt gaslist_gas ; >4? (-> Diluents) |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
221 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
222 |
0 | 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 | |
227 bra gaslist_strcat_4 | |
50 | 228 call TFT_warnings_color ; Turn red if bigger |
0 | 229 gaslist_strcat_4: |
230 TSTOSS opt_units ; 0=Meters, 1=Feets | |
231 bra gaslist_strcat_3_metric | |
232 ;gaslist_strcat_3_imperial: | |
233 movf lo,W | |
234 mullw .100 ; convert meters to mbar | |
235 movff PRODL,lo | |
236 movff PRODH,hi | |
237 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
238 bsf leftbind | |
239 output_16_3 | |
240 STRCAT_TEXT tFeets ; "ft" | |
241 return | |
242 | |
243 gaslist_strcat_3_metric: | |
244 output_99 | |
245 STRCAT_TEXT tMeters ; "m" | |
246 return | |
247 | |
248 ;---------------------------------------------------------------------------- | |
249 ; Store current menu item, and display gas description later. | |
250 ; Input: PRODL : gas number (0..4) | |
251 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry. | |
252 global gaslist_setgas | |
253 gaslist_setgas: | |
254 movff PRODL,gaslist_gas | |
255 movlw .5 | |
256 btfsc ccr_diluent_setup ; in CCR menus? | |
257 addwf gaslist_gas,F ; Yes, offset to gases 5-9 | |
258 return | |
259 | |
260 | |
261 global gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth | |
262 gaslist_cleanup_list: | |
263 bcf ignore_last_edited_gas | |
264 movlw .0 | |
265 btfsc ccr_diluent_setup ; In CCR-Menu? | |
266 addlw .5 ; Yes, adjust offset | |
267 subwf gaslist_gas,F | |
268 gaslist_cleanup_list1: | |
269 clrf lo | |
270 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | |
271 movlw .5 ; Check 5 gases | |
272 movwf hi | |
273 gaslist_cleanup_list2: | |
274 decf hi,w ; 0-4 | |
275 btfsc ccr_diluent_setup ; In CCR-Menu? | |
276 addlw .5 ; Yes, adjust offset | |
277 movff PLUSW1,hi_temp | |
278 movlw .1 | |
279 cpfseq hi_temp ; gas = first ? | |
280 bra gaslist_cleanup_list3 ; No | |
281 incf lo,F ; Yes, count "first gases" | |
282 | |
283 btfss ignore_last_edited_gas ; If we are not in the second-pass mode | |
284 bra gaslist_cleanup_list2b | |
285 | |
286 decf hi,w ; 0-4 | |
287 cpfseq gaslist_gas ; Do not disable last edited gas | |
288 gaslist_cleanup_list2b: | |
289 movff hi,lo_temp ; Keep the last "first gas" found | |
290 gaslist_cleanup_list3: | |
291 decfsz hi,F | |
292 bra gaslist_cleanup_list2 ; Loop | |
293 | |
294 tstfsz lo ; No gas active? | |
295 bra gaslist_cleanup_list4 ; No, at least one is active | |
296 | |
297 btfsc ccr_diluent_setup ; In CCR-Menu? | |
298 bra gaslist_cleanup_list3a ; Yes. | |
299 ; make gas1 first and zero | |
300 movlw .1 ; First | |
301 movwf lo_temp | |
302 movwf INDF1 | |
303 bra gaslist_cleanup_list5 ; Set change depth to zero | |
304 | |
305 gaslist_cleanup_list3a: | |
306 movlw .5 | |
307 addwf FSR1L,F | |
308 movlw .0 | |
309 addwfc FSR1H,F ; Setup to Diluents | |
310 ; make dil1 first and zero | |
311 movlw .1 ; First | |
312 movwf lo_temp | |
313 movwf INDF1 | |
314 bra gaslist_cleanup_list5 ; Set change depth to zero | |
315 | |
316 gaslist_cleanup_list4: | |
317 movlw .1 | |
318 cpfsgt lo ; More then one "first gas"? | |
319 bra gaslist_cleanup_list5 ; No, done. | |
320 ; More then one Gas is "first gas" | |
321 ; Disable last found "first gas" but keep it's change depth | |
322 decf lo_temp,W ; 0-4 | |
323 cpfseq gaslist_gas ; Do not disable last edited gas | |
324 bra gaslist_cleanup_list4b | |
325 ; Do not disable last edited gas | |
326 ; search again but ignore last edited gas | |
327 bsf ignore_last_edited_gas | |
328 bra gaslist_cleanup_list1 ; Loop until only one "first gas" is left | |
329 | |
330 gaslist_cleanup_list4b: | |
331 btfsc ccr_diluent_setup ; In CCR-Menu? | |
332 addlw .5 ; Yes, adjust offset | |
333 clrf PLUSW1 ; Disable gas | |
334 bra gaslist_cleanup_list ; Loop until only one "first gas" is left | |
335 | |
336 gaslist_cleanup_list5: | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
337 ; Read switch depth |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
338 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
339 btfss ccr_diluent_setup ; In CCR-Menu? |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
340 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases |
0 | 341 decf lo_temp,W |
342 btfsc ccr_diluent_setup ; In CCR-Menu? | |
343 addlw .5 ; Yes, adjust offset | |
344 clrf PLUSW1 ; Set First gas to zero m | |
345 return | |
346 | |
347 ;---------------------------------------------------------------------------- | |
348 ; Increment/Decrement O2 ratio | |
349 global gaslist_pO2 | |
350 gaslist_pO2: | |
351 movf gaslist_gas,W | |
352 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | |
353 movff PLUSW1,gaslist_He | |
354 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
355 movff PLUSW1,gaslist_O2 | |
356 | |
357 incf gaslist_O2,F ; O2++ | |
358 movf gaslist_He,W | |
359 addwf gaslist_O2,W | |
360 movwf lo | |
361 movlw .101 | |
362 cpfslt lo ; O2+He<101? | |
363 decf gaslist_O2,F ; O2-- (Unchanged) | |
364 | |
365 movf gaslist_gas,W | |
366 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG] | |
367 return | |
368 | |
369 global gaslist_mO2 | |
370 gaslist_mO2: | |
371 movf gaslist_gas,W | |
372 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
373 movff PLUSW1,gaslist_O2 | |
374 | |
375 decf gaslist_O2,F | |
376 movlw gaslist_min_o2 | |
377 cpfslt gaslist_O2 | |
378 bra gaslist_mO2_1 | |
379 movlw gaslist_min_o2 | |
380 movwf gaslist_O2 | |
381 gaslist_mO2_1: | |
382 movf gaslist_gas,W | |
383 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG] | |
384 return | |
385 | |
386 ;---------------------------------------------------------------------------- | |
387 ; Increment/Decrement He ratio | |
388 global gaslist_pHe | |
389 gaslist_pHe: | |
390 movf gaslist_gas,W | |
391 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
392 movff PLUSW1,gaslist_O2 | |
393 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | |
394 movff PLUSW1,gaslist_He | |
395 | |
396 incf gaslist_He,F ; He++ | |
397 movf gaslist_He,W | |
398 addwf gaslist_O2,W | |
399 movwf lo | |
400 movlw .101 | |
401 cpfslt lo ; O2+He<101? | |
402 decf gaslist_He,F ; Yes, He-- (Unchanged) | |
403 | |
404 movf gaslist_gas,W | |
405 movff gaslist_He,PLUSW1 ; And write back to opt_gas_He_ratio[WREG] | |
406 return | |
407 | |
408 global gaslist_mHe | |
409 gaslist_mHe: | |
410 movf gaslist_gas,W | |
411 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | |
412 movff PLUSW1,gaslist_He | |
413 | |
414 decf gaslist_He,F | |
415 bnn gaslist_mHe_1 | |
416 clrf gaslist_He | |
417 gaslist_mHe_1: | |
418 movf gaslist_gas,W | |
419 movff gaslist_He,PLUSW1 ; And write back to opt_gas_He_ratio[WREG] | |
420 return | |
421 | |
422 ;---------------------------------------------------------------------------- | |
423 ; Increment/Decrement switch depth | |
424 global gaslist_pDepth | |
425 gaslist_pDepth: | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
426 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
427 movlw .4 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
428 cpfsgt gaslist_gas ; >4? (-> Diluents) |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
429 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
430 |
0 | 431 movf gaslist_gas,W |
432 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG] | |
433 | |
434 incf gaslist_O2,F | |
435 movlw gaslist_max_change_depth | |
436 cpfsgt gaslist_O2 | |
437 bra gaslist_pDepth_1 | |
438 movlw gaslist_max_change_depth | |
439 movwf gaslist_O2 | |
440 gaslist_pDepth_1: | |
441 movf gaslist_gas,W | |
442 movff gaslist_O2,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] | |
443 return | |
444 | |
445 global gaslist_mDepth | |
446 gaslist_mDepth: | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
447 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
448 movlw .4 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
449 cpfsgt gaslist_gas ; >4? (-> Diluents) |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
450 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
451 |
0 | 452 movf gaslist_gas,W |
453 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG] | |
454 | |
455 decf gaslist_O2,F | |
456 btfsc STATUS,N | |
457 clrf gaslist_O2 | |
458 | |
459 movf gaslist_gas,W | |
460 movff gaslist_O2,PLUSW1 ; And write back to char_I_deco_gas_change[WREG] | |
461 return | |
462 | |
463 global gaslist_spplus | |
464 gaslist_spplus: | |
465 movf gaslist_gas,W | |
466 lfsr FSR1,char_I_setpoint_cbar | |
467 movff PLUSW1,lo ; Read char_I_setpoint_cbar[WREG] | |
468 movlw gaslist_sp_stepsize | |
469 addwf lo,F | |
470 movlw gaslist_sp_max | |
471 cpfsgt lo | |
472 bra gaslist_spplus2 | |
473 movlw gaslist_sp_min | |
474 movwf lo | |
475 gaslist_spplus2: | |
476 movf gaslist_gas,W | |
477 movff lo,PLUSW1 ; Write back to char_I_setpoint_cbar | |
478 return | |
479 | |
480 global gaslist_spdepthplus | |
481 gaslist_spdepthplus: | |
482 movf gaslist_gas,W | |
483 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m | |
484 lfsr FSR1,char_I_setpoint_change | |
485 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG] | |
486 incf gaslist_O2,F | |
487 movlw gaslist_max_change_depth | |
488 cpfsgt gaslist_O2 | |
489 bra gaslist_spdepthplus_1 | |
490 movlw gaslist_max_change_depth | |
491 movwf gaslist_O2 | |
492 gaslist_spdepthplus_1: | |
493 movf gaslist_gas,W | |
494 movff gaslist_O2,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] | |
495 return | |
496 | |
497 gaslist_spdepthplus3: | |
498 movlw .0 | |
499 movff WREG,char_I_setpoint_change+0 ; Reset to 0m | |
500 return | |
501 | |
502 global gaslist_spdepthminus | |
503 gaslist_spdepthminus: | |
504 movf gaslist_gas,W | |
505 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m | |
506 lfsr FSR1,char_I_setpoint_change | |
507 movff PLUSW1,gaslist_O2 ; Read opt_gas_O2_ratio[WREG] | |
508 decf gaslist_O2,F | |
509 btfsc STATUS,N | |
510 clrf gaslist_O2 | |
511 movf gaslist_gas,W | |
512 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG] | |
513 return | |
514 | |
515 ;---------------------------------------------------------------------------- | |
516 ; Compute MOD from ppO2 Max and current O2 Ratio. | |
517 ; | |
518 ; Input: gaslist_gas = current gas index. | |
519 ; opt_gas_O2_ratio[gaslist_gas] = current O2 ratio | |
520 ; Output: WREG = MOD [m] | |
521 ; | |
522 gaslist_calc_mod: | |
523 movf gaslist_gas,W ; Read current gas O2 ratio | |
524 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | |
525 movf PLUSW1,W | |
526 | |
527 btfsc divemode ; In divemode? | |
528 bra gaslist_calc_mod_divemode ; Yes. | |
529 | |
530 ; Pamb max = ppO2 Max / O2 ratio | |
531 movwf xB+0 | |
532 clrf xB+1 | |
533 | |
534 movff opt_ppO2_max,WREG | |
535 mullw .10 | |
536 movff PRODL,xA+0 | |
537 movff PRODH,xA+1 | |
538 call div16x16 | |
539 | |
540 ; Prof = Pamb - 1bar. | |
541 movf xC+0,W | |
542 addlw -.10 | |
543 return | |
544 | |
545 gaslist_calc_mod_divemode: | |
546 extern TFT_color_code1 | |
547 movwf hi ; Copy O2% | |
548 movlw warn_gas_in_gaslist | |
549 call TFT_color_code1 ; Color-code current row in Gaslist (%O2 in hi), opt_ppO2_max as threshold | |
550 return | |
551 ;---------------------------------------------------------------------------- | |
552 global gaslist_MOD_END | |
553 gaslist_MOD_END: | |
554 rcall gaslist_calc_mod ; Compute MOD into WREG | |
555 movwf lo ; Copy to lo | |
14 | 556 STRCAT_TEXT tMOD ; MOD: |
0 | 557 TSTOSS opt_units ; 0=Meters, 1=Feets |
558 bra gaslist_MOD_metric | |
559 ;gaslist_MOD_imperial: | |
560 movf lo,W | |
561 mullw .100 ; convert meters to mbar | |
562 movff PRODL,lo | |
563 movff PRODH,hi | |
564 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
565 bsf leftbind | |
566 output_16_3 | |
567 STRCAT_TEXT tFeets ; "ft" | |
568 bra gaslist_MOD_common | |
569 gaslist_MOD_metric: | |
570 output_8 | |
571 STRCAT_TEXT tMeters ; m | |
572 gaslist_MOD_common: | |
573 PUTC "/" | |
574 STRCAT_TEXT tEND ; END: | |
575 rcall gaslist_calc_mod ; Output: WREG = MOD [m] | |
576 addlw .10 ; MOD=MOD+10m | |
577 movwf xB+0 | |
578 clrf xB+1 | |
579 movlw d'100' | |
580 movwf xA+0 | |
581 movf gaslist_He,W ; He value in % -> WREG | |
582 subwf xA+0,F ; xA+0 = 100 - He Value in % | |
583 clrf xA+1 | |
584 call mult16x16 ; xA*xB=xC | |
585 movff xC+0,xA+0 | |
586 movff xC+1,xA+1 | |
587 movlw d'100' | |
588 movwf xB+0 | |
589 clrf xB+1 | |
590 call div16x16 ; xA/xB=xC with xA as remainder | |
591 ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100 | |
592 movlw d'10' | |
593 subwf xC+0,F ; Subtract 10m... | |
594 movff xC+0,lo | |
595 ; END 8Bit only | |
596 ; movlw d'0' | |
597 ; subwfb xC+1,F | |
598 ; movff xC+1,hi | |
599 TSTOSS opt_units ; 0=Meters, 1=Feets | |
600 bra gaslist_END_metric | |
601 ;gaslist_END_imperial: | |
602 movf lo,W | |
603 mullw .100 ; convert meters to mbar | |
604 movff PRODL,lo | |
605 movff PRODH,hi | |
606 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
607 bsf leftbind | |
608 output_16_3 | |
609 STRCAT_TEXT tFeets ; "ft" | |
610 return | |
611 gaslist_END_metric: | |
612 output_8 | |
613 STRCAT_TEXT tMeters ; m | |
614 return | |
615 | |
616 ;---------------------------------------------------------------------------- | |
617 global gaslist_reset_mod_title | |
618 gaslist_reset_mod_title: | |
619 STRCAT_TEXT tDepthReset | |
620 | |
621 gaslist_reset_mod_title2: | |
622 rcall gaslist_calc_mod ; Compute MOD into WREG | |
623 movwf lo ; Copy to lo | |
624 | |
625 movf gaslist_gas,W ; Compare to switch depth | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
626 lfsr FSR1,char_I_dil_change ; Setup Diluents mH |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
627 btfss ccr_diluent_setup ; In CCR-Menu? |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
628 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases |
0 | 629 movf PLUSW1,W |
630 cpfslt lo | |
631 bra gaslist_strcat_4 ; And return... | |
50 | 632 call TFT_warnings_color ; Turn red if bigger ! |
0 | 633 bra gaslist_strcat_4 ; And return... |
634 | |
635 ;---------------------------------------------------------------------------- | |
636 global gaslist_reset_mod | |
637 gaslist_reset_mod: | |
638 rcall gaslist_calc_mod ; Compute MOD | |
639 movwf gaslist_depth | |
640 | |
641 movf gaslist_gas,W ; Read current gas O2 ratio | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
642 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
643 lfsr FSR1,char_I_dil_change ; Setup Diluents mH |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
644 btfss ccr_diluent_setup ; In CCR-Menu? |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
645 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
95
diff
changeset
|
646 |
0 | 647 movff gaslist_depth,PLUSW1 ; And save new change depth |
648 return | |
649 ;---------------------------------------------------------------------------- | |
650 END |