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