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