Mercurial > public > hwos_code
annotate src/gaslist.asm @ 628:cd58f7fc86db
3.05 stable work
author | heinrichsweikamp |
---|---|
date | Thu, 19 Sep 2019 12:01:29 +0200 |
parents | c40025d8e750 |
children | 185ba2f91f59 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
628 | 3 ; File gaslist.asm combined next generation V3.03.5 |
0 | 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 | |
604 | 12 #include "hwos.inc" ; mandatory header |
582 | 13 #include "convert.inc" |
623 | 14 #include "math.inc" ; div16x16 for MOD calculation |
582 | 15 #include "strings.inc" |
16 #include "tft.inc" | |
17 #include "tft_outputs.inc" | |
18 #include "shared_definitions.h" | |
604 | 19 #include "wait.inc" |
623 | 20 #include "rx_ops.inc" |
604 | 21 |
0 | 22 |
582 | 23 extern convert_mbar_to_feet |
604 | 24 extern tSetup_GasDepth |
582 | 25 extern tGasDisabled |
26 extern tDilDisabled | |
604 | 27 extern tLiter |
28 extern tbar10 | |
582 | 29 extern tbar |
0 | 30 |
623 | 31 |
32 gaslist CODE | |
33 | |
34 ;----------------------------------------------------------------------------- | |
0 | 35 |
36 ;============================================================================= | |
604 | 37 ; Helper Functions for divemenu_tree.asm |
38 ; | |
39 ; They need to be put in a different file than | |
40 ; where the MENU_DYNAMIC macros uses them. | |
41 | |
42 global do_toggle_gf_label | |
43 do_toggle_gf_label: | |
44 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF | |
45 decfsz WREG,W ; toggle GF only in GF modes - in GF mode? | |
46 bra do_toggle_gf_label_1 ; NO - print in disabled color | |
47 movff opt_enable_aGF,WREG ; =1: aGF can be selected underwater | |
48 decfsz WREG,W ; aGF enabled? | |
49 bra do_toggle_gf_label_1 ; NO - print in disabled color | |
50 bra do_toggle_gf_label_2 ; YES to both - print in standard color | |
51 do_toggle_gf_label_1: | |
52 call TFT_disabled_color | |
53 do_toggle_gf_label_2: | |
54 STRCAT_TEXT tDivemenu_ToggleGF | |
55 return | |
56 | |
623 | 57 ;============================================================================= |
604 | 58 |
59 IFDEF _cave_mode | |
623 | 60 |
604 | 61 global do_turn_dive_label |
62 do_turn_dive_label: | |
623 | 63 btfss cave_mode ; cave mode switched on? |
604 | 64 call TFT_disabled_color ; NO - print in disabled color |
623 | 65 btfsc dive_turned ; dive already turned? |
604 | 66 call TFT_attention_color ; YES - print in attention color |
67 STRCAT_TEXT tDivemenu_TurnDive ; output label | |
68 return | |
623 | 69 |
604 | 70 ENDIF |
71 | |
623 | 72 ;============================================================================= |
73 | |
74 IFDEF _rx_functions | |
604 | 75 |
76 global do_toggle_max_pres_diff_label | |
77 do_toggle_max_pres_diff_label: | |
78 movff opt_TR_mode,WREG ; get TR mode | |
79 xorlw .2 ; compare with 2 (ind.double) | |
80 tstfsz WREG ; equal? | |
81 call TFT_disabled_color ; NO - print in disabled color | |
82 STRCAT_TEXT tTrMaxDeltaP ; output label | |
83 movff char_I_max_pres_diff,lo | |
84 output_99 | |
85 STRCAT_TEXT tbar ; " bar" | |
86 return | |
87 | |
623 | 88 ENDIF |
89 | |
90 ;============================================================================= | |
91 | |
92 IFDEF _ccr_pscr | |
93 | |
604 | 94 global gaslist_copy_dil_to_oc |
95 gaslist_copy_dil_to_oc: | |
96 ; | |
97 ; Memory Map: | |
98 ; ----------------------------------------- | |
99 ; opt_gas_O2_ratio res 5 | |
100 ; opt_dil_O2_ratio res 5 | |
101 ; opt_gas_He_ratio res 5 | |
102 ; opt_dil_He_ratio res 5 | |
103 ; opt_gas_type res 5 | |
104 ; opt_dil_type res 5 | |
105 ; opt_gas_change res 5 | |
106 ; opt_dil_change res 5 | |
107 ; | |
623 | 108 ; char_I_gas_avail_size res 10 |
109 ; char_I_gas_avail_pres res 10 | |
604 | 110 ; |
623 | 111 bcf copying_dil ; default to copying a gas |
604 | 112 movf gaslist_gas,W ; copy current gas or diluent number to WREG |
623 | 113 btfss is_diluent_menu ; setting up diluents? |
604 | 114 bra gaslist_copy_dil_to_oc_1 ; NO - gaslist_gas is already pointing to an OC gas |
115 addlw -.5 ; YES - subtract offset between diluents and gases | |
116 movwf gaslist_gas ; - let gaslist_gas point to the corresponding OC gas | |
623 | 117 bsf copying_dil ; - we are copying a diluent |
118 bcf is_diluent_menu ; - pretend we are setting up OC gases | |
604 | 119 gaslist_copy_dil_to_oc_1: |
120 lfsr FSR0,opt_dil_O2_ratio ; load base address of diluents settings, ASM variables | |
121 lfsr FSR1,opt_gas_O2_ratio ; load base address of gas settings, ASM variables | |
122 movff PLUSW0,PLUSW1 ; copy O2 ratio | |
123 addlw .10 ; add offset from O2 ratios to He ratios | |
124 movff PLUSW0,PLUSW1 ; copy He ratio | |
125 addlw .10 ; add offset from He ratios to types | |
126 movff PLUSW0,PLUSW1 ; copy type | |
127 addlw .10 ; add offset from type to change depth | |
128 movff PLUSW0,PLUSW1 ; copy change depth | |
129 addlw -.30 ; wind back to initial gas number | |
623 | 130 lfsr FSR0,char_I_gas_avail_size+5; load base address of diluents settings, shared variables |
131 lfsr FSR1,char_I_gas_avail_size+0; load base address of gas settings, shared variables | |
604 | 132 movff PLUSW0,PLUSW1 ; copy tank size |
133 addlw .10 ; add offset from tank sizes to pressure budget | |
134 movff PLUSW0,PLUSW1 ; copy pressure budget | |
135 call gaslist_cleanup_list ; make sure that there will be just one first gas | |
623 | 136 btfss copying_dil ; are we copying a diluent? |
604 | 137 return ; NO - done |
623 | 138 bsf is_diluent_menu ; YES - restore to be setting up diluents |
604 | 139 movlw .5 ; - offset between OC gases and diluents |
140 addwf gaslist_gas,F ; - let gaslist_gas point to the diluent again | |
141 WIN_BOX_BLACK .30,.239,.0,.159 ; - create some visual effect to show activity | |
142 WAITMS .200 ; - pause for 200 ms | |
143 return ; - done | |
144 | |
623 | 145 ENDIF |
146 | |
147 ;============================================================================= | |
604 | 148 |
149 ;============================================================================= | |
150 ; Append gas description to current string | |
151 ; | |
582 | 152 ; Input: PRODL : gas number (0..4) |
604 | 153 ; FSR2 : Current string position |
154 ; Output: Text appended into buffer pointed by FSR2 | |
582 | 155 |
156 global gaslist_strcat_gas | |
604 | 157 global gaslist_strcat_gas_WREG |
623 | 158 gaslist_strcat_gas: ; entry point with gas/dil in PRODL (0-4) and flag 'is_diluent_menu' set accordingly |
604 | 159 movff PRODL,gaslist_gas ; get current menu item (0-4) |
160 movlw .5 ; offset between gases and diluents | |
623 | 161 btfsc is_diluent_menu ; setting up diluents? |
604 | 162 addwf gaslist_gas,F ; YES - add the offset |
163 movf gaslist_gas,W ; copy to WREG | |
164 gaslist_strcat_gas_WREG: ; entry point with gas/dil in WREG (0-9) | |
165 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio | |
166 movff PLUSW1,lo ; read O2 ratio | |
167 lfsr FSR1,opt_gas_He_ratio ; load base address of opt_gas_He_ratio | |
168 movff PLUSW1,hi ; read He ratio | |
623 | 169 goto gaslist_show_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and RETURN |
170 | |
0 | 171 |
172 ;============================================================================= | |
623 | 173 ; Append current mix to current string (for dive mode) |
604 | 174 ; |
175 ; Input: FSR2 : Current string position | |
176 ; Output: Text appended into buffer pointed by FSR2 | |
177 | |
582 | 178 global gaslist_strcat_gas6 |
604 | 179 gaslist_strcat_gas6: ; show current O2/He mix |
623 | 180 STRCAT_TEXT tGas ; print "Gas" |
181 STRCAT ": " ; print ":" | |
604 | 182 movff gas6_O2_ratio,hi ; TFT_color_code_gaslist needs O2 ratio in hi |
183 call TFT_color_code_gaslist ; color-code according to O2 ratio and depth | |
623 | 184 movff gas6_O2_ratio,lo ; gaslist_show_mix needs O2 ratio in lo |
185 IFDEF _helium | |
186 movff gas6_He_ratio,hi ; ... and He ratio in hi | |
187 ELSE | |
188 clrf hi ; ... and He ration will be zero | |
189 ENDIF | |
190 goto gaslist_show_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and return | |
191 | |
192 | |
604 | 193 ;============================================================================= |
194 ; Helper functions for menu_tree | |
0 | 195 |
604 | 196 global gaslist_GasDepth |
197 gaslist_GasDepth: | |
198 movf gaslist_gas,W ; load gas/dil index into WREG (0-9) | |
199 lfsr FSR1,opt_gas_change ; load base address of change depths | |
200 tstfsz PLUSW1 ; change depth = 0 ? | |
201 bra gaslist_GasDepth_1 ; NO | |
202 lfsr FSR1,opt_gas_type ; YES - load base address of opt_gas_type | |
203 tstfsz PLUSW1 ; - type = disabled ? | |
204 call TFT_attention_color ; NO - print in attention color (yellow) | |
205 gaslist_GasDepth_1: | |
206 STRCAT_TEXT tSetup_GasDepth | |
207 return | |
582 | 208 |
623 | 209 |
582 | 210 global gaslist_show_type |
0 | 211 gaslist_show_type: |
582 | 212 movf gaslist_gas,W |
604 | 213 lfsr FSR1,opt_gas_type ; load base address of opt_gas_type |
214 movff PLUSW1,lo ; read gas type | |
582 | 215 STRCAT_TEXT tType |
604 | 216 lfsr FSR1,tGasDisabled ; load base address of gas type labels |
623 | 217 btfsc is_diluent_menu ; setting up diluents? |
604 | 218 lfsr FSR1,tDilDisabled ; YES - load base address of diluent type labels |
582 | 219 movff lo,WREG ; 0-3 |
220 rlncf WREG ; x2 | |
604 | 221 addwf FSR1L,F ; adjust address pointer to required text |
582 | 222 movlw .0 |
223 addwfc FSR1H,F | |
604 | 224 call strcat_text ; copy label text |
582 | 225 return |
0 | 226 |
604 | 227 |
582 | 228 global gaslist_toggle_type |
0 | 229 gaslist_toggle_type: |
582 | 230 movf gaslist_gas,W |
604 | 231 lfsr FSR1,opt_gas_type ; load base address of opt_gas_type |
232 movff PLUSW1,lo ; read gas type | |
233 incf lo,F ; increment type | |
623 | 234 btfsc is_diluent_menu ; setting up diluents? |
604 | 235 bra gaslist_toggle_type2 ; YES - diluents |
236 btfsc lo,2 ; NO - gases, type index > 3 ? | |
237 clrf lo ; YES - clear to zero | |
238 movff lo,PLUSW1 ; - copy back result | |
582 | 239 return |
0 | 240 gaslist_toggle_type2: |
582 | 241 movlw .3 |
604 | 242 cpfslt lo ; index > 2 ? |
243 clrf lo ; YES - clear to zero | |
244 movf gaslist_gas,W ; restore gaslist_gas in WREG | |
245 movff lo,PLUSW1 ; copy back result | |
582 | 246 return |
0 | 247 |
623 | 248 ;============================================================================= |
249 | |
250 IFDEF _ccr_pscr | |
582 | 251 |
252 global gaslist_strcat_setpoint | |
253 global gaslist_strcat_setpoint_0 | |
604 | 254 gaslist_strcat_setpoint: ; entry point with setpoint index in PRODL |
255 movff PRODL,gaslist_gas ; get current menu item (0-4) | |
256 gaslist_strcat_setpoint_0: ; entry point with setpoint index in gaslist_gas | |
582 | 257 bsf leftbind |
623 | 258 btfsc short_gas_descriptions ; shall use short versions of gaslist_strcat_setpoint? |
604 | 259 bra gaslist_strcat_setpoint2 ; YES - use short version |
260 STRCAT_TEXT tSP ; "SP" | |
261 incf gaslist_gas,W ; (0-4) -> (1-5) into WREG | |
582 | 262 movwf lo |
604 | 263 output_8 ; print SP number |
582 | 264 bcf leftbind |
265 PUTC ":" | |
604 | 266 gaslist_strcat_setpoint2: ; short version |
582 | 267 btfsc divemode |
623 | 268 bra gaslist_strcat_setpoint4 ; no "*" in dive mode |
604 | 269 movf gaslist_gas,W ; (0-4) into WREG |
270 bnz gaslist_strcat_setpoint3 ; SP index = 0 ? | |
271 PUTC "*" ; YES - print * | |
272 bra gaslist_strcat_setpoint4 ; - continue with cbar value | |
273 gaslist_strcat_setpoint3: ; NO | |
274 PUTC " " ; - print a space | |
0 | 275 gaslist_strcat_setpoint4: |
604 | 276 movf gaslist_gas,W ; (0-4) into WREG |
623 | 277 lfsr FSR1,opt_setpoint_cbar ; load base address of setpoint cbar values |
604 | 278 movf PLUSW1,W ; read cbar value |
582 | 279 movwf lo |
280 clrf hi | |
281 bsf leftbind | |
604 | 282 output_16dp d'3' ; print as X.XX |
623 | 283 btfsc divemode ; in dive mode? |
284 bra gaslist_strcat_setpoint5 ; YES - skip text in dive mode | |
604 | 285 STRCAT_TEXT tbar ; NO - print "bar" |
0 | 286 gaslist_strcat_setpoint5: |
604 | 287 PUTC " " ; print a space |
288 movf gaslist_gas,W ; (0-4) into WREG | |
623 | 289 lfsr FSR1,opt_setpoint_change ; load base address of switch depths |
604 | 290 movff PLUSW1,lo ; read switch depth into lo |
291 bra gaslist_strcat_depth ; print depth in meters or ft | |
582 | 292 |
623 | 293 ENDIF ; _ccr_pscr |
0 | 294 |
295 ;---------------------------------------------------------------------------- | |
604 | 296 ; Append gas description to current string |
297 ; | |
298 ; Prints gas number, * if first, = if deco gas, gas composition and change depth, | |
299 ; including fancy color-coding | |
0 | 300 ; |
604 | 301 ; Input: PRODL gas number (0..4) |
302 ; FSR2 current string position | |
303 ; Output: text appended to buffer pointed by FSR2 | |
304 ; | |
305 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry | |
0 | 306 |
604 | 307 global gaslist_strcat_gas_cd |
582 | 308 global gaslist_gastitle |
623 | 309 gaslist_strcat_gas_cd: ; entry point with gas in PRODL (0-4) and flag 'is_diluent_menu' set accordingly |
604 | 310 movff PRODL,gaslist_gas ; get current menu item (0-4) |
311 movlw .5 ; offset between gases and diluents | |
623 | 312 btfsc is_diluent_menu ; setting up diluents? |
604 | 313 addwf gaslist_gas,F ; YES - add the offset |
314 gaslist_gastitle: ; entry point with gas/dil in gaslist_gas (0-4 for gases, 5-9 for diluents) | |
315 bcf win_invert ; clear flag for inverted output by default | |
623 | 316 btfsc short_gas_descriptions ; shall use short versions of gaslist_strcat_gas_cd? |
604 | 317 bra gaslist_gastitle1 ; YES - use short version |
318 incf gaslist_gas,W ; (0-9) -> (1-10) into WREG | |
582 | 319 movwf lo |
604 | 320 movlw .6 ; diluents start with 6 |
321 cpfslt lo ; gas number < 6 ? | |
322 bra gaslist_gastitle_dil ; NO - it's a diluent | |
323 STRCAT_TEXT tGas ; YES - it's a gas | |
324 bra gaslist_gastitle0 | |
325 gaslist_gastitle_dil: | |
326 STRCAT_TEXT tDil | |
327 movlw .5 ; offset between gases and diluents | |
328 subwf lo,F ; subtract offset from diluent number (6-10) -> (1-5) | |
582 | 329 gaslist_gastitle0: |
330 bsf leftbind | |
604 | 331 output_8 ; print gas/dil number (1-5) |
582 | 332 bcf leftbind |
333 PUTC ":" | |
604 | 334 gaslist_gastitle1: ; short version of gaslist_strcat_gas_cd |
623 | 335 btfsc divemode ; in dive mode? |
604 | 336 bra gaslist_gastitle3 ; YES - no "*" and "=" in front of gas composition, no highlighting for transmitters paired |
337 | |
338 IFDEF _rx_functions | |
623 | 339 btfss tr_functions_activated ; NO - TR functions activated? |
604 | 340 bra gaslist_gastitle2 ; NO - continue with gas type |
341 lfsr FSR1,opt_transmitter_id_1 ; YES - load base address of transmitter ID table | |
342 movf gaslist_gas,W ; - (0-4 for OC/Bailout, 5-9 for Diluents) | |
343 rlncf WREG,W ; - index x2 because IDs are 2 byte | |
344 tstfsz PLUSW1 ; - transmitter ID low byte <> 0 ? | |
345 bsf win_invert ; YES - flag transmitter paired by inverting output | |
346 incf WREG,W ; - increment index | |
347 tstfsz PLUSW1 ; - transmitter ID high byte <> 0 ? | |
348 bsf win_invert ; YES - flag transmitter paired by inverting output | |
349 ENDIF | |
350 | |
582 | 351 gaslist_gastitle2: |
604 | 352 rcall gaslist_strcat_gas_type ; print "*" for first gas/dil, "=" for a deco gas or " " else |
582 | 353 gaslist_gastitle3: |
354 call TFT_standard_color | |
623 | 355 btfsc divemode ; in dive mode? |
604 | 356 rcall gaslist_strcat_gas_better ; YES - check if this is a "better gas" |
357 lfsr FSR1,opt_gas_type ; load base address of gas types | |
358 movf gaslist_gas,W ; load index into WREG (0-4 for gases, 5-9 for diluents) | |
359 movf PLUSW1,W ; read gas/dil type into WREG | |
360 bnz gaslist_gastitle4 ; type = disabled? NO - keep color | |
361 call TFT_disabled_color ; YES - switch color to disabled | |
362 bra gaslist_gastitle5 ; - skip ppO2 check for disabled gases | |
363 gaslist_gastitle4: | |
623 | 364 btfss divemode ; in dive mode? |
365 bra gaslist_gastitle5 ; NO - no ppO2 check if not in dive mode | |
604 | 366 lfsr FSR1,opt_gas_O2_ratio ; YES - load base address of opt_gas_O2_ratio |
367 movf gaslist_gas,W ; - load index into WREG (0-4 for gases, 5-9 for diluents) | |
368 movff PLUSW1,hi ; - read O2 ratio into hi | |
369 call TFT_color_code_gaslist ; - set color according to ppO2 limits | |
370 gaslist_gastitle5: | |
371 movf gaslist_gas,W ; copy gas/dil index to WREG (0-9) | |
372 rcall gaslist_strcat_gas_WREG ; print gas composition | |
623 | 373 btfss divemode ; in dive mode? |
604 | 374 bra gaslist_gastitle6 ; NO - continue printing a space |
375 rcall gaslist_strcat_gas_type ; YES - print "*" for first gas/dil, "=" for a deco gas, or a space else | |
376 bra gaslist_gastitle7 ; - continue with change depth | |
377 gaslist_gastitle6: | |
378 PUTC " " ; print a space | |
379 gaslist_gastitle7: | |
380 lfsr FSR1,opt_gas_change ; load base address of change depths | |
381 movf gaslist_gas,W ; load gas/dil index into WREG (0-9) | |
382 movff PLUSW1,lo ; read change depth into lo | |
383 gaslist_strcat_depth: ; entry point for general printing of depths with value in meters in lo | |
384 TSTOSS opt_units ; check depth units | |
385 bra gaslist_strcat_depth_metric ; 0 - use Meters | |
386 gaslist_strcat_depth_imperial: ; 1 - use Feet | |
582 | 387 movf lo,W |
388 mullw .100 ; convert meters to mbar | |
389 movff PRODL,lo | |
390 movff PRODH,hi | |
391 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
604 | 392 output_16_3 ; limit to 999 and display only 0-999 |
623 | 393 STRCAT_TEXT tFeets ; append "ft" REMARK: still one char to long for space available in dive mode menu! |
604 | 394 return |
395 gaslist_strcat_depth_metric: | |
623 | 396 ; PUTC " " ; print a space |
397 ; output_99 | |
398 output_8 | |
604 | 399 STRCAT_TEXT tMeters ; "m" |
582 | 400 return |
604 | 401 |
623 | 402 |
403 ; check for better gas | |
404 ; | |
604 | 405 gaslist_strcat_gas_better: ; color-code output if this is the best gas/diluent |
406 btfss better_gas_hint ; shall better gas hints be given? | |
407 return ; NO - return | |
408 movf best_gas_number,W ; get best gas number into WREG | |
623 | 409 IFDEF _ccr_pscr |
410 btfsc is_diluent_menu ; setting up diluents? | |
604 | 411 movf best_dil_number,W ; YES - overwrite with best diluent number |
623 | 412 ENDIF |
604 | 413 tstfsz WREG ; is a best gas/dil available? |
414 bra gaslist_strcat_gas_better1 ; YES - proceed | |
415 return ; NO - return | |
416 gaslist_strcat_gas_better1: | |
417 decf WREG,W ; (1-5) -> (0-4) | |
623 | 418 btfsc is_diluent_menu ; setting up diluents? |
604 | 419 addlw .5 ; YES - add offset between gases and diluents (0-4) -> (5-9) |
420 cpfseq gaslist_gas ; compare with given gas/dil (0-4 for OC bailout gases, 5-9 for diluents) | |
421 return ; not equal - return | |
422 bsf win_invert ; equal - invert | |
423 movlw color_green ; - select green color (gas is something "good") | |
424 goto TFT_set_color ; - activate color and return | |
425 | |
623 | 426 |
604 | 427 gaslist_strcat_gas_type: |
428 lfsr FSR1,opt_gas_type ; load base address of gas types | |
429 movf gaslist_gas,W ; load index to WREG (0-4 for gases, 5-9 for diluents) | |
628 | 430 decf PLUSW1,W ; get and decrement gas type (-1 for disabled, 0 for first, 1 for work/normal, 2 for deco) |
431 bnz gaslist_strcat_gas_type_1 ; type = first? NO - continue with checking for work and deco gas | |
604 | 432 PUTC "*" ; YES - print "*" for first |
433 return ; - done | |
434 gaslist_strcat_gas_type_1: | |
628 | 435 decf WREG,W ; decrement gas type (-2 for disabled, -1 for first, 0 for work/normal, 1 for deco) |
436 bnz gaslist_strcat_gas_type_2 ; type = work? NO - continue with checking for deco gas | |
437 PUTC "\xb8" ; YES - print down-arrow for a work gas | |
438 return ; - done | |
439 gaslist_strcat_gas_type_2: | |
440 decf WREG,W ; decrement gas type (-3 for disabled, -2 for first, -1 for work/normal, 0 for deco) | |
441 bnz gaslist_strcat_gas_type_3 ; type = deco? NO - neither first nor deco | |
604 | 442 PUTC "=" ; YES - print "=" for a deco gas |
443 return ; - done | |
628 | 444 gaslist_strcat_gas_type_3: |
604 | 445 PUTC " " ; neither first nor deco, print a space |
582 | 446 return |
0 | 447 |
623 | 448 |
0 | 449 ;---------------------------------------------------------------------------- |
604 | 450 ; Housekeeping for the gas/dil settings, e.g. making sure there is one FIRST only |
451 ; | |
452 ; Input: gaslist_gas last edited gas/dil (0-9) | |
453 | |
454 global gaslist_cleanup_list | |
455 gaslist_cleanup_list: | |
456 lfsr FSR1,opt_gas_type ; load base address of opt_gas_type | |
623 | 457 IFDEF _ccr_pscr |
604 | 458 movlw .5 ; offset between gases and diluents |
623 | 459 btfsc is_diluent_menu ; setting up diluents? |
604 | 460 subwf gaslist_gas,F ; YES - subtract offset from gaslist_gas: (5-9) -> (0-4) |
623 | 461 ENDIF |
604 | 462 gaslist_cleanup_list0: |
463 bcf ignore_last_edited_gas | |
464 gaslist_cleanup_list1: | |
465 clrf lo ; counter for number of "firsts" found | |
466 movlw .5 ; initialize hi as loop counter for checking 5 gases/diluents | |
467 movwf hi | |
468 gaslist_cleanup_list2: ; loop body | |
469 decf hi,W ; WREG = current gas/dil (0-4) | |
623 | 470 IFDEF _ccr_pscr |
471 btfsc is_diluent_menu ; setting up diluents? | |
604 | 472 addlw .5 ; YES - add offset from gases to diluents -> (5-9) |
623 | 473 ENDIF |
604 | 474 movff PLUSW1,WREG ; read type into WREG |
475 decfsz WREG ; is type = first (ex type code 1)? | |
476 bra gaslist_cleanup_list3 ; NO - done with this gas/dil | |
477 incf lo,F ; YES - increment number of "firsts" found | |
478 btfss ignore_last_edited_gas ; - shall we ignore the last edited gas/dil? | |
479 bra gaslist_cleanup_list2b ; NO - continue remembering the "last first" gas/dil (do a shortcut) | |
480 decf hi,W ; YES - get the current gas/dil as (0-4) | |
481 cpfseq gaslist_gas ; - is this the last edited gas/dil? | |
482 gaslist_cleanup_list2b: | |
483 movff hi,up ; (NO) - remember the last "first gas" found | |
484 gaslist_cleanup_list3: | |
623 | 485 decfsz hi,F ; decrement loop counter, did loop counter became 0? |
486 bra gaslist_cleanup_list2 ; NO - loop | |
487 tstfsz lo ; YES - any first gas/dil at all? | |
488 bra gaslist_cleanup_list4 ; YES - at least one first gas/dil existing | |
489 IFDEF _ccr_pscr | |
490 btfsc is_diluent_menu ; NO - setting up diluents? | |
491 lfsr FSR1,opt_dil_type ; YES - load base address of opt_gas_type | |
492 ENDIF | |
493 movlw .1 ; - load coding for first gas | |
494 movwf INDF1 ; - make gas/dil 1 the first gas | |
495 bsf option_repaired ; - flag that an option was repaired | |
496 return ; - done | |
604 | 497 gaslist_cleanup_list4: |
623 | 498 movlw .1 ; total number of Firsts that should exist is 1 |
604 | 499 cpfsgt lo ; more then one "first gas" found? |
500 return ; NO - done | |
501 decf up,W ; YES - WREG = last found "first gas" - 1 (0-4) | |
502 cpfseq gaslist_gas ; - is this the last edited gas/dil? | |
503 bra gaslist_cleanup_list4b ; NO - disable it | |
504 bsf ignore_last_edited_gas ; YES - do not disable last edited gas, search again but ignore the last edited gas | |
505 bra gaslist_cleanup_list1 ; - loop until only one "first" is left over | |
506 gaslist_cleanup_list4b: | |
623 | 507 IFDEF _ccr_pscr |
508 btfsc is_diluent_menu ; setting up diluents? | |
604 | 509 addlw .5 ; YES - adjust offset |
623 | 510 ENDIF |
604 | 511 clrf PLUSW1 ; disable gas |
623 | 512 bsf option_repaired ; flag that an option was repaired |
604 | 513 bra gaslist_cleanup_list0 ; redo from start until only one "first" is left over |
514 return | |
515 | |
623 | 516 |
604 | 517 ;---------------------------------------------------------------------------- |
518 ; Tank Settings | |
519 ; | |
623 | 520 ; Input: char_I_gas_avail_size size of the tank in liters |
521 ; char_I_gas_avail_pres available pressure in multiples of 10 bar | |
582 | 522 |
604 | 523 global gaslist_tank_size_pres |
524 gaslist_tank_size_pres: ; dynamic title: xx l, xx0 bar | |
623 | 525 lfsr FSR1,char_I_gas_avail_size ; load base address of char_I_gas_avail_size |
604 | 526 movf gaslist_gas,W ; load index (0-9) |
623 | 527 movff PLUSW1,lo ; read char_I_gas_avail_size[WREG] into lo |
528 lfsr FSR1,char_I_gas_avail_pres ; load base address of char_I_gas_avail_pres | |
529 movff PLUSW1,hi ; read char_I_gas_avail_pres[WREG] into hi | |
604 | 530 STRCAT " " ; print 5 leading spaces for alignment |
531 output_8 ; print tank size | |
532 STRCAT_TEXT tLiter ; print unit (" l") | |
533 movff hi,lo ; copy fill pressure into lo | |
534 output_8 ; print fill pressure (it is stored in multiples of 10 bar) | |
535 STRCAT_TEXT tbar10 ; print unit ("0 bar") | |
536 return | |
537 | |
623 | 538 |
604 | 539 global gaslist_tank_size |
623 | 540 gaslist_tank_size: ; adjust char_I_gas_avail_size between min_tank_size and max_tank_size |
541 lfsr FSR1,char_I_gas_avail_size ; load base address of char_I_gas_avail_size | |
604 | 542 movf gaslist_gas,W ; load index (0-9) |
623 | 543 movff PLUSW1,lo ; read char_I_gas_avail_size[WREG] into lo |
604 | 544 incf lo,F ; increment tank size by 1 liter |
545 movlw max_tank_size ; load max. allowed value into WREG | |
546 cpfsgt lo ; tank size <= max value? | |
547 bra gaslist_tank_size_1 ; YES - new value can be used | |
548 movlw min_tank_size ; NO - wrap-around to min value | |
549 movwf lo ; - and write to lo | |
550 gaslist_tank_size_1: | |
551 movf gaslist_gas,W ; re-load index | |
623 | 552 movff lo,PLUSW1 ; write back tank size to char_I_gas_avail_size[WREG] |
604 | 553 return |
554 | |
623 | 555 |
604 | 556 global gaslist_tank_pres |
623 | 557 gaslist_tank_pres: ; adjust char_I_gas_avail_pres between 5(0) and 29(0) bar |
558 lfsr FSR1,char_I_gas_avail_pres ; load base address of char_I_gas_avail_pres | |
604 | 559 movf gaslist_gas,W ; load index (0-9) |
623 | 560 movff PLUSW1,lo ; read char_I_gas_avail_pres[WREG] into lo |
604 | 561 incf lo,F ; increment fill press by by 1(0) bar |
562 movlw max_fill_press ; load max. allowed value into WREG | |
563 cpfsgt lo ; press <= max value? | |
564 bra gaslist_tank_pres_1 ; YES - new value can be used | |
565 movlw min_fill_press ; NO - wrap-around to min value | |
566 movwf lo ; - and write to lo | |
567 gaslist_tank_pres_1: | |
568 movf gaslist_gas,W ; re-load index | |
623 | 569 movff lo,PLUSW1 ; write back tank size to char_I_gas_avail_pres[WREG] |
604 | 570 return |
571 | |
623 | 572 |
573 ;============================================================================= | |
604 | 574 |
575 IFDEF _rx_functions | |
576 | |
623 | 577 ; Transmitter functions - ID |
578 ; | |
604 | 579 global gaslist_tank_id_pres |
580 gaslist_tank_id_pres: ; dynamic title: shows ID and pressure from transmitter with ID opt_transmitter_id[gaslist_gas] | |
581 ; When changing layout, adapt output position TFT_menu_tank_pres! | |
582 STRCAT " ID: " ; print header | |
583 ; get ID ; | |
584 lfsr FSR1,opt_transmitter_id_1 ; load base address of opt_transmitter_id | |
585 movf gaslist_gas,W ; load index (0-9) | |
586 rlncf WREG,W ; multiply by 2 because IDs are 2 byte in size | |
587 movff PLUSW1,lo ; copy opt_transmitter_id+0[gaslist_gas] to lo | |
588 incf WREG,W ; increment index | |
589 movff PLUSW1,hi ; copy opt_transmitter_id+1[gaslist_gas] to hi | |
590 ; check if a transmitter is paired to this tank | |
591 tstfsz hi ; high byte of ID <> 0 ? | |
592 bra gaslist_tank_id_pres_1 ; YES - a transmitter is paired to the tank | |
593 tstfsz lo ; low byte of ID <> 0 ? | |
594 bra gaslist_tank_id_pres_1 ; YES - a transmitter is paired to the tank | |
623 | 595 STRCAT "----" ; NO - no transmitter paired |
596 bcf imprint_xmitter_pres ; - stop imprinting of transmitter pressure data | |
597 return ; - done | |
598 gaslist_tank_id_pres_1: ; YES - show ID | |
599 movf hi,W ; - copy high byte of ID to WREG | |
600 output_hex ; - print it | |
601 movf lo,W ; - copy low byte of ID to WREG | |
602 output_hex ; - print it | |
603 bsf imprint_xmitter_pres ; - start imprinting of transmitter pressure data | |
604 return ; - done | |
0 | 605 |
606 | |
623 | 607 ; Transmitter functions - Pairing |
608 ; | |
604 | 609 global gaslist_tank_pairing |
610 gaslist_tank_pairing: | |
611 incf pairing_slot,F ; goto next RX data slot | |
612 btfsc pairing_slot,3 ; slot = 8? | |
613 bra gaslist_tank_pairing_none ; YES - offer unpairing | |
614 movf pairing_slot,W ; NO - copy slot to WREG | |
615 call get_transmitter_id_by_slot ; WREG = slot (0-7) -> hi:lo = transmitter ID | |
616 tstfsz hi ; transmitter found (probe on high byte)? | |
617 bra gaslist_tank_pairing_common ; YES - select this transmitter | |
618 tstfsz hi ; transmitter found (probe on low byte)? | |
619 bra gaslist_tank_pairing_common ; YES - select this transmitter | |
620 bra gaslist_tank_pairing ; NO - try next slot | |
621 gaslist_tank_pairing_common: | |
622 lfsr FSR1,opt_transmitter_id_1 ; load base address of opt_transmitter_id | |
623 movf gaslist_gas,W ; load index into WREG (0-9) | |
624 rlncf WREG,W ; multiply by 2 because IDs are 2 byte in size | |
625 movff lo,PLUSW1 ; copy lo to opt_transmitter_id+0[gaslist_gas] | |
626 incf WREG,W ; increment index | |
627 movff hi,PLUSW1 ; copy hi to opt_transmitter_id+1[gaslist_gas] | |
628 return ; done | |
629 gaslist_tank_pairing_none: | |
630 setf pairing_slot ; prime slot number with 255 aka -1 | |
631 clrf hi ; adjust "no transmitter" ID | |
632 clrf lo ; adjust "no transmitter" ID | |
633 bra gaslist_tank_pairing_common ; continue with common part | |
634 | |
635 ENDIF | |
0 | 636 |
623 | 637 ;============================================================================= |
638 | |
0 | 639 ;---------------------------------------------------------------------------- |
623 | 640 ; Helper Functions for Menu Operations |
641 | |
582 | 642 |
623 | 643 ; Increment O2 ratio |
644 ; | |
582 | 645 global gaslist_pO2 |
0 | 646 gaslist_pO2: |
604 | 647 movf gaslist_gas,W ; load index (0-9) |
648 lfsr FSR1,opt_gas_He_ratio ; load base address of opt_gas_He_ratio | |
649 movff PLUSW1,hi ; read He ratio into hi | |
650 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio | |
651 movff PLUSW1,lo ; read O2 ratio into lo | |
0 | 652 |
582 | 653 incf lo,F ; O2++ |
654 movf hi,W ; get He ratio into WREG | |
623 | 655 addwf lo,W ; add O2 ratio to WREG |
582 | 656 movwf up ; move sum He + O2 to up |
657 movlw .101 ; | |
658 cpfslt up ; O2 + He < 101? | |
659 decf lo,F ; O2-- (revoke ++) | |
604 | 660 movf gaslist_gas,W ; re-load index |
582 | 661 movff lo,PLUSW1 ; write back O2 ratio to opt_gas_O2_ratio[WREG] |
662 return | |
663 | |
623 | 664 |
665 ; Decrement O2 ratio | |
666 ; | |
582 | 667 global gaslist_mO2 |
0 | 668 gaslist_mO2: |
604 | 669 movf gaslist_gas,W ; load index (0-9) |
670 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio | |
671 movff PLUSW1,lo ; read O2 ratio into lo | |
0 | 672 |
582 | 673 decf lo,F ; O2-- |
674 movlw gaslist_min_o2 ; get minimum allowed O2 ratio | |
675 cpfslt lo ; current O2 ratio below allowed minimum? | |
676 bra gaslist_mO2_1 ; NO | |
604 | 677 movwf lo ; YES - copy minimum O2 ratio to lo |
0 | 678 gaslist_mO2_1: |
604 | 679 movf gaslist_gas,W ; re-load index |
582 | 680 movff lo,PLUSW1 ; write back O2 ratio to opt_gas_O2_ratio[WREG] |
681 return | |
0 | 682 |
623 | 683 ;============================================================================= |
582 | 684 |
623 | 685 IFDEF _helium |
686 | |
687 ; Increment He ratio | |
688 ; | |
582 | 689 global gaslist_pHe |
0 | 690 gaslist_pHe: |
604 | 691 movf gaslist_gas,W ; load index (0-9) |
692 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio | |
693 movff PLUSW1,lo ; read O2 ratio into lo | |
694 lfsr FSR1,opt_gas_He_ratio ; load base address of opt_gas_He_ratio | |
695 movff PLUSW1,hi ; read He ratio into hi | |
0 | 696 |
582 | 697 incf hi,F ; He++ |
698 movf hi,W ; get He ratio into WREG | |
699 addwf lo,W ; add O2 ratio to WREG | |
700 movwf up ; move sum He + O2 to up | |
701 movlw .101 ; | |
702 cpfslt up ; O2 + He < 101? | |
703 decf hi,F ; He-- (revoke ++) | |
604 | 704 movf gaslist_gas,W ; re-load index |
582 | 705 movff hi,PLUSW1 ; write back He ratio to opt_gas_He_ratio[WREG] |
706 return | |
0 | 707 |
623 | 708 ; Decrement He ratio |
709 ; | |
582 | 710 global gaslist_mHe |
0 | 711 gaslist_mHe: |
604 | 712 movf gaslist_gas,W ; load index (0-9) |
713 lfsr FSR1,opt_gas_He_ratio ; load base address of opt_gas_He_ratio | |
714 movff PLUSW1,hi ; read He ratio into hi | |
0 | 715 |
582 | 716 decf hi,F ; He-- |
717 bnn gaslist_mHe_1 ; He ratio negative? | |
604 | 718 clrf hi ; YES - set He ratio to 0 |
0 | 719 gaslist_mHe_1: |
604 | 720 movf gaslist_gas,W ; re-load index |
582 | 721 movff hi,PLUSW1 ; write back He ratio to opt_gas_He_ratio[WREG] |
722 return | |
0 | 723 |
623 | 724 ENDIF ; _helium |
0 | 725 |
623 | 726 ;============================================================================= |
727 | |
728 ; Increment switch depth | |
729 ; | |
582 | 730 global gaslist_pDepth |
731 gaslist_pDepth: | |
604 | 732 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change |
733 movf gaslist_gas,W ; load index (0-4) | |
734 movff PLUSW1,lo ; read switch depth into lo | |
735 incf lo,F ; increment switch depth | |
736 movlw gaslist_max_change_depth ; get max change depth | |
737 cpfsgt lo ; above max change depth? | |
738 bra gaslist_pDepth_1 ; NO | |
739 movwf lo ; YES - revert to max change depth | |
0 | 740 gaslist_pDepth_1: |
604 | 741 movf gaslist_gas,W ; re-load index |
742 movff lo,PLUSW1 ; write back switch depth | |
582 | 743 return |
744 | |
623 | 745 |
746 ; Decrement switch depth | |
747 ; | |
582 | 748 global gaslist_mDepth |
0 | 749 gaslist_mDepth: |
604 | 750 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change |
751 movf gaslist_gas,W ; load index (0-4) | |
752 movff PLUSW1,lo ; read switch depth into lo | |
753 decf lo,F ; decrement switch depth | |
754 btfsc STATUS,N ; did depth became negative? | |
755 clrf lo ; YES - reset to zero | |
756 movff lo,PLUSW1 ; write back switch depth | |
582 | 757 return |
0 | 758 |
623 | 759 ;============================================================================= |
760 | |
761 IFDEF _ccr_pscr | |
762 | |
763 ; Increment setpoint | |
764 ; | |
582 | 765 global gaslist_spplus |
0 | 766 gaslist_spplus: |
582 | 767 movf gaslist_gas,W |
623 | 768 lfsr FSR1,opt_setpoint_cbar |
604 | 769 movff PLUSW1,lo ; read setpoint |
582 | 770 movlw gaslist_sp_stepsize |
771 addwf lo,F | |
772 movlw gaslist_sp_max | |
773 cpfsgt lo | |
774 bra gaslist_spplus2 | |
775 movlw gaslist_sp_min | |
776 movwf lo | |
0 | 777 gaslist_spplus2: |
582 | 778 movf gaslist_gas,W |
604 | 779 movff lo,PLUSW1 ; write back setpoint |
582 | 780 return |
781 | |
623 | 782 |
783 ; Increment setpoint switch depth | |
784 ; | |
582 | 785 global gaslist_spdepthplus |
0 | 786 gaslist_spdepthplus: |
604 | 787 movf gaslist_gas,W ; get setpoint number (0-4) |
788 bz gaslist_spdepthplus2 ; setpoint number = 0? YES - force depth to always be 0m | |
623 | 789 lfsr FSR1,opt_setpoint_change ; load base address of opt_setpoint_change |
604 | 790 movff PLUSW1,lo ; read setpoint depth into lo |
791 incf lo,F ; increment depth | |
792 movlw gaslist_max_change_depth ; get max. depth | |
793 cpfsgt lo ; switch depth > max. depth? | |
794 bra gaslist_spdepthplus_1 ; NO | |
795 movwf lo ; YES - copy to lo | |
0 | 796 gaslist_spdepthplus_1: |
604 | 797 movf gaslist_gas,W ; re-load index |
798 movff lo,PLUSW1 ; write back setpoint depth | |
582 | 799 return |
0 | 800 |
623 | 801 |
802 ; Decrement set point switch depth | |
803 ; | |
582 | 804 global gaslist_spdepthminus |
0 | 805 gaslist_spdepthminus: |
604 | 806 movf gaslist_gas,W ; get setpoint number (0-4) |
807 bz gaslist_spdepthminus2 ; setpoint number = 0? YES - force depth to always be 0m | |
623 | 808 lfsr FSR1,opt_setpoint_change ; load base address of opt_setpoint_change |
604 | 809 movff PLUSW1,lo ; read setpoint depth into lo |
810 decf lo,F ; decrement switch depth | |
811 btfsc STATUS,N ; did depth became negative? | |
812 clrf lo ; YES - reset to zero | |
813 movff lo,PLUSW1 ; write back setpoint depth | |
582 | 814 return |
0 | 815 |
623 | 816 |
817 ; helper for increment/decrement setpoint switch depth | |
818 ; | |
604 | 819 gaslist_spdepthplus2: |
820 gaslist_spdepthminus2: | |
821 movlw .0 | |
623 | 822 movff WREG,opt_setpoint_change+0; hard reset to 0m |
604 | 823 return |
824 | |
623 | 825 ENDIF ; _ccr_pscr |
826 | |
827 ;============================================================================= | |
828 | |
604 | 829 |
0 | 830 ;---------------------------------------------------------------------------- |
628 | 831 ; Compute MOD from O2 ratio and char_I_ppO2_max_work / char_I_ppO2_max_deco |
832 ; Compute MOD from O2 ratio and char_I_ppO2_max_deco | |
0 | 833 ; |
582 | 834 ; Input: gaslist_gas = current gas index. |
0 | 835 ; opt_gas_O2_ratio[gaslist_gas] = current O2 ratio |
582 | 836 ; Output: WREG = MOD [m] |
0 | 837 ; |
838 gaslist_calc_mod: | |
628 | 839 lfsr FSR1,opt_gas_type ; load base address of opt_gas_type |
604 | 840 movf gaslist_gas,W ; load index (0...9) |
628 | 841 movff PLUSW1,xA+0 ; read gas/dil type into xA+0 (used as temp here) |
842 movff char_I_ppO2_max_work,xB+1 ; get max ppO2 for deco into xB+1 (used as temp here) | |
843 movlw .3 ; type code for deco gases | |
844 cpfslt xA+0 ; is it a deco gas? | |
845 gaslist_calc_mod_deco: | |
846 movff char_I_ppO2_max_deco,xB+1 ; YES - overwrite/get ppO2 max with/for work | |
604 | 847 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio |
628 | 848 movf gaslist_gas,W ; load index (0...9) |
604 | 849 movff PLUSW1,xB+0 ; read O2 ratio into xB+0 |
628 | 850 movf xB+1,W ; copy ppO2 max into WREG |
604 | 851 clrf xB+1 ; clear xB+1 for div16x16 operation |
852 mullw .10 ; multiply ppO2 max value with 10 | |
623 | 853 MOVII PROD,xA ; copy result to xA |
604 | 854 call div16x16 ; xC = xA / xB with xA as remainder |
628 | 855 movf xC+0,W ; copy low byte of the result to WREG |
604 | 856 addlw -.10 ; subtract 10 cbar |
623 | 857 return ; return with final result [in meters] in WREG |
582 | 858 |
0 | 859 ;---------------------------------------------------------------------------- |
154
afa31c815f24
NEW: Show ppO2 for change depth during gas setup
heinrichsweikamp
parents:
97
diff
changeset
|
860 |
623 | 861 ; print ppO2 as x.xx for gas/diluent in gaslist_gas (0-9) |
862 ; | |
582 | 863 global gaslist_ppo2 |
154
afa31c815f24
NEW: Show ppO2 for change depth during gas setup
heinrichsweikamp
parents:
97
diff
changeset
|
864 gaslist_ppo2: |
582 | 865 STRCAT_TEXT tppO2 ; ppO2: |
604 | 866 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change |
867 movf gaslist_gas,W ; load index (0-9) | |
868 movf PLUSW1,W ; read change depth into WREG | |
869 mullw .10 ; PROD = depth in mbar/10 (100 = 1.00 bar) | |
623 | 870 ADDLI .100,PROD ; add 1 bar |
871 MOVII PROD,xA ; copy result to xA | |
604 | 872 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio |
873 movf gaslist_gas,W ; load index (0-9) | |
874 movff PLUSW1,xB+0 ; read O2 ratio into xB+0 | |
875 clrf xB+1 ; clear xB+1 | |
876 call mult16x16 ; calculate char_I_O2_ratio * (p_amb/10) | |
623 | 877 MOVII xC,xA ; copy result to xA |
604 | 878 movlw d'100' ; load 100 to xB |
582 | 879 movwf xB+0 |
880 clrf xB+1 | |
604 | 881 call div16x16 ; xC = xA / xB = (char_I_O2_ratio * p_amb/10)/100 |
882 ; check for very high ppO2 | |
883 tstfsz xC+2 ; xC+2 remains from mult16x16, xC+2 > 0 (-> ppO2 is > 6.55 bar) ? | |
884 bra gaslist_ppo2_1 ; YES - display a fixed max value | |
623 | 885 MOVII xC,mpr ; copy result to hi:lo |
582 | 886 bcf ignore_digit4 |
887 bsf leftbind | |
604 | 888 output_16dp d'3' ; print ppO2 as x.xx |
889 STRCAT_TEXT tbar ; print "bar" | |
582 | 890 return |
604 | 891 gaslist_ppo2_1: |
582 | 892 STRCAT ">6.6" |
893 return | |
154
afa31c815f24
NEW: Show ppO2 for change depth during gas setup
heinrichsweikamp
parents:
97
diff
changeset
|
894 |
623 | 895 |
896 ; print MOD and END for gas in gaslist_gas (0-9) | |
897 ; | |
582 | 898 global gaslist_MOD_END |
0 | 899 gaslist_MOD_END: |
604 | 900 STRCAT_TEXT tMOD ; print "MOD:" |
901 rcall gaslist_calc_mod ; compute MOD into WREG | |
902 movwf lo ; copy result to lo | |
903 call gaslist_strcat_depth ; print depth in meters or feet as configured | |
904 PUTC "/" ; print "/" | |
905 STRCAT_TEXT tEND ; print "END:" | |
906 rcall gaslist_calc_mod ; compute MOD into WREG | |
907 addlw .10 ; compute MOD = MOD + 10m | |
582 | 908 movwf xB+0 |
909 clrf xB+1 | |
910 movlw d'100' | |
911 movwf xA+0 | |
604 | 912 lfsr FSR1,opt_gas_He_ratio ; load base address of opt_gas_He_ratio |
913 movf gaslist_gas,W ; load index (0...9) | |
914 movf PLUSW1,W ; read He ration into WREG | |
915 subwf xA+0,F ; xA+0 = 100 - He ratio in % | |
582 | 916 clrf xA+1 |
917 call mult16x16 ; xA*xB=xC | |
623 | 918 MOVII xC,xA |
582 | 919 movlw d'100' |
920 movwf xB+0 | |
921 clrf xB+1 | |
604 | 922 call div16x16 ; xC = xA / xB with xA as remainder |
582 | 923 ; ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100 |
604 | 924 movlw d'10' ; subtract 10 m |
925 subwf xC+0,F ; ... | |
926 movff xC+0,lo ; copy result to lo | |
927 bra gaslist_strcat_depth ; print depth in meters or feet as configured and return | |
928 | |
929 | |
623 | 930 ; print change depth of gas in gaslist_gas (0-9), use warning color if > MOD |
931 ; | |
604 | 932 global gaslist_reset_mod_title |
933 gaslist_reset_mod_title: | |
628 | 934 STRCAT_TEXT tDepthReset ; print "Reset to MOD:" |
935 PUTC " " ; add a space char | |
604 | 936 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change |
937 movf gaslist_gas,W ; load index (0-9) | |
628 | 938 movff PLUSW1,hi ; read change depth into hi |
939 rcall gaslist_calc_mod ; compute MOD for ppO2 max work/deco dependent on gas type into WREG | |
940 movwf lo ; copy (true) MOD to lo | |
941 movf hi,W ; copy change depth to WREG | |
604 | 942 cpfslt lo ; change depth > MOD ? |
628 | 943 bra gaslist_strcat_depth ; NO - print MOD from value in lo |
944 call TFT_attention_color ; YES - use attention color | |
945 rcall gaslist_calc_mod_deco ; - compute MOD for ppO2 max deco into WREG | |
946 movwf up ; - copy result to up | |
947 movf hi,W ; - copy change depth to WREG again | |
948 cpfslt up ; - change depth > MOD deco ? | |
949 bra gaslist_strcat_depth ; NO - print MOD from value in lo, keeping attention color | |
950 call TFT_warning_color ; YES - switch to warning color | |
951 bra gaslist_strcat_depth ; - print MOD from value in lo | |
604 | 952 |
953 | |
623 | 954 ; set change depth of gas in gaslist_gas (0-9) to its MOD |
955 ; | |
604 | 956 global gaslist_reset_mod |
957 gaslist_reset_mod: | |
958 rcall gaslist_calc_mod ; compute MOD into WREG | |
959 movwf lo ; copy result to lo | |
960 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change | |
961 movf gaslist_gas,W ; load index (0-9) | |
962 movff lo,PLUSW1 ; write back new change depth | |
582 | 963 return |
0 | 964 |
965 ;---------------------------------------------------------------------------- | |
623 | 966 ; put "Nxlo", "Txlo/hi", "Air" or "O2" into postinc2 |
967 ; | |
968 ; Includes capability to show trimix gases to be able to properly decode data | |
969 ; from logbook in case trimix dives are stored on an OSTC running the sport FW. | |
970 | |
971 global gaslist_show_mix | |
972 gaslist_show_mix: | |
973 tstfsz hi ; He=0? | |
974 bra gaslist_show_mix5 ; NO - show a TX | |
975 movlw .21 | |
976 cpfseq lo ; Air? | |
977 bra gaslist_show_mix2 ; NO | |
978 STRCAT_TEXT tSelectAir ; YES - show "Air" | |
979 bra gaslist_show_mix4b | |
980 gaslist_show_mix2: | |
981 movlw .100 | |
982 cpfseq lo ; O2? | |
983 bra gaslist_show_mix3 ; NO | |
984 STRCAT_TEXT tSelectO2 ; YES - show "O2" | |
985 bra gaslist_show_mix4b | |
986 gaslist_show_mix3: | |
987 movlw .21 | |
988 cpfslt lo ; < Nx21? | |
989 bra gaslist_show_mix4 ; NO | |
990 STRCAT_TEXT tGasErr ; YES - show "Err" | |
991 output_99 ; O2 ratio is still in "lo" | |
992 bra gaslist_show_mix4c | |
993 gaslist_show_mix4: | |
994 STRCAT_TEXT tSelectNx ; show "Nx" | |
995 output_99 ; O2 ratio is still in "lo" | |
996 gaslist_show_mix4b: | |
997 STRCAT " " | |
998 gaslist_show_mix4c: | |
999 btfsc divemode ; in dive mode? | |
1000 return ; YES | |
1001 STRCAT " " | |
1002 return | |
1003 gaslist_show_mix5: | |
1004 btfsc divemode | |
1005 bra gaslist_show_mix6 | |
1006 STRCAT_TEXT tSelectTx ; show "Tx" | |
1007 gaslist_show_mix6: | |
1008 output_99 ; O2 ratio is still in "lo" | |
1009 PUTC "/" | |
1010 movff hi,lo | |
1011 output_99 ; He ratio | |
1012 return | |
1013 | |
1014 ;----------------------------------------------------------------------------- | |
1015 | |
582 | 1016 END |