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