Mercurial > public > hwos_code
annotate src/gaslist.asm @ 653:8bcd138ab744
add tools/o3pack.bat and the required tools/libs
author | heinrichsweikamp |
---|---|
date | Fri, 11 Aug 2023 15:53:49 +0200 |
parents | 4050675965ea |
children | 75e90cd0c2c3 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
634 | 3 ; File gaslist.asm * combined next generation V3.09.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" |
634 | 21 #include "colorschemes.inc" |
0 | 22 |
23 | |
24 ;============================================================================= | |
634 | 25 gaslist1 CODE |
26 ;============================================================================= | |
631 | 27 |
28 ;----------------------------------------------------------------------------- | |
634 | 29 ; Append Mix ("Nxlo", "Txlo/hi", "Air" or "O2") to current String |
604 | 30 ; |
634 | 31 ; Input: PRODL : gas/dil number (0..4) |
32 ; flag 'is_diluent_menu' for gas/dil selection | |
604 | 33 ; |
634 | 34 global gaslist_strcat_mix_PRODL |
35 gaslist_strcat_mix_PRODL: | |
604 | 36 movff PRODL,gaslist_gas ; get current menu item (0-4) |
37 movlw .5 ; offset between gases and diluents | |
623 | 38 btfsc is_diluent_menu ; setting up diluents? |
604 | 39 addwf gaslist_gas,F ; YES - add the offset |
40 movf gaslist_gas,W ; copy to WREG | |
634 | 41 ;bra gaslist_strcat_mix_WREG ; continue |
42 | |
43 | |
44 ;----------------------------------------------------------------------------- | |
45 ; Append Mix ("Nxlo", "Txlo/hi", "Air" or "O2") to current String | |
46 ; | |
47 ; Input: WREG : gas/dil number (0..9) | |
48 ; | |
49 global gaslist_strcat_mix_WREG | |
50 gaslist_strcat_mix_WREG: ; entry point with gas/dil in WREG (0-9) | |
604 | 51 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio |
52 movff PLUSW1,lo ; read O2 ratio | |
53 lfsr FSR1,opt_gas_He_ratio ; load base address of opt_gas_He_ratio | |
54 movff PLUSW1,hi ; read He ratio | |
634 | 55 ;bra gaslist_strcat_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and RETURN |
0 | 56 |
604 | 57 |
634 | 58 ;---------------------------------------------------------------------------- |
59 ; Append Mix ("Nxlo", "Txlo/hi", "Air" or "O2") to current String | |
60 ; | |
61 ; Input: lo O2% | |
62 ; hi He% | |
63 ; | |
64 ; Includes capability to show trimix gases to be able to properly decode data | |
65 ; from logbook in case trimix dives are stored on an OSTC running the sport FW | |
66 ; | |
67 global gaslist_strcat_mix | |
68 gaslist_strcat_mix: | |
69 tstfsz hi ; He=0? | |
70 bra gaslist_strcat_mix_5 ; NO - print a TX | |
71 | |
72 gaslist_strcat_mix_1: | |
73 movlw .21 ; air is 21% O2 | |
74 cpfseq lo ; Air ? | |
75 bra gaslist_strcat_mix_2 ; NO - try next | |
76 STRCAT_TEXT tSelectAir ; YES - print "Air" | |
77 bra gaslist_strcat_mix_4b ; - continue | |
78 | |
79 gaslist_strcat_mix_2: | |
80 movlw .100 ; O2 is 100% O2 | |
81 cpfseq lo ; O2 ? | |
82 bra gaslist_strcat_mix_3 ; NO - try next | |
83 STRCAT_TEXT tSelectO2 ; YES - print "O2" | |
84 bra gaslist_strcat_mix_4b ; - continue | |
85 | |
86 gaslist_strcat_mix_3: | |
87 movlw .21 ; strange mix has no He and O2 < 21% | |
88 cpfslt lo ; < Nx21 ? | |
89 bra gaslist_strcat_mix_4 ; NO - try next | |
90 STRCAT_TEXT tGasErr ; YES - print "Err" | |
91 output_99 ; - print O2% | |
92 bra gaslist_strcat_mix_4c ; - continue | |
93 | |
94 gaslist_strcat_mix_4: | |
95 STRCAT_TEXT tSelectNx ; print "Nx" | |
96 output_99 ; print O2% | |
97 | |
98 gaslist_strcat_mix_4b: | |
99 STRCAT " " ; print a space | |
100 | |
101 gaslist_strcat_mix_4c: | |
102 btfsc divemode ; in dive mode? | |
103 return ; YES - done | |
104 STRCAT " " ; NO - add two spaces | |
105 return ; - done | |
106 | |
107 gaslist_strcat_mix_5: | |
108 btfsc divemode ; in dive mode? | |
109 bra gaslist_strcat_mix_6 ; YES - do short version | |
110 STRCAT_TEXT tSelectTx ; NO - print "Tx" | |
111 | |
112 gaslist_strcat_mix_6: | |
113 output_99 ; print O2% | |
114 PUTC "/" ; print "/" | |
115 movff hi,lo ; move He% into lo | |
116 output_99 ; print He% | |
631 | 117 return ; done |
0 | 118 |
119 | |
120 ;---------------------------------------------------------------------------- | |
634 | 121 ; Append full Gas Description to current String |
604 | 122 ; |
123 ; Prints gas number, * if first, = if deco gas, gas composition and change depth, | |
124 ; including fancy color-coding | |
0 | 125 ; |
604 | 126 ; Input: PRODL gas number (0..4) |
634 | 127 ; flag 'is_diluent_menu' for gas/dil selection |
604 | 128 ; |
129 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry | |
634 | 130 ; |
131 global gaslist_strcat_gas_PRODL | |
132 gaslist_strcat_gas_PRODL: | |
604 | 133 movff PRODL,gaslist_gas ; get current menu item (0-4) |
134 movlw .5 ; offset between gases and diluents | |
631 | 135 btfsc is_diluent_menu ; dealing with diluents? |
604 | 136 addwf gaslist_gas,F ; YES - add the offset |
634 | 137 ;bra gaslist_strcat_gas ; continue with gaslist_strcat_gas function |
138 | |
631 | 139 |
634 | 140 ;---------------------------------------------------------------------------- |
141 ; Append full Gas Description to current String | |
142 ; | |
143 ; Print gas number, * if first, = if deco gas, gas composition and change depth, | |
144 ; including fancy color-coding | |
145 ; | |
146 ; Input: gaslist_gas gas/dil number (0..9) | |
147 ; | |
148 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry | |
149 ; | |
150 global gaslist_strcat_gas | |
151 gaslist_strcat_gas: | |
152 btfsc short_gas_descriptions ; shall use short versions of gaslist_strcat_gas_PRODL? | |
153 bra gaslist_gastitle_short ; YES - use short version | |
154 incf gaslist_gas,W ; NO - (0-9) -> (1-10) into WREG | |
155 movwf lo ; - copy gas index to lo | |
156 movlw .6 ; - diluents start with 6 | |
157 cpfslt lo ; - gas number < 6 ? | |
158 bra gaslist_gastitle_dil ; NO - it's a diluent | |
159 ;bra gaslist_gastitle_gas ; YES - it's a gas | |
160 | |
161 gaslist_gastitle_gas: | |
162 STRCAT_TEXT tGas ; it's a gas | |
163 bra gaslist_gastitle_gas_num ; continue | |
164 | |
604 | 165 gaslist_gastitle_dil: |
631 | 166 STRCAT_TEXT tDil ; it's a diluent |
604 | 167 movlw .5 ; offset between gases and diluents |
631 | 168 subwf lo,F ; subtract offset from diluent number (6-10) -> (1-5) again |
634 | 169 |
170 gaslist_gastitle_gas_num: | |
171 output_9 ; print gas/dil number (1-5) | |
172 PUTC ":" ; print ":" | |
173 | |
174 gaslist_gastitle_short: | |
623 | 175 btfsc divemode ; in dive mode? |
634 | 176 bra gaslist_gastitle_color_avail; YES - no "*" and "=" in front of gas composition, no highlighting for transmitters paired |
604 | 177 |
178 IFDEF _rx_functions | |
634 | 179 btfss tr_functions_activated ; TR functions activated? |
180 bra gaslist_gastitle_type_1 ; NO - continue with gas type | |
181 lfsr FSR1,opt_transmitter_id_1 ; YES - load base address of transmitter ID table | |
182 movf gaslist_gas,W ; - (0-4 for gases, 5-9 for diluents) | |
183 rlncf WREG,W ; - index x2 because IDs are 2 byte | |
184 tstfsz PLUSW1 ; - transmitter ID low byte <> 0 ? | |
185 bsf win_invert ; YES - flag transmitter paired by inverting output | |
186 incf WREG,W ; - increment index | |
187 tstfsz PLUSW1 ; - transmitter ID high byte <> 0 ? | |
188 bsf win_invert ; YES - flag transmitter paired by inverting output | |
189 ENDIF ; _rx_functions | |
604 | 190 |
634 | 191 gaslist_gastitle_type_1: |
192 rcall gaslist_strcat_gas_type ; print type marking ("*", "=", "X", ...) | |
193 | |
194 gaslist_gastitle_color_avail: | |
195 FONT_COLOR_MEMO ; default to standard color | |
623 | 196 btfsc divemode ; in dive mode? |
631 | 197 rcall gaslist_strcat_gas_better ; YES - check if this is a "better gas", if yes switch to green and inverted output |
604 | 198 lfsr FSR1,opt_gas_type ; load base address of gas types |
199 movf gaslist_gas,W ; load index into WREG (0-4 for gases, 5-9 for diluents) | |
200 movf PLUSW1,W ; read gas/dil type into WREG | |
631 | 201 btfsc WREG,gas_lost ; gas/dil lost? |
634 | 202 bra gaslist_gastitle_not_avail ; YES - switch to disabled color and skip ppO2 check |
631 | 203 btfsc WREG,gas_staged ; gas/dil staged? |
634 | 204 bra gaslist_gastitle_not_avail ; YES - switch to disabled color and skip ppO2 check |
205 bnz gaslist_gastitle_color_ppo2 ; type not disabled -> color code by ppO2 | |
206 ;bz gaslist_gastitle_not_avail ; type disabled -> switch to disabled color and skip ppO2 check | |
207 | |
208 gaslist_gastitle_not_avail: | |
209 FONT_COLOR_DISABLED ; switch to disabled color | |
210 bra gaslist_gastitle_mix ; skip ppO2 check for disabled gases | |
211 | |
212 gaslist_gastitle_color_ppo2: | |
623 | 213 btfss divemode ; in dive mode? |
634 | 214 bra gaslist_gastitle_mix ; NO - no color-coding if not in dive mode |
631 | 215 btfss color_code_gases ; YES - shall color-code the gases by ppO2 and current depth? |
634 | 216 bra gaslist_gastitle_mix ; NO - skip color-coding |
631 | 217 lfsr FSR1,opt_gas_O2_ratio ; YES - load base address of opt_gas_O2_ratio |
218 movf gaslist_gas,W ; - load index into WREG (0-4 for gases, 5-9 for diluents) | |
219 movff PLUSW1,hi ; - read O2 ratio into hi | |
220 call TFT_color_code_gaslist ; - set color according to ppO2 limits | |
634 | 221 |
222 gaslist_gastitle_mix: | |
604 | 223 movf gaslist_gas,W ; copy gas/dil index to WREG (0-9) |
634 | 224 rcall gaslist_strcat_mix_WREG ; print gas composition |
623 | 225 btfss divemode ; in dive mode? |
634 | 226 bra gaslist_gastitle_no_type ; NO - print no type marking |
227 ;bra gaslist_gastitle_type_2 ; YES - print type marking | |
228 | |
229 gaslist_gastitle_type_2: | |
230 rcall gaslist_strcat_gas_type ; print type marking ("*", "=", "X", ...) | |
231 bra gaslist_gastitle_depth ; continue with change depth | |
232 | |
233 gaslist_gastitle_no_type: | |
604 | 234 PUTC " " ; print a space |
634 | 235 |
236 gaslist_gastitle_depth: | |
604 | 237 lfsr FSR1,opt_gas_change ; load base address of change depths |
238 movf gaslist_gas,W ; load gas/dil index into WREG (0-9) | |
239 movff PLUSW1,lo ; read change depth into lo | |
634 | 240 ;bra gaslist_strcat_depth ; print depth and return |
604 | 241 |
623 | 242 |
634 | 243 ;----------------------------------------------------------------------------- |
244 ; Helper Function - print Depths in Meters or Feet | |
245 ; | |
246 ; input: lo depth in meters | |
623 | 247 ; |
634 | 248 gaslist_strcat_depth: |
249 TSTOSS opt_units ; check depth units | |
250 bra gaslist_strcat_depth_meter ; 0 - use Meters | |
251 ;bra gaslist_strcat_depth_feet ; 1 - use Feet | |
252 | |
253 gaslist_strcat_depth_feet: | |
254 call convert_meter_to_feet ; convert value in lo from [m] to [feet] | |
255 output_999 ; print depth (0-999) | |
256 STRCAT_TEXT tFeets ; append "ft" REMARK: still one char to long for space available in dive mode menu! | |
257 return ; done | |
258 | |
259 gaslist_strcat_depth_meter: | |
260 output_256 ; print 0-256 | |
261 STRCAT_TEXT tMeters ; append "m" | |
262 return ; done | |
263 | |
264 | |
265 ;----------------------------------------------------------------------------- | |
266 ; Helper Function - color-code Output if this is the best Gas/Diluent | |
267 ; | |
268 gaslist_strcat_gas_better: | |
269 btfss better_gas_hint ; shall better gas cues be given? | |
270 return ; NO - return | |
271 movf best_gas_number,W ; YES - get best gas number into WREG | |
623 | 272 IFDEF _ccr_pscr |
634 | 273 btfsc is_diluent_menu ; - setting up diluents? |
274 movf best_dil_number,W ; YES - replace with best diluent number | |
275 ENDIF ; _ccr_pscr | |
276 tstfsz WREG ; - is a best gas/dil available? | |
277 bra gaslist_strcat_gas_better1 ; YES - proceed | |
278 return ; NO - done | |
279 | |
604 | 280 gaslist_strcat_gas_better1: |
281 decf WREG,W ; (1-5) -> (0-4) | |
623 | 282 btfsc is_diluent_menu ; setting up diluents? |
634 | 283 addlw .5 ; YES - add offset between gases and diluents (0-4) -> (5-9) to better gas number |
284 cpfseq gaslist_gas ; is the current gas/dil the best one? | |
285 return ; NO - done | |
286 bsf win_invert ; YES - print invert | |
287 FONT_COLOR color_green ; - select green color (gas is something "good") | |
288 return ; - done | |
604 | 289 |
623 | 290 |
634 | 291 ;----------------------------------------------------------------------------- |
292 ; Helper Function - print "*" for first Gas/Dil | |
293 ; a down arrow for a Work Gas/Dil | |
294 ; "=" for a Deco Gas | |
295 ; " " for a disabled Gas/Dil | |
296 ; "X" for a lost Gas/Dil | |
297 ; "S" for a staged Gas/Dil | |
298 ; | |
604 | 299 gaslist_strcat_gas_type: |
300 lfsr FSR1,opt_gas_type ; load base address of gas types | |
301 movf gaslist_gas,W ; load index to WREG (0-4 for gases, 5-9 for diluents) | |
631 | 302 movf PLUSW1,W ; get gas/dil type into WREG |
303 btfsc WREG,gas_lost ; gas set as lost? | |
304 bra gaslist_strcat_gas_type_4 ; YES - print lost marking | |
305 IFDEF _cave_mode | |
306 btfsc WREG,gas_staged ; gas set as staged? | |
307 bra gaslist_strcat_gas_type_5 ; YES - print staged marking | |
634 | 308 ENDIF ; _cave_mode |
631 | 309 decf WREG,W ; decrement gas type (-1 for disabled, 0 for first, 1 for work/normal, 2 for deco) |
628 | 310 bnz gaslist_strcat_gas_type_1 ; type = first? NO - continue with checking for work and deco gas |
604 | 311 PUTC "*" ; YES - print "*" for first |
312 return ; - done | |
634 | 313 |
604 | 314 gaslist_strcat_gas_type_1: |
628 | 315 decf WREG,W ; decrement gas type (-2 for disabled, -1 for first, 0 for work/normal, 1 for deco) |
316 bnz gaslist_strcat_gas_type_2 ; type = work? NO - continue with checking for deco gas | |
317 PUTC "\xb8" ; YES - print down-arrow for a work gas | |
318 return ; - done | |
634 | 319 |
628 | 320 gaslist_strcat_gas_type_2: |
321 decf WREG,W ; decrement gas type (-3 for disabled, -2 for first, -1 for work/normal, 0 for deco) | |
322 bnz gaslist_strcat_gas_type_3 ; type = deco? NO - neither first nor deco | |
604 | 323 PUTC "=" ; YES - print "=" for a deco gas |
634 | 324 return ; - done |
325 | |
628 | 326 gaslist_strcat_gas_type_3: |
634 | 327 PUTC " " ; type = disabled, print a space |
631 | 328 return ; done |
634 | 329 |
631 | 330 gaslist_strcat_gas_type_4: |
331 PUTC "x" ; print lost marking | |
332 return ; done | |
634 | 333 |
631 | 334 IFDEF _cave_mode |
335 gaslist_strcat_gas_type_5: | |
336 PUTC "S" ; print staged marking | |
337 return ; done | |
634 | 338 ENDIF ; _cave_mode |
604 | 339 |
623 | 340 |
604 | 341 ;---------------------------------------------------------------------------- |
634 | 342 ; Helper Function: |
628 | 343 ; Compute MOD from O2 ratio and char_I_ppO2_max_work / char_I_ppO2_max_deco |
344 ; Compute MOD from O2 ratio and char_I_ppO2_max_deco | |
0 | 345 ; |
634 | 346 ; Input: gaslist_gas = current gas index |
0 | 347 ; opt_gas_O2_ratio[gaslist_gas] = current O2 ratio |
582 | 348 ; Output: WREG = MOD [m] |
0 | 349 ; |
634 | 350 global gaslist_calc_mod |
0 | 351 gaslist_calc_mod: |
628 | 352 lfsr FSR1,opt_gas_type ; load base address of opt_gas_type |
604 | 353 movf gaslist_gas,W ; load index (0...9) |
628 | 354 movff PLUSW1,xA+0 ; read gas/dil type into xA+0 (used as temp here) |
355 movff char_I_ppO2_max_work,xB+1 ; get max ppO2 for deco into xB+1 (used as temp here) | |
356 movlw .3 ; type code for deco gases | |
357 cpfslt xA+0 ; is it a deco gas? | |
358 gaslist_calc_mod_deco: | |
359 movff char_I_ppO2_max_deco,xB+1 ; YES - overwrite/get ppO2 max with/for work | |
604 | 360 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio |
628 | 361 movf gaslist_gas,W ; load index (0...9) |
604 | 362 movff PLUSW1,xB+0 ; read O2 ratio into xB+0 |
634 | 363 movf xB+1,W ; copy ppO2 [cbar] max into WREG |
604 | 364 clrf xB+1 ; clear xB+1 for div16x16 operation |
365 mullw .10 ; multiply ppO2 max value with 10 | |
623 | 366 MOVII PROD,xA ; copy result to xA |
604 | 367 call div16x16 ; xC = xA / xB with xA as remainder |
634 | 368 movf xC+0,W ; copy low byte of the result to WREG |
369 addlw -.10 ; subtract 10 m to remove the 1 bar surface pressure | |
623 | 370 return ; return with final result [in meters] in WREG |
582 | 371 |
634 | 372 |
373 ;============================================================================= | |
374 gaslist2 CODE | |
375 ;============================================================================= | |
376 | |
377 ;----------------------------------------------------------------------------- | |
378 ; Clean up the Gas/Diluent Settings so that there is only one FIRST Gas/Diluent | |
379 ; | |
380 ; Input: gaslist_gas last edited gas/dil (0-9) | |
381 ; | |
382 global gaslist_cleanup_list | |
383 gaslist_cleanup_list: | |
384 lfsr FSR1,opt_gas_type ; load base address of opt_gas_type | |
385 | |
386 IFDEF _ccr_pscr | |
387 movlw .5 ; offset between gases and diluents | |
388 btfsc is_diluent_menu ; setting up diluents? | |
389 subwf gaslist_gas,F ; YES - subtract offset from gaslist_gas: (5-9) -> (0-4) | |
390 ENDIF ; _ccr_pscr | |
391 | |
392 gaslist_cleanup_list_loop_1: | |
393 bcf ignore_last_edited_gas ; allow the last edited gas/dil to be found as a "first" | |
394 | |
395 gaslist_cleanup_list_loop_2: | |
396 clrf lo ; clear number of "first" gases found | |
397 movlw .5 ; initialize hi as loop counter for checking 5 gases/diluents | |
398 movwf hi ; ... | |
399 | |
400 gaslist_cleanup_list_loop_3: | |
401 decf hi,W ; WREG = current gas/dil to check (4..0) | |
402 | |
403 IFDEF _ccr_pscr | |
404 btfsc is_diluent_menu ; setting up diluents? | |
405 addlw .5 ; YES - add offset from gases to diluents -> (9..5) | |
406 ENDIF ; _ccr_pscr | |
407 | |
408 movff PLUSW1,WREG ; read type into WREG | |
409 decfsz WREG ; type = first ? | |
410 bra gaslist_cleanup_1 ; NO - done with this gas/dil | |
411 incf lo,F ; YES - increment number of "firsts" found | |
412 btfss ignore_last_edited_gas ; - shall the last edited gas/dil be skipped? | |
413 bra gaslist_cleanup_set_first ; NO - set the currently checked gas/dil as last "first" found | |
414 decf hi,W ; YES - get the currently checked gas/dil (0..4) | |
415 cpfseq gaslist_gas ; - is the currently checked gas/dil == the last edited gas/dil ? | |
416 gaslist_cleanup_set_first: | |
417 movff hi,up ; (NO) - set current gas/dil as the last "first" found (1..5) | |
418 | |
419 gaslist_cleanup_1: | |
420 decfsz hi,F ; decrement loop counter, did loop counter became 0? | |
421 bra gaslist_cleanup_list_loop_3 ; NO - check next gas/dil | |
422 tstfsz lo ; YES - any first gas/dil at all? | |
423 bra gaslist_cleanup_list_2 ; YES - one or more "first" gas/dil found | |
424 | |
425 IFDEF _ccr_pscr | |
426 btfsc is_diluent_menu ; NO - setting up diluents? | |
427 lfsr FSR1,opt_dil_type ; YES - load base address of opt_gas_type | |
428 ENDIF ; _ccr_pscr | |
429 | |
430 movlw .1 ; - load coding for first gas | |
431 movwf INDF1 ; - make gas/dil 1 the first gas | |
432 bsf option_changed ; - flag that the EEPROM needs to be updated | |
433 return ; - done | |
434 | |
435 gaslist_cleanup_list_2: | |
436 movlw .1 ; total number of "first" gas/dil allowed is 1 | |
437 cpfsgt lo ; more than one "first" found? | |
438 return ; NO - done | |
439 decf up,W ; YES - get last found "first" (0-4) | |
440 cpfseq gaslist_gas ; - is last found "first" == last edited gas/dil ? | |
441 bra gaslist_cleanup_disable ; NO - disable it | |
442 bsf ignore_last_edited_gas ; YES - do not find the last edited gas/dil as "first" any more | |
443 bra gaslist_cleanup_list_loop_2 ; - loop until only one "first" is left over | |
154
afa31c815f24
NEW: Show ppO2 for change depth during gas setup
heinrichsweikamp
parents:
97
diff
changeset
|
444 |
634 | 445 gaslist_cleanup_disable: |
446 IFDEF _ccr_pscr | |
447 btfsc is_diluent_menu ; setting up diluents? | |
448 addlw .5 ; YES - adjust offset | |
449 ENDIF ; _ccr_pscr | |
450 | |
451 clrf PLUSW1 ; disable the gas/dil | |
452 bsf option_changed ; flag that the EEPROM needs to be updated | |
453 bra gaslist_cleanup_list_loop_1 ; redo from start until only one "first" is left over | |
454 | |
455 | |
456 ;============================================================================= | |
457 gaslist3 CODE | |
458 ;============================================================================= | |
459 | |
460 IFDEF _ccr_pscr | |
461 | |
462 ;----------------------------------------------------------------------------- | |
463 ; Main Menu Item - print Setpoint by 'PRODL' (dynamic Title) | |
464 ; | |
465 global gaslist_strcat_setpoint_PRODL | |
466 gaslist_strcat_setpoint_PRODL: | |
467 movff PRODL,gaslist_gas ; get current menu item (0-4) | |
468 ;bra gaslist_strcat_setpoint ; continue | |
469 | |
470 | |
471 ;----------------------------------------------------------------------------- | |
472 ; Main Menu Item - print Setpoint by 'gaslist_gas' (dynamic Title) | |
473 ; | |
474 global gaslist_strcat_setpoint | |
475 gaslist_strcat_setpoint: | |
476 btfsc short_gas_descriptions ; shall use short version? | |
477 bra gaslist_strcat_setpoint2 ; YES - use short version | |
478 STRCAT_TEXT tSP ; "SP" | |
479 incf gaslist_gas,W ; (0-4) -> (1-5) into WREG | |
480 movwf lo ; copy to lo | |
481 output_9 ; print SP number (0-9) | |
482 PUTC ":" ; ":" | |
483 | |
484 gaslist_strcat_setpoint2: | |
485 btfsc divemode ; in dive mode? | |
486 bra gaslist_strcat_setpoint4 ; YES - do not add the "*" in dive mode | |
487 movf gaslist_gas,W ; NO - (0-4) into WREG | |
488 bnz gaslist_strcat_setpoint3 ; - SP index = 0 ? | |
489 PUTC "*" ; YES - print * | |
490 bra gaslist_strcat_setpoint4 ; - continue with cbar value | |
491 | |
492 gaslist_strcat_setpoint3: | |
493 PUTC " " ; print a space | |
494 | |
495 gaslist_strcat_setpoint4: | |
496 movf gaslist_gas,W ; (0-4) into WREG | |
497 lfsr FSR1,opt_setpoint_cbar ; load base address of setpoint cbar values | |
498 movf PLUSW1,W ; read cbar value | |
499 movwf lo ; copy to lo | |
500 bsf decimal_digit2 ; place a decimal point in front of digit 2 | |
501 output_256 ; print as x.xx | |
502 btfsc divemode ; in dive mode? | |
503 bra gaslist_strcat_setpoint5 ; YES - skip text in dive mode | |
504 STRCAT_TEXT tbar ; NO - print "bar" | |
505 | |
506 gaslist_strcat_setpoint5: | |
507 PUTC " " ; print a space | |
508 movf gaslist_gas,W ; (0-4) into WREG | |
509 lfsr FSR1,opt_setpoint_change ; load base address of switch depths | |
510 movff PLUSW1,lo ; read switch depth into lo | |
511 goto gaslist_strcat_depth ; print depth (meters or ft) | |
512 | |
513 ENDIF ; _ccr_pscr | |
514 | |
515 | |
516 ;============================================================================= | |
517 gaslist4 CODE | |
518 ;============================================================================= | |
519 | |
520 ;---------------------------------------------------------------------------- | |
521 ; Main Menu Item - print ppO2 at Change Depth (dynamic Title) | |
623 | 522 ; |
582 | 523 global gaslist_ppo2 |
154
afa31c815f24
NEW: Show ppO2 for change depth during gas setup
heinrichsweikamp
parents:
97
diff
changeset
|
524 gaslist_ppo2: |
634 | 525 STRCAT_TEXT tppO2 ; print "ppO2:" |
604 | 526 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change |
527 movf gaslist_gas,W ; load index (0-9) | |
528 movf PLUSW1,W ; read change depth into WREG | |
529 mullw .10 ; PROD = depth in mbar/10 (100 = 1.00 bar) | |
623 | 530 ADDLI .100,PROD ; add 1 bar |
531 MOVII PROD,xA ; copy result to xA | |
604 | 532 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio |
533 movf gaslist_gas,W ; load index (0-9) | |
534 movff PLUSW1,xB+0 ; read O2 ratio into xB+0 | |
535 clrf xB+1 ; clear xB+1 | |
536 call mult16x16 ; calculate char_I_O2_ratio * (p_amb/10) | |
623 | 537 MOVII xC,xA ; copy result to xA |
634 | 538 MOVLI .100,xB ; load 100 to xB |
604 | 539 call div16x16 ; xC = xA / xB = (char_I_O2_ratio * p_amb/10)/100 |
540 ; check for very high ppO2 | |
541 tstfsz xC+2 ; xC+2 remains from mult16x16, xC+2 > 0 (-> ppO2 is > 6.55 bar) ? | |
634 | 542 bra gaslist_ppo2_2 ; YES - display a fixed max value |
543 PUTC " " ; NO - print a space | |
544 MOVII xC,mpr ; - copy result to hi:lo | |
545 bsf leftbind ; - print left-aligned | |
546 bsf decimal_digit2 ; - place a decimal point in front of digit 2 | |
547 output_999 ; - print ppO2 (0.00-655.35) | |
604 | 548 gaslist_ppo2_1: |
634 | 549 STRCAT_TEXT tbar ; - print "bar" |
550 return ; - done | |
551 | |
552 gaslist_ppo2_2: | |
553 STRCAT ">6.55" ; print ">6.55" | |
554 bra gaslist_ppo2_1 ; append unit and return | |
154
afa31c815f24
NEW: Show ppO2 for change depth during gas setup
heinrichsweikamp
parents:
97
diff
changeset
|
555 |
623 | 556 |
634 | 557 ;----------------------------------------------------------------------------- |
558 ; Main Menu Item - print MOD and END for a Gas (dynamic Title) | |
623 | 559 ; |
582 | 560 global gaslist_MOD_END |
0 | 561 gaslist_MOD_END: |
604 | 562 STRCAT_TEXT tMOD ; print "MOD:" |
634 | 563 call gaslist_calc_mod ; compute MOD into WREG |
604 | 564 movwf lo ; copy result to lo |
634 | 565 movwf hi ; keep copy in hi |
604 | 566 call gaslist_strcat_depth ; print depth in meters or feet as configured |
567 PUTC "/" ; print "/" | |
568 STRCAT_TEXT tEND ; print "END:" | |
634 | 569 movf hi,W ; retrieve MOD |
604 | 570 addlw .10 ; compute MOD = MOD + 10m |
634 | 571 movwf xB+0 ; copy to xB |
572 clrf xB+1 ; ... | |
573 MOVLI .100,xA ; load 100 to xA | |
604 | 574 lfsr FSR1,opt_gas_He_ratio ; load base address of opt_gas_He_ratio |
575 movf gaslist_gas,W ; load index (0...9) | |
634 | 576 movf PLUSW1,W ; read He ratio into WREG |
577 subwf xA+0,F ; xA = 100 - He ratio in % | |
578 call mult16x16 ; xC = xA * xB | |
579 MOVII xC,xA ; copy result to xA | |
580 MOVLI .100,xB ; load 100 to xB | |
604 | 581 call div16x16 ; xC = xA / xB with xA as remainder |
582 | 582 ; ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100 |
604 | 583 movlw d'10' ; subtract 10 m |
584 subwf xC+0,F ; ... | |
585 movff xC+0,lo ; copy result to lo | |
634 | 586 goto gaslist_strcat_depth ; print depth and return |
604 | 587 |
588 | |
634 | 589 ;----------------------------------------------------------------------------- |
590 ; Main Menu Item - print 'reset to MOD' (dynamic Title) | |
623 | 591 ; |
604 | 592 global gaslist_reset_mod_title |
593 gaslist_reset_mod_title: | |
628 | 594 STRCAT_TEXT tDepthReset ; print "Reset to MOD:" |
595 PUTC " " ; add a space char | |
604 | 596 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change |
597 movf gaslist_gas,W ; load index (0-9) | |
628 | 598 movff PLUSW1,hi ; read change depth into hi |
634 | 599 call gaslist_calc_mod ; compute MOD for ppO2 max work/deco dependent on gas type into WREG |
628 | 600 movwf lo ; copy (true) MOD to lo |
601 movf hi,W ; copy change depth to WREG | |
604 | 602 cpfslt lo ; change depth > MOD ? |
634 | 603 bra gaslist_reset_mod_title_exit; NO - print MOD from value in lo |
604 FONT_COLOR_ATTENTION ; YES - use attention color | |
605 call gaslist_calc_mod_deco ; - compute MOD for ppO2 max deco into WREG | |
628 | 606 movwf up ; - copy result to up |
607 movf hi,W ; - copy change depth to WREG again | |
608 cpfslt up ; - change depth > MOD deco ? | |
634 | 609 bra gaslist_reset_mod_title_exit; NO - print MOD from value in lo, keeping attention color |
610 FONT_COLOR_WARNING ; YES - switch to warning color | |
611 ;bra gaslist_reset_mod_title_exit; - print MOD depth | |
623 | 612 |
634 | 613 gaslist_reset_mod_title_exit: |
614 goto gaslist_strcat_depth ; print MOD depth and return | |
623 | 615 |
616 ;----------------------------------------------------------------------------- | |
617 | |
582 | 618 END |