Mercurial > public > hwos_code
comparison src/gaslist.asm @ 604:ca4556fb60b9
bump to 2.99beta, work on 3.00 stable
author | heinrichsweikamp |
---|---|
date | Thu, 22 Nov 2018 19:47:26 +0100 |
parents | b455b31ce022 |
children | c40025d8e750 |
comparison
equal
deleted
inserted
replaced
603:00b24fb4324d | 604:ca4556fb60b9 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File gaslist.asm ## V2.98 | 3 ; File gaslist.asm REFACTORED VERSION V2.99e |
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 ;============================================================================= |
9 ; HISTORY | 9 ; HISTORY |
10 ; 2011-08-11 : [jDG] Creation. | 10 ; 2011-08-11 : [jDG] Creation. |
11 | 11 |
12 #include "hwos.inc" ; Mandatory header | 12 #include "hwos.inc" ; mandatory header |
13 #include "convert.inc" | 13 #include "convert.inc" |
14 #include "math.inc" ; div16x16 for MOD calculations | 14 #include "math.inc" ; div16x16 for MOD calculations |
15 #include "strings.inc" | 15 #include "strings.inc" |
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" | |
20 | |
21 IFDEF _rx_functions | |
22 #include "rx_ops.inc" | |
23 ENDIF | |
19 | 24 |
20 extern convert_mbar_to_feet | 25 extern convert_mbar_to_feet |
21 extern customview_show_mix | 26 extern customview_show_mix |
27 extern tSetup_GasDepth | |
22 extern tGasDisabled | 28 extern tGasDisabled |
23 extern tDilDisabled | 29 extern tDilDisabled |
30 extern tLiter | |
31 extern tbar10 | |
24 extern tbar | 32 extern tbar |
25 | 33 |
26 gui CODE | 34 gaslist CODE |
27 | 35 |
28 ;============================================================================= | 36 ;============================================================================= |
29 ; Append gas description to current string. | 37 ; Helper Functions for divemenu_tree.asm |
38 ; | |
39 ; They need to be put in a different file than | |
40 ; where the MENU_DYNAMIC macros uses them. | |
41 | |
42 global do_toggle_gf_label | |
43 do_toggle_gf_label: | |
44 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF | |
45 decfsz WREG,W ; toggle GF only in GF modes - in GF mode? | |
46 bra do_toggle_gf_label_1 ; NO - print in disabled color | |
47 movff opt_enable_aGF,WREG ; =1: aGF can be selected underwater | |
48 decfsz WREG,W ; aGF enabled? | |
49 bra do_toggle_gf_label_1 ; NO - print in disabled color | |
50 bra do_toggle_gf_label_2 ; YES to both - print in standard color | |
51 do_toggle_gf_label_1: | |
52 call TFT_disabled_color | |
53 do_toggle_gf_label_2: | |
54 STRCAT_TEXT tDivemenu_ToggleGF | |
55 return | |
56 | |
57 | |
58 IFDEF _cave_mode | |
59 global do_turn_dive_label | |
60 do_turn_dive_label: | |
61 btfss FLAG_cave_mode ; in cave mode? | |
62 call TFT_disabled_color ; NO - print in disabled color | |
63 btfsc FLAG_dive_turned ; dive already turned? | |
64 call TFT_attention_color ; YES - print in attention color | |
65 STRCAT_TEXT tDivemenu_TurnDive ; output label | |
66 return | |
67 ENDIF | |
68 | |
69 | |
70 global do_toggle_max_pres_diff_label | |
71 do_toggle_max_pres_diff_label: | |
72 movff opt_TR_mode,WREG ; get TR mode | |
73 xorlw .2 ; compare with 2 (ind.double) | |
74 tstfsz WREG ; equal? | |
75 call TFT_disabled_color ; NO - print in disabled color | |
76 STRCAT_TEXT tTrMaxDeltaP ; output label | |
77 movff char_I_max_pres_diff,lo | |
78 output_99 | |
79 STRCAT_TEXT tbar ; " bar" | |
80 return | |
81 | |
82 global gaslist_copy_dil_to_oc | |
83 gaslist_copy_dil_to_oc: | |
84 ; | |
85 ; Memory Map: | |
86 ; ----------------------------------------- | |
87 ; opt_gas_O2_ratio res 5 | |
88 ; opt_dil_O2_ratio res 5 | |
89 ; opt_gas_He_ratio res 5 | |
90 ; opt_dil_He_ratio res 5 | |
91 ; opt_gas_type res 5 | |
92 ; opt_dil_type res 5 | |
93 ; opt_gas_change res 5 | |
94 ; opt_dil_change res 5 | |
95 ; | |
96 ; char_I_tank_size res 10 | |
97 ; char_I_tank_pres_fill res 10 | |
98 ; | |
99 bcf aux_flag ; clear aux_flag by default | |
100 movf gaslist_gas,W ; copy current gas or diluent number to WREG | |
101 btfss FLAG_diluent_setup ; in CCR menus? | |
102 bra gaslist_copy_dil_to_oc_1 ; NO - gaslist_gas is already pointing to an OC gas | |
103 addlw -.5 ; YES - subtract offset between diluents and gases | |
104 movwf gaslist_gas ; - let gaslist_gas point to the corresponding OC gas | |
105 bsf aux_flag ; - remember we came from a CCR menu | |
106 bcf FLAG_diluent_setup ; - pretend we came from an OC gas menu | |
107 gaslist_copy_dil_to_oc_1: | |
108 lfsr FSR0,opt_dil_O2_ratio ; load base address of diluents settings, ASM variables | |
109 lfsr FSR1,opt_gas_O2_ratio ; load base address of gas settings, ASM variables | |
110 movff PLUSW0,PLUSW1 ; copy O2 ratio | |
111 addlw .10 ; add offset from O2 ratios to He ratios | |
112 movff PLUSW0,PLUSW1 ; copy He ratio | |
113 addlw .10 ; add offset from He ratios to types | |
114 movff PLUSW0,PLUSW1 ; copy type | |
115 addlw .10 ; add offset from type to change depth | |
116 movff PLUSW0,PLUSW1 ; copy change depth | |
117 addlw -.30 ; wind back to initial gas number | |
118 lfsr FSR0,char_I_tank_size+5 ; load base address of diluents settings, shared variables | |
119 lfsr FSR1,char_I_tank_size+0 ; load base address of gas settings, shared variables | |
120 movff PLUSW0,PLUSW1 ; copy tank size | |
121 addlw .10 ; add offset from tank sizes to pressure budget | |
122 movff PLUSW0,PLUSW1 ; copy pressure budget | |
123 call gaslist_cleanup_list ; make sure that there will be just one first gas | |
124 btfss aux_flag ; did we came from a CCR menu? | |
125 return ; NO - done | |
126 bsf FLAG_diluent_setup ; YES - restore proper origin again | |
127 movlw .5 ; - offset between OC gases and diluents | |
128 addwf gaslist_gas,F ; - let gaslist_gas point to the diluent again | |
129 WIN_BOX_BLACK .30,.239,.0,.159 ; - create some visual effect to show activity | |
130 WAITMS .200 ; - pause for 200 ms | |
131 return ; - done | |
132 | |
133 | |
134 ;============================================================================= | |
135 ; Append gas description to current string | |
136 ; | |
30 ; Input: PRODL : gas number (0..4) | 137 ; Input: PRODL : gas number (0..4) |
31 ; FSR2 : Current string position. | 138 ; FSR2 : Current string position |
32 ; Output: Text appended into buffer pointed by FSR2. | 139 ; Output: Text appended into buffer pointed by FSR2 |
33 | 140 |
34 global gaslist_strcat_gas | 141 global gaslist_strcat_gas |
35 gaslist_strcat_gas: | 142 global gaslist_strcat_gas_WREG |
36 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents) | 143 gaslist_strcat_gas: ; entry point with gas/dil in PRODL (0-4) and FLAG_diluent_setup |
37 ; Retrieve gas definition: | 144 movff PRODL,gaslist_gas ; get current menu item (0-4) |
38 gaslist_strcat_gas_0: | 145 movlw .5 ; offset between gases and diluents |
39 movf gaslist_gas,W | 146 btfsc FLAG_diluent_setup ; in CCR menus? |
40 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | 147 addwf gaslist_gas,F ; YES - add the offset |
41 movff PLUSW1,lo ; O2 ratio | 148 movf gaslist_gas,W ; copy to WREG |
42 ;movf gaslist_gas,W | 149 gaslist_strcat_gas_WREG: ; entry point with gas/dil in WREG (0-9) |
43 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | 150 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio |
44 movff PLUSW1,hi ; He ratio | 151 movff PLUSW1,lo ; read O2 ratio |
45 goto customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and RETURN | 152 lfsr FSR1,opt_gas_He_ratio ; load base address of opt_gas_He_ratio |
153 movff PLUSW1,hi ; read He ratio | |
154 goto customview_show_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and RETURN | |
46 | 155 |
47 ;============================================================================= | 156 ;============================================================================= |
48 ; Append current mix to current string (For divemode) | 157 ; Append current mix to current string (for divemode) |
49 ; Input: FSR2 : Current string position. | 158 ; |
50 ; Output: Text appended into buffer pointed by FSR2. | 159 ; Input: FSR2 : Current string position |
160 ; Output: Text appended into buffer pointed by FSR2 | |
161 | |
51 global gaslist_strcat_gas6 | 162 global gaslist_strcat_gas6 |
52 gaslist_strcat_gas6: ; Show current O2/He mix | 163 gaslist_strcat_gas6: ; show current O2/He mix |
53 STRCAT_TEXT tGas | 164 STRCAT_TEXT tGas |
54 STRCAT ": " | 165 STRCAT ": " |
55 movff gas6_O2_ratio,lo | 166 movff gas6_O2_ratio,hi ; TFT_color_code_gaslist needs O2 ratio in hi |
56 movff gas6_He_ratio,hi | 167 call TFT_color_code_gaslist ; color-code according to O2 ratio and depth |
57 goto customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and RETURN | 168 movff gas6_O2_ratio,lo ; customview_show_mix needs O2 ratio in lo |
58 | 169 movff gas6_He_ratio,hi ; ... and He ratio in hi |
170 goto customview_show_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and return | |
171 ;============================================================================= | |
172 ; Helper functions for menu_tree | |
173 | |
174 global gaslist_GasDepth | |
175 gaslist_GasDepth: | |
176 movf gaslist_gas,W ; load gas/dil index into WREG (0-9) | |
177 lfsr FSR1,opt_gas_change ; load base address of change depths | |
178 tstfsz PLUSW1 ; change depth = 0 ? | |
179 bra gaslist_GasDepth_1 ; NO | |
180 lfsr FSR1,opt_gas_type ; YES - load base address of opt_gas_type | |
181 tstfsz PLUSW1 ; - type = disabled ? | |
182 call TFT_attention_color ; NO - print in attention color (yellow) | |
183 gaslist_GasDepth_1: | |
184 STRCAT_TEXT tSetup_GasDepth | |
185 return | |
59 | 186 |
60 global gaslist_show_type | 187 global gaslist_show_type |
61 gaslist_show_type: | 188 gaslist_show_type: |
62 movf gaslist_gas,W | 189 movf gaslist_gas,W |
63 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | 190 lfsr FSR1,opt_gas_type ; load base address of opt_gas_type |
64 movff PLUSW1,lo ; lo holds gas type | 191 movff PLUSW1,lo ; read gas type |
65 STRCAT_TEXT tType | 192 STRCAT_TEXT tType |
66 lfsr FSR1,tGasDisabled ; Base text number | 193 lfsr FSR1,tGasDisabled ; load base address of gas type labels |
67 btfsc ccr_diluent_setup ; In CCR setup? | 194 btfsc FLAG_diluent_setup ; in CCR setup? |
68 lfsr FSR1,tDilDisabled ; Base text number | 195 lfsr FSR1,tDilDisabled ; YES - load base address of diluent type labels |
69 movff lo,WREG ; 0-3 | 196 movff lo,WREG ; 0-3 |
70 rlncf WREG ; x2 | 197 rlncf WREG ; x2 |
71 addwf FSR1L,F | 198 addwf FSR1L,F ; adjust address pointer to required text |
72 movlw .0 | 199 movlw .0 |
73 addwfc FSR1H,F | 200 addwfc FSR1H,F |
74 call strcat_text | 201 call strcat_text ; copy label text |
75 return | 202 return |
203 | |
76 | 204 |
77 global gaslist_toggle_type | 205 global gaslist_toggle_type |
78 gaslist_toggle_type: | 206 gaslist_toggle_type: |
79 movf gaslist_gas,W | 207 movf gaslist_gas,W |
80 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | 208 lfsr FSR1,opt_gas_type ; load base address of opt_gas_type |
81 movff PLUSW1,lo ; lo holds gas type | 209 movff PLUSW1,lo ; read gas type |
82 incf lo,F ; 0-3/0-2 | 210 incf lo,F ; increment type |
83 btfsc ccr_diluent_setup ; In CCR setup? | 211 btfsc FLAG_diluent_setup ; in CCR setup? |
84 bra gaslist_toggle_type2 ; Yes | 212 bra gaslist_toggle_type2 ; YES - diluents |
85 btfsc lo,2 ; >3? | 213 btfsc lo,2 ; NO - gases, type index > 3 ? |
86 clrf lo ; Clear to zero | 214 clrf lo ; YES - clear to zero |
87 movff lo,PLUSW1 ; Copy back result | 215 movff lo,PLUSW1 ; - copy back result |
88 return | 216 return |
89 gaslist_toggle_type2: | 217 gaslist_toggle_type2: |
90 movlw .3 | 218 movlw .3 |
91 cpfslt lo ; >2? | 219 cpfslt lo ; index > 2 ? |
92 clrf lo ; Clear to zero | 220 clrf lo ; YES - clear to zero |
93 movf gaslist_gas,W | 221 movf gaslist_gas,W ; restore gaslist_gas in WREG |
94 movff lo,PLUSW1 ; Copy back result | 222 movff lo,PLUSW1 ; copy back result |
95 return | |
96 | |
97 global gaslist_setSP | |
98 gaslist_setSP: | |
99 movff PRODL,gaslist_gas ; 0-4 | |
100 return | 223 return |
101 | 224 |
102 | 225 |
103 global gaslist_strcat_setpoint | 226 global gaslist_strcat_setpoint |
104 global gaslist_strcat_setpoint_0 | 227 global gaslist_strcat_setpoint_0 |
105 gaslist_strcat_setpoint: | 228 gaslist_strcat_setpoint: ; entry point with setpoint index in PRODL |
106 call gaslist_setSP | 229 movff PRODL,gaslist_gas ; get current menu item (0-4) |
107 gaslist_strcat_setpoint_0: | 230 gaslist_strcat_setpoint_0: ; entry point with setpoint index in gaslist_gas |
108 bsf leftbind | 231 bsf leftbind |
109 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | 232 btfsc short_gas_decriptions ; shall use short versions of gaslist_strcat_setpoint? |
110 bra gaslist_strcat_setpoint2 ; Short version | 233 bra gaslist_strcat_setpoint2 ; YES - use short version |
111 STRCAT_TEXT tSP | 234 STRCAT_TEXT tSP ; "SP" |
112 incf gaslist_gas,W | 235 incf gaslist_gas,W ; (0-4) -> (1-5) into WREG |
113 movwf lo | 236 movwf lo |
114 output_8 | 237 output_8 ; print SP number |
115 bcf leftbind | 238 bcf leftbind |
116 PUTC ":" | 239 PUTC ":" |
117 gaslist_strcat_setpoint2: ; Short version | 240 gaslist_strcat_setpoint2: ; short version |
118 btfsc divemode | 241 btfsc divemode |
119 bra gaslist_strcat_setpoint4 ; no "*" in divemode | 242 bra gaslist_strcat_setpoint4 ; no "*" in divemode |
120 movf gaslist_gas,W ; Number-1 into WREG | 243 movf gaslist_gas,W ; (0-4) into WREG |
121 bnz gaslist_strcat_setpoint3 ; Not SP1 | 244 bnz gaslist_strcat_setpoint3 ; SP index = 0 ? |
122 PUTC "*" | 245 PUTC "*" ; YES - print * |
123 bra gaslist_strcat_setpoint4 | 246 bra gaslist_strcat_setpoint4 ; - continue with cbar value |
124 gaslist_strcat_setpoint3: | 247 gaslist_strcat_setpoint3: ; NO |
125 PUTC " " | 248 PUTC " " ; - print a space |
126 gaslist_strcat_setpoint4: | 249 gaslist_strcat_setpoint4: |
127 movf gaslist_gas,W | 250 movf gaslist_gas,W ; (0-4) into WREG |
128 lfsr FSR1,char_I_setpoint_cbar | 251 lfsr FSR1,char_I_setpoint_cbar ; load base address of setpoint cbar values |
129 movf PLUSW1,W | 252 movf PLUSW1,W ; read cbar value |
130 movwf lo | 253 movwf lo |
131 clrf hi | 254 clrf hi |
132 bsf leftbind | 255 bsf leftbind |
133 output_16dp d'3' | 256 output_16dp d'3' ; print as X.XX |
134 btfsc divemode | 257 btfsc divemode ; in divemode? |
135 bra gaslist_strcat_setpoint5 ; Skip text in divemode | 258 bra gaslist_strcat_setpoint5 ; YES - skip text in divemode |
136 STRCAT_TEXT tbar | 259 STRCAT_TEXT tbar ; NO - print "bar" |
137 gaslist_strcat_setpoint5: | 260 gaslist_strcat_setpoint5: |
138 PUTC " " | 261 PUTC " " ; print a space |
139 ; Read switch depth | 262 movf gaslist_gas,W ; (0-4) into WREG |
140 movf gaslist_gas,W | 263 lfsr FSR1,char_I_setpoint_change ; load base address of switch depths |
141 lfsr FSR1,char_I_setpoint_change | 264 movff PLUSW1,lo ; read switch depth into lo |
142 movff PLUSW1,lo | 265 bra gaslist_strcat_depth ; print depth in meters or ft |
143 | 266 |
144 bsf ccr_diluent_setup ; inhibit output of "----" for depth | 267 |
145 call gaslist_strcat_5 | 268 ;---------------------------------------------------------------------------- |
146 bcf ccr_diluent_setup | 269 ; Append gas description to current string |
147 return | 270 ; |
148 | 271 ; Prints gas number, * if first, = if deco gas, gas composition and change depth, |
149 ;---------------------------------------------------------------------------- | 272 ; including fancy color-coding |
150 ; Append gas description to current string. | 273 ; |
151 ; Input: PRODL : gas number (0..4) | 274 ; Input: PRODL gas number (0..4) |
152 ; FSR2 : Current string position. | 275 ; FSR2 current string position |
153 ; Output: Text appended into buffer pointed by FSR2. | 276 ; Output: text appended to buffer pointed by FSR2 |
154 ; | 277 ; |
155 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry. | 278 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry |
156 | 279 |
157 gaslist_strcat_gas_better: ; Yes, check if this is a "better gas" | 280 global gaslist_strcat_gas_cd |
158 bcf win_invert | |
159 movff better_gas_number,WREG ; get better gas number into WREG | |
160 decf WREG,W ; better_gas_number = better_gas_number -1 | |
161 btfsc ccr_diluent_setup ; in CCR menus? | |
162 addlw .5 ; Yes, offset to gases 5-9 | |
163 cpfseq gaslist_gas ; 0-4 for OC/Bailout, 5-9 for Diluents | |
164 return | |
165 call TFT_attention_color ; show in yellow | |
166 bsf win_invert ; And invert | |
167 return | |
168 | |
169 global gaslist_strcat_gas_mod | |
170 gaslist_strcat_gas_mod: | |
171 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents) | |
172 bsf space_gas_decriptions ; add a space in front for gas numbers < 10 for alignment | |
173 ;bra gaslist_gastitle | |
174 | |
175 global gaslist_gastitle | 281 global gaslist_gastitle |
176 gaslist_gastitle: | 282 gaslist_strcat_gas_cd: ; entry point with gas in PRODL (0-4) and usage of FLAG_diluent_setup |
177 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | 283 movff PRODL,gaslist_gas ; get current menu item (0-4) |
178 bra gaslist_gastitle1 ; Short version | 284 movlw .5 ; offset between gases and diluents |
179 STRCAT_TEXT tGas | 285 btfsc FLAG_diluent_setup ; in diluent menus? |
180 incf gaslist_gas,W | 286 addwf gaslist_gas,F ; YES - add the offset |
287 gaslist_gastitle: ; entry point with gas/dil in gaslist_gas (0-4 for gases, 5-9 for diluents) | |
288 bcf win_invert ; clear flag for inverted output by default | |
289 btfsc short_gas_decriptions ; shall use short versions of gaslist_strcat_gas_cd? | |
290 bra gaslist_gastitle1 ; YES - use short version | |
291 incf gaslist_gas,W ; (0-9) -> (1-10) into WREG | |
181 movwf lo | 292 movwf lo |
182 btfss space_gas_decriptions ; add a space in front for gas numbers < 10 for alignment? | 293 movlw .6 ; diluents start with 6 |
183 bra gaslist_gastitle0 ; NO | 294 cpfslt lo ; gas number < 6 ? |
184 bcf space_gas_decriptions ; YES - clear flag again | 295 bra gaslist_gastitle_dil ; NO - it's a diluent |
185 movlw .10 ; load a 10 | 296 STRCAT_TEXT tGas ; YES - it's a gas |
186 cpfslt lo ; gas# < 10 ? | 297 bra gaslist_gastitle0 |
187 bra gaslist_gastitle0 ; NO | 298 gaslist_gastitle_dil: |
188 PUTC " " ; YES - add a space | 299 STRCAT_TEXT tDil |
300 movlw .5 ; offset between gases and diluents | |
301 subwf lo,F ; subtract offset from diluent number (6-10) -> (1-5) | |
189 gaslist_gastitle0: | 302 gaslist_gastitle0: |
190 bsf leftbind | 303 bsf leftbind |
191 output_8 | 304 output_8 ; print gas/dil number (1-5) |
192 bcf leftbind | 305 bcf leftbind |
193 PUTC ":" | 306 PUTC ":" |
194 gaslist_gastitle1: | 307 gaslist_gastitle1: ; short version of gaslist_strcat_gas_cd |
195 lfsr FSR1,opt_gas_type | 308 btfsc divemode ; in divemode? |
196 btfsc divemode | 309 bra gaslist_gastitle3 ; YES - no "*" and "=" in front of gas composition, no highlighting for transmitters paired |
197 bra gaslist_gastitle3 ; no "*" in divemode | 310 |
198 movf gaslist_gas,W | 311 IFDEF _rx_functions |
199 decf PLUSW1,W ; Type-1 into WREG | 312 btfss FLAG_tr_enabled ; NO - TR functions enabled? |
200 bnz gaslist_gastitle2 ; Not "First" | 313 bra gaslist_gastitle2 ; NO - continue with gas type |
201 PUTC "*" | 314 lfsr FSR1,opt_transmitter_id_1 ; YES - load base address of transmitter ID table |
202 bra gaslist_gastitle3 | 315 movf gaslist_gas,W ; - (0-4 for OC/Bailout, 5-9 for Diluents) |
316 rlncf WREG,W ; - index x2 because IDs are 2 byte | |
317 tstfsz PLUSW1 ; - transmitter ID low byte <> 0 ? | |
318 bsf win_invert ; YES - flag transmitter paired by inverting output | |
319 incf WREG,W ; - increment index | |
320 tstfsz PLUSW1 ; - transmitter ID high byte <> 0 ? | |
321 bsf win_invert ; YES - flag transmitter paired by inverting output | |
322 ENDIF | |
323 | |
203 gaslist_gastitle2: | 324 gaslist_gastitle2: |
204 PUTC " " | 325 rcall gaslist_strcat_gas_type ; print "*" for first gas/dil, "=" for a deco gas or " " else |
205 gaslist_gastitle3: | 326 gaslist_gastitle3: |
206 call TFT_standard_color | 327 call TFT_standard_color |
207 btfsc divemode ; In divemode? | 328 btfsc divemode ; in divemode? |
208 rcall gaslist_strcat_gas_better ; Yes, check if this is a "better gas" | 329 rcall gaslist_strcat_gas_better ; YES - check if this is a "better gas" |
209 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) | 330 lfsr FSR1,opt_gas_type ; load base address of gas types |
210 movf PLUSW1,W | 331 movf gaslist_gas,W ; load index into WREG (0-4 for gases, 5-9 for diluents) |
211 bnz gaslist_strcat_3 | 332 movf PLUSW1,W ; read gas/dil type into WREG |
212 call TFT_disabled_color | 333 bnz gaslist_gastitle4 ; type = disabled? NO - keep color |
213 bra gaslist_strcat_4 ; no MOD-check and red color for disabled gases | 334 call TFT_disabled_color ; YES - switch color to disabled |
214 gaslist_strcat_3: | 335 bra gaslist_gastitle5 ; - skip ppO2 check for disabled gases |
215 rcall gaslist_strcat_gas_0 | 336 gaslist_gastitle4: |
216 PUTC " " | 337 btfss divemode ; in divemode? |
217 ; Read switch depth | 338 bra gaslist_gastitle5 ; NO - no ppO2 check if not in divemode |
218 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | 339 lfsr FSR1,opt_gas_O2_ratio ; YES - load base address of opt_gas_O2_ratio |
219 movlw .4 | 340 movf gaslist_gas,W ; - load index into WREG (0-4 for gases, 5-9 for diluents) |
220 cpfsgt gaslist_gas ; >4? (-> Diluents) | 341 movff PLUSW1,hi ; - read O2 ratio into hi |
221 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases | 342 call TFT_color_code_gaslist ; - set color according to ppO2 limits |
222 | 343 gaslist_gastitle5: |
223 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) | 344 movf gaslist_gas,W ; copy gas/dil index to WREG (0-9) |
224 movff PLUSW1,lo | 345 rcall gaslist_strcat_gas_WREG ; print gas composition |
225 rcall gaslist_calc_mod ; Compute MOD into WREG | 346 btfss divemode ; in divemode? |
226 cpfsgt lo ; within MOD range? | 347 bra gaslist_gastitle6 ; NO - continue printing a space |
227 bra gaslist_strcat_5 ; YES | 348 rcall gaslist_strcat_gas_type ; YES - print "*" for first gas/dil, "=" for a deco gas, or a space else |
228 call TFT_warnings_color ; NO - turn red | 349 bra gaslist_gastitle7 ; - continue with change depth |
229 bra gaslist_strcat_5 ; skip gaslist_strcat_gas_0 here | 350 gaslist_gastitle6: |
230 gaslist_strcat_4: | 351 PUTC " " ; print a space |
231 rcall gaslist_strcat_gas_0 | 352 gaslist_gastitle7: |
232 PUTC " " | 353 lfsr FSR1,opt_gas_change ; load base address of change depths |
233 ; Dummy code, needs some cleanup someday... | 354 movf gaslist_gas,W ; load gas/dil index into WREG (0-9) |
234 ; Read switch depth | 355 movff PLUSW1,lo ; read change depth into lo |
235 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | 356 gaslist_strcat_depth: ; entry point for general printing of depths with value in meters in lo |
236 movlw .4 | 357 TSTOSS opt_units ; check depth units |
237 cpfsgt gaslist_gas ; >4? (-> Diluents) | 358 bra gaslist_strcat_depth_metric ; 0 - use Meters |
238 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases | 359 gaslist_strcat_depth_imperial: ; 1 - use Feet |
239 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) | |
240 movff PLUSW1,lo | |
241 rcall gaslist_calc_mod ; Compute MOD into WREG | |
242 gaslist_strcat_5: | |
243 PUTC " " | |
244 TSTOSS opt_units ; 0=Meter, 1=Feet | |
245 bra gaslist_strcat_3_metric | |
246 ;gaslist_strcat_3_imperial: | |
247 btfsc ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") | |
248 bra gaslist_imperial_non_travel | |
249 movf gaslist_gas,W | |
250 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | |
251 movff PLUSW1,up ; up holds gas type | |
252 movlw .2 ; 2=Travel | |
253 cpfseq up ; compare gas type with type 2=Travel | |
254 bra gaslist_imperial_non_travel ; Non-Travel Gas | |
255 bra gaslist_strcat_depth_travel ; Show "---" instead of "0m"... | |
256 gaslist_imperial_non_travel: | |
257 movf lo,W | 360 movf lo,W |
258 mullw .100 ; convert meters to mbar | 361 mullw .100 ; convert meters to mbar |
259 movff PRODL,lo | 362 movff PRODL,lo |
260 movff PRODH,hi | 363 movff PRODH,hi |
261 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | 364 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet |
262 bsf leftbind | 365 ;bsf leftbind |
263 output_16_3 ; limit to 999 and display only (0-999) | 366 output_16_3 ; limit to 999 and display only 0-999 |
264 STRCAT_TEXT tFeets ; "ft" | 367 STRCAT_TEXT tFeets ; append "ft" REMARK: still one char to long for space available in divemode menu! |
265 return | 368 return |
266 gaslist_strcat_3_metric: | 369 gaslist_strcat_depth_metric: |
267 btfsc ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") | 370 PUTC " " ; print a space |
268 bra gaslist_metric_non_travel | |
269 movf gaslist_gas,W | |
270 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | |
271 movff PLUSW1,up ; up holds gas type | |
272 movlw .2 ; 2=Travel | |
273 cpfseq up ; compare gas type with type 2=Travel | |
274 bra gaslist_metric_non_travel ; Non-Travel Gas | |
275 gaslist_strcat_depth_travel: ; Show "---" instead of "0m"... | |
276 STRCAT "---" | |
277 return | |
278 gaslist_metric_non_travel: | |
279 output_99 | 371 output_99 |
280 STRCAT_TEXT tMeters ; "m" | 372 STRCAT_TEXT tMeters ; "m" |
281 return | 373 return |
282 | 374 |
283 ;---------------------------------------------------------------------------- | 375 gaslist_strcat_gas_better: ; color-code output if this is the best gas/diluent |
284 ; Store current menu item, and display gas description later. | 376 btfss better_gas_hint ; shall better gas hints be given? |
285 ; Input: PRODL : gas number (0..4) | 377 return ; NO - return |
286 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry. | 378 movf best_gas_number,W ; get best gas number into WREG |
287 | 379 btfsc FLAG_diluent_setup ; in CCR (pSCR) menus? |
288 global gaslist_setgas | 380 movf best_dil_number,W ; YES - overwrite with best diluent number |
289 gaslist_setgas: | 381 tstfsz WREG ; is a best gas/dil available? |
290 movff PRODL,gaslist_gas | 382 bra gaslist_strcat_gas_better1 ; YES - proceed |
291 movlw .5 | 383 return ; NO - return |
292 btfsc ccr_diluent_setup ; in CCR menus? | 384 gaslist_strcat_gas_better1: |
293 addwf gaslist_gas,F ; Yes, offset to gases 5-9 | 385 decf WREG,W ; (1-5) -> (0-4) |
294 return | 386 btfsc FLAG_diluent_setup ; in diluent menus? |
295 | 387 addlw .5 ; YES - add offset between gases and diluents (0-4) -> (5-9) |
296 | 388 cpfseq gaslist_gas ; compare with given gas/dil (0-4 for OC bailout gases, 5-9 for diluents) |
297 global gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth | 389 return ; not equal - return |
390 bsf win_invert ; equal - invert | |
391 movlw color_green ; - select green color (gas is something "good") | |
392 goto TFT_set_color ; - activate color and return | |
393 | |
394 gaslist_strcat_gas_type: | |
395 lfsr FSR1,opt_gas_type ; load base address of gas types | |
396 movf gaslist_gas,W ; load index to WREG (0-4 for gases, 5-9 for diluents) | |
397 decf PLUSW1,W ; read gas/dil type into WREG and... | |
398 ; ...decrement by 1 (-1 for disabled, 0 for first, 1 for travel/normal, 2 for deco) | |
399 bnz gaslist_strcat_gas_type_1 ; type = first? NO - continue with checking for deco gas | |
400 PUTC "*" ; YES - print "*" for first | |
401 return ; - done | |
402 gaslist_strcat_gas_type_1: | |
403 decf WREG,W ; decrement gas type (-2 for disabled, -1 for first, 0 for travel/normal, 1 for deco) | |
404 decf WREG,W ; decrement gas type (-3 for disabled, -2 for first, -1 for travel/normal, 0 for deco) | |
405 bnz gaslist_strcat_gas_type_2 ; type = deco? NO - neither first nor deco | |
406 PUTC "=" ; YES - print "=" for a deco gas | |
407 return ; - done | |
408 gaslist_strcat_gas_type_2: | |
409 PUTC " " ; neither first nor deco, print a space | |
410 return | |
411 | |
412 ;---------------------------------------------------------------------------- | |
413 ; Housekeeping for the gas/dil settings, e.g. making sure there is one FIRST only | |
414 ; | |
415 ; Input: gaslist_gas last edited gas/dil (0-9) | |
416 | |
417 global gaslist_cleanup_list | |
298 gaslist_cleanup_list: | 418 gaslist_cleanup_list: |
419 lfsr FSR1,opt_gas_type ; load base address of opt_gas_type | |
420 movlw .5 ; offset between gases and diluents | |
421 btfsc FLAG_diluent_setup ; in CCR-Menu? | |
422 subwf gaslist_gas,F ; YES - subtract offset from gaslist_gas: (5-9) -> (0-4) | |
423 gaslist_cleanup_list0: | |
299 bcf ignore_last_edited_gas | 424 bcf ignore_last_edited_gas |
300 movlw .0 | |
301 btfsc ccr_diluent_setup ; In CCR-Menu? | |
302 addlw .5 ; Yes, adjust offset | |
303 subwf gaslist_gas,F | |
304 gaslist_cleanup_list1: | 425 gaslist_cleanup_list1: |
305 clrf lo | 426 clrf lo ; counter for number of "firsts" found |
306 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | 427 movlw .5 ; initialize hi as loop counter for checking 5 gases/diluents |
307 movlw .5 ; Check 5 gases | |
308 movwf hi | 428 movwf hi |
309 gaslist_cleanup_list2: | 429 gaslist_cleanup_list2: ; loop body |
310 decf hi,w ; 0-4 | 430 decf hi,W ; WREG = current gas/dil (0-4) |
311 btfsc ccr_diluent_setup ; In CCR-Menu? | 431 btfsc FLAG_diluent_setup ; in CCR-Menu? |
312 addlw .5 ; Yes, adjust offset | 432 addlw .5 ; YES - add offset from gases to diluents -> (5-9) |
313 movff PLUSW1,WREG ; read gas type | 433 movff PLUSW1,WREG ; read type into WREG |
314 decfsz WREG ; is gas = first (ex 1)? | 434 decfsz WREG ; is type = first (ex type code 1)? |
315 bra gaslist_cleanup_list3 ; NO | 435 bra gaslist_cleanup_list3 ; NO - done with this gas/dil |
316 incf lo,F ; YES - count "first gases" | 436 incf lo,F ; YES - increment number of "firsts" found |
317 btfss ignore_last_edited_gas ; If we are not in the second-pass mode | 437 btfss ignore_last_edited_gas ; - shall we ignore the last edited gas/dil? |
318 bra gaslist_cleanup_list2b | 438 bra gaslist_cleanup_list2b ; NO - continue remembering the "last first" gas/dil (do a shortcut) |
319 decf hi,w ; 0-4 | 439 decf hi,W ; YES - get the current gas/dil as (0-4) |
320 cpfseq gaslist_gas ; Do not disable last edited gas | 440 cpfseq gaslist_gas ; - is this the last edited gas/dil? |
321 gaslist_cleanup_list2b: | 441 gaslist_cleanup_list2b: |
322 movff hi,up ; Keep the last "first gas" found | 442 movff hi,up ; (NO) - remember the last "first gas" found |
323 gaslist_cleanup_list3: | 443 gaslist_cleanup_list3: |
324 decfsz hi,F | 444 decfsz hi,F ; decrement loop counter |
325 bra gaslist_cleanup_list2 ; Loop | 445 bra gaslist_cleanup_list2 ; loop counter became 0 ? NO - loop |
326 tstfsz lo ; No gas active? | 446 tstfsz lo ; YES - any first gas/dil at all? |
327 bra gaslist_cleanup_list4 ; No, at least one is active | 447 bra gaslist_cleanup_list4 ; YES - at least one first gas/dil existing |
328 btfsc ccr_diluent_setup ; In CCR-Menu? | 448 btfsc FLAG_diluent_setup ; NO - in CCR-Menu? |
329 bra gaslist_cleanup_list3a ; Yes. | 449 lfsr FSR1,opt_dil_type ; YES - load base address of opt_gas_type |
330 ; make gas1 first and zero | 450 movlw .1 ; - load coding for first gas |
331 movlw .1 ; First | 451 movwf INDF1 ; - make gas/dil 1 the first gas |
332 movwf up | 452 return ; - done |
333 movwf INDF1 | |
334 bra gaslist_cleanup_list5 ; Set change depth to zero | |
335 gaslist_cleanup_list3a: | |
336 movlw .5 | |
337 addwf FSR1L,F | |
338 movlw .0 | |
339 addwfc FSR1H,F ; Setup to Diluents | |
340 ; make dil1 first and zero | |
341 movlw .1 ; First | |
342 movwf up | |
343 movwf INDF1 | |
344 bra gaslist_cleanup_list5 ; Set change depth to zero | |
345 gaslist_cleanup_list4: | 453 gaslist_cleanup_list4: |
346 movlw .1 | 454 movlw .1 |
347 cpfsgt lo ; More then one "first gas"? | 455 cpfsgt lo ; more then one "first gas" found? |
348 bra gaslist_cleanup_list5 ; No, done. | 456 return ; NO - done |
349 ; More then one Gas is "first gas" | 457 decf up,W ; YES - WREG = last found "first gas" - 1 (0-4) |
350 ; Disable last found "first gas" but keep it's change depth | 458 cpfseq gaslist_gas ; - is this the last edited gas/dil? |
351 decf up,W ; 0-4 | 459 bra gaslist_cleanup_list4b ; NO - disable it |
352 cpfseq gaslist_gas ; Do not disable last edited gas | 460 bsf ignore_last_edited_gas ; YES - do not disable last edited gas, search again but ignore the last edited gas |
353 bra gaslist_cleanup_list4b | 461 bra gaslist_cleanup_list1 ; - loop until only one "first" is left over |
354 ; Do not disable last edited gas | |
355 ; search again but ignore last edited gas | |
356 bsf ignore_last_edited_gas | |
357 bra gaslist_cleanup_list1 ; Loop until only one "first gas" is left | |
358 gaslist_cleanup_list4b: | 462 gaslist_cleanup_list4b: |
359 btfsc ccr_diluent_setup ; In CCR-Menu? | 463 btfsc FLAG_diluent_setup ; in CCR-Menu? |
360 addlw .5 ; Yes, adjust offset | 464 addlw .5 ; YES - adjust offset |
361 clrf PLUSW1 ; Disable gas | 465 clrf PLUSW1 ; disable gas |
362 bra gaslist_cleanup_list ; Loop until only one "first gas" is left | 466 bra gaslist_cleanup_list0 ; redo from start until only one "first" is left over |
363 gaslist_cleanup_list5: | 467 return |
364 ; Read switch depth | 468 |
365 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | 469 ;---------------------------------------------------------------------------- |
366 btfss ccr_diluent_setup ; In CCR-Menu? | 470 ; Tank Settings |
367 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases | 471 ; |
368 decf up,W | 472 ; Inputs: char_I_tank_size size of the tank, using unit text tLiter ("l") |
369 btfsc ccr_diluent_setup ; In CCR-Menu? | 473 ; char_I_tank_pres_fill fill pressure in multiples of 10 bar, using unit text tbar10 ("0 bar") |
370 addlw .5 ; Yes, adjust offset | 474 |
371 clrf PLUSW1 ; Set First gas to zero m | 475 global gaslist_tank_size_pres |
372 return | 476 gaslist_tank_size_pres: ; dynamic title: xx l, xx0 bar |
477 lfsr FSR1,char_I_tank_size ; load base address of char_I_tank_size | |
478 movf gaslist_gas,W ; load index (0-9) | |
479 movff PLUSW1,lo ; read char_I_tank_size[WREG] into lo | |
480 lfsr FSR1,char_I_tank_pres_fill ; load base address of char_I_tank_pres_fill | |
481 movff PLUSW1,hi ; read char_I_tank_pres_fill[WREG] into hi | |
482 STRCAT " " ; print 5 leading spaces for alignment | |
483 output_8 ; print tank size | |
484 STRCAT_TEXT tLiter ; print unit (" l") | |
485 movff hi,lo ; copy fill pressure into lo | |
486 output_8 ; print fill pressure (it is stored in multiples of 10 bar) | |
487 STRCAT_TEXT tbar10 ; print unit ("0 bar") | |
488 return | |
489 | |
490 global gaslist_tank_size | |
491 gaslist_tank_size: ; adjust char_I_tank_size between min_tank_size and max_tank_size | |
492 lfsr FSR1,char_I_tank_size ; load base address of char_I_tank_size | |
493 movf gaslist_gas,W ; load index (0-9) | |
494 movff PLUSW1,lo ; read char_I_tank_size[WREG] into lo | |
495 incf lo,F ; increment tank size by 1 liter | |
496 movlw max_tank_size ; load max. allowed value into WREG | |
497 cpfsgt lo ; tank size <= max value? | |
498 bra gaslist_tank_size_1 ; YES - new value can be used | |
499 movlw min_tank_size ; NO - wrap-around to min value | |
500 movwf lo ; - and write to lo | |
501 gaslist_tank_size_1: | |
502 movf gaslist_gas,W ; re-load index | |
503 movff lo,PLUSW1 ; write back tank size to char_I_tank_size[WREG] | |
504 return | |
505 | |
506 global gaslist_tank_pres | |
507 gaslist_tank_pres: ; adjust char_I_tank_pres_fill between 5(0) and 29(0) bar | |
508 lfsr FSR1,char_I_tank_pres_fill ; load base address of char_I_tank_pres_fill | |
509 movf gaslist_gas,W ; load index (0-9) | |
510 movff PLUSW1,lo ; read char_I_tank_pres_fill[WREG] into lo | |
511 incf lo,F ; increment fill press by by 1(0) bar | |
512 movlw max_fill_press ; load max. allowed value into WREG | |
513 cpfsgt lo ; press <= max value? | |
514 bra gaslist_tank_pres_1 ; YES - new value can be used | |
515 movlw min_fill_press ; NO - wrap-around to min value | |
516 movwf lo ; - and write to lo | |
517 gaslist_tank_pres_1: | |
518 movf gaslist_gas,W ; re-load index | |
519 movff lo,PLUSW1 ; write back tank size to char_I_tank_pres_fill[WREG] | |
520 return | |
521 | |
522 ;---------------------------------------------------------------------------- | |
523 ; Transmitter functions | |
524 | |
525 IFDEF _rx_functions | |
526 | |
527 global gaslist_tank_id_pres | |
528 gaslist_tank_id_pres: ; dynamic title: shows ID and pressure from transmitter with ID opt_transmitter_id[gaslist_gas] | |
529 ; When changing layout, adapt output position TFT_menu_tank_pres! | |
530 STRCAT " ID: " ; print header | |
531 ; get ID ; | |
532 lfsr FSR1,opt_transmitter_id_1 ; load base address of opt_transmitter_id | |
533 movf gaslist_gas,W ; load index (0-9) | |
534 rlncf WREG,W ; multiply by 2 because IDs are 2 byte in size | |
535 movff PLUSW1,lo ; copy opt_transmitter_id+0[gaslist_gas] to lo | |
536 incf WREG,W ; increment index | |
537 movff PLUSW1,hi ; copy opt_transmitter_id+1[gaslist_gas] to hi | |
538 ; check if a transmitter is paired to this tank | |
539 tstfsz hi ; high byte of ID <> 0 ? | |
540 bra gaslist_tank_id_pres_1 ; YES - a transmitter is paired to the tank | |
541 tstfsz lo ; low byte of ID <> 0 ? | |
542 bra gaslist_tank_id_pres_1 ; YES - a transmitter is paired to the tank | |
543 ; no transmitter paired | |
544 STRCAT "----" ; | |
545 bcf menu_update_tank_pres ; stop imprinting of tank pressure updates | |
546 return | |
547 gaslist_tank_id_pres_1: | |
548 ; show ID | |
549 movf hi,W ; copy high byte of ID to WREG | |
550 output_hex ; print it | |
551 movf lo,W ; copy low byte of ID to WREG | |
552 output_hex ; print it | |
553 bsf menu_update_tank_pres ; start imprinting of tank pressure updates | |
554 return | |
555 | |
556 | |
557 global gaslist_tank_pairing | |
558 gaslist_tank_pairing: | |
559 incf pairing_slot,F ; goto next RX data slot | |
560 btfsc pairing_slot,3 ; slot = 8? | |
561 bra gaslist_tank_pairing_none ; YES - offer unpairing | |
562 movf pairing_slot,W ; NO - copy slot to WREG | |
563 call get_transmitter_id_by_slot ; WREG = slot (0-7) -> hi:lo = transmitter ID | |
564 tstfsz hi ; transmitter found (probe on high byte)? | |
565 bra gaslist_tank_pairing_common ; YES - select this transmitter | |
566 tstfsz hi ; transmitter found (probe on low byte)? | |
567 bra gaslist_tank_pairing_common ; YES - select this transmitter | |
568 bra gaslist_tank_pairing ; NO - try next slot | |
569 gaslist_tank_pairing_common: | |
570 lfsr FSR1,opt_transmitter_id_1 ; load base address of opt_transmitter_id | |
571 movf gaslist_gas,W ; load index into WREG (0-9) | |
572 rlncf WREG,W ; multiply by 2 because IDs are 2 byte in size | |
573 movff lo,PLUSW1 ; copy lo to opt_transmitter_id+0[gaslist_gas] | |
574 incf WREG,W ; increment index | |
575 movff hi,PLUSW1 ; copy hi to opt_transmitter_id+1[gaslist_gas] | |
576 return ; done | |
577 gaslist_tank_pairing_none: | |
578 setf pairing_slot ; prime slot number with 255 aka -1 | |
579 clrf hi ; adjust "no transmitter" ID | |
580 clrf lo ; adjust "no transmitter" ID | |
581 bra gaslist_tank_pairing_common ; continue with common part | |
582 | |
583 ENDIF | |
373 | 584 |
374 ;---------------------------------------------------------------------------- | 585 ;---------------------------------------------------------------------------- |
375 ; Increment/Decrement O2 ratio | 586 ; Increment/Decrement O2 ratio |
376 | 587 |
377 global gaslist_pO2 | 588 global gaslist_pO2 |
378 gaslist_pO2: | 589 gaslist_pO2: |
379 movf gaslist_gas,W | 590 movf gaslist_gas,W ; load index (0-9) |
380 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | 591 lfsr FSR1,opt_gas_He_ratio ; load base address of opt_gas_He_ratio |
381 movff PLUSW1,hi ; hi holds He ratio | 592 movff PLUSW1,hi ; read He ratio into hi |
382 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | 593 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio |
383 movff PLUSW1,lo ; lo holds O2 ratio | 594 movff PLUSW1,lo ; read O2 ratio into lo |
384 | 595 |
385 incf lo,F ; O2++ | 596 incf lo,F ; O2++ |
386 movf hi,W ; get He ratio into WREG | 597 movf hi,W ; get He ratio into WREG |
387 addwf lo,W ; add O2 ratio to WREG | 598 addwf lo,W ; add O2 ratio to WREG |
388 movwf up ; move sum He + O2 to up | 599 movwf up ; move sum He + O2 to up |
389 movlw .101 ; | 600 movlw .101 ; |
390 cpfslt up ; O2 + He < 101? | 601 cpfslt up ; O2 + He < 101? |
391 decf lo,F ; O2-- (revoke ++) | 602 decf lo,F ; O2-- (revoke ++) |
392 movf gaslist_gas,W | 603 movf gaslist_gas,W ; re-load index |
393 movff lo,PLUSW1 ; write back O2 ratio to opt_gas_O2_ratio[WREG] | 604 movff lo,PLUSW1 ; write back O2 ratio to opt_gas_O2_ratio[WREG] |
394 return | 605 return |
395 | 606 |
396 global gaslist_mO2 | 607 global gaslist_mO2 |
397 gaslist_mO2: | 608 gaslist_mO2: |
398 movf gaslist_gas,W | 609 movf gaslist_gas,W ; load index (0-9) |
399 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | 610 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio |
400 movff PLUSW1,lo ; lo holds O2 ratio | 611 movff PLUSW1,lo ; read O2 ratio into lo |
401 | 612 |
402 decf lo,F ; O2-- | 613 decf lo,F ; O2-- |
403 movlw gaslist_min_o2 ; get minimum allowed O2 ratio | 614 movlw gaslist_min_o2 ; get minimum allowed O2 ratio |
404 cpfslt lo ; current O2 ratio below allowed minimum? | 615 cpfslt lo ; current O2 ratio below allowed minimum? |
405 bra gaslist_mO2_1 ; NO | 616 bra gaslist_mO2_1 ; NO |
406 movlw gaslist_min_o2 ; YES - load minimum | 617 movwf lo ; YES - copy minimum O2 ratio to lo |
407 movwf lo ; write minimum to current O2 ratio | |
408 gaslist_mO2_1: | 618 gaslist_mO2_1: |
409 movf gaslist_gas,W | 619 movf gaslist_gas,W ; re-load index |
410 movff lo,PLUSW1 ; write back O2 ratio to opt_gas_O2_ratio[WREG] | 620 movff lo,PLUSW1 ; write back O2 ratio to opt_gas_O2_ratio[WREG] |
411 return | 621 return |
412 | 622 |
413 ;---------------------------------------------------------------------------- | 623 ;---------------------------------------------------------------------------- |
414 ; Increment/Decrement He ratio | 624 ; Increment/Decrement He ratio |
415 | 625 |
416 global gaslist_pHe | 626 global gaslist_pHe |
417 gaslist_pHe: | 627 gaslist_pHe: |
418 movf gaslist_gas,W | 628 movf gaslist_gas,W ; load index (0-9) |
419 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | 629 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio |
420 movff PLUSW1,lo ; lo holds O2 ratio | 630 movff PLUSW1,lo ; read O2 ratio into lo |
421 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | 631 lfsr FSR1,opt_gas_He_ratio ; load base address of opt_gas_He_ratio |
422 movff PLUSW1,hi ; hi holds He ratio | 632 movff PLUSW1,hi ; read He ratio into hi |
423 | 633 |
424 incf hi,F ; He++ | 634 incf hi,F ; He++ |
425 movf hi,W ; get He ratio into WREG | 635 movf hi,W ; get He ratio into WREG |
426 addwf lo,W ; add O2 ratio to WREG | 636 addwf lo,W ; add O2 ratio to WREG |
427 movwf up ; move sum He + O2 to up | 637 movwf up ; move sum He + O2 to up |
428 movlw .101 ; | 638 movlw .101 ; |
429 cpfslt up ; O2 + He < 101? | 639 cpfslt up ; O2 + He < 101? |
430 decf hi,F ; He-- (revoke ++) | 640 decf hi,F ; He-- (revoke ++) |
431 movf gaslist_gas,W | 641 movf gaslist_gas,W ; re-load index |
432 movff hi,PLUSW1 ; write back He ratio to opt_gas_He_ratio[WREG] | 642 movff hi,PLUSW1 ; write back He ratio to opt_gas_He_ratio[WREG] |
433 return | 643 return |
434 | 644 |
435 global gaslist_mHe | 645 global gaslist_mHe |
436 gaslist_mHe: | 646 gaslist_mHe: |
437 movf gaslist_gas,W | 647 movf gaslist_gas,W ; load index (0-9) |
438 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | 648 lfsr FSR1,opt_gas_He_ratio ; load base address of opt_gas_He_ratio |
439 movff PLUSW1,hi ; hi holds He ratio | 649 movff PLUSW1,hi ; read He ratio into hi |
440 | 650 |
441 decf hi,F ; He-- | 651 decf hi,F ; He-- |
442 bnn gaslist_mHe_1 ; He ratio negative? | 652 bnn gaslist_mHe_1 ; He ratio negative? |
443 clrf hi ; YES - set He to 0 | 653 clrf hi ; YES - set He ratio to 0 |
444 gaslist_mHe_1: | 654 gaslist_mHe_1: |
445 movf gaslist_gas,W | 655 movf gaslist_gas,W ; re-load index |
446 movff hi,PLUSW1 ; write back He ratio to opt_gas_He_ratio[WREG] | 656 movff hi,PLUSW1 ; write back He ratio to opt_gas_He_ratio[WREG] |
447 return | 657 return |
448 | 658 |
449 ;---------------------------------------------------------------------------- | 659 ;---------------------------------------------------------------------------- |
450 ; Increment/Decrement switch depth | 660 ; Increment/Decrement switch depth |
451 | 661 |
452 global gaslist_pDepth | 662 global gaslist_pDepth |
453 gaslist_pDepth: | 663 gaslist_pDepth: |
454 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | 664 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change |
455 movlw .4 | 665 movf gaslist_gas,W ; load index (0-4) |
456 cpfsgt gaslist_gas ; >4? (-> Diluents) | 666 movff PLUSW1,lo ; read switch depth into lo |
457 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases | 667 incf lo,F ; increment switch depth |
458 movf gaslist_gas,W | 668 movlw gaslist_max_change_depth ; get max change depth |
459 movff PLUSW1,lo ; Read char_I_deco_gas_change[WREG] | 669 cpfsgt lo ; above max change depth? |
460 incf lo,F | 670 bra gaslist_pDepth_1 ; NO |
461 movlw gaslist_max_change_depth | 671 movwf lo ; YES - revert to max change depth |
462 cpfsgt lo | |
463 bra gaslist_pDepth_1 | |
464 movlw gaslist_max_change_depth | |
465 movwf lo | |
466 gaslist_pDepth_1: | 672 gaslist_pDepth_1: |
467 movf gaslist_gas,W | 673 movf gaslist_gas,W ; re-load index |
468 movff lo,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] | 674 movff lo,PLUSW1 ; write back switch depth |
469 return | 675 return |
470 | 676 |
471 global gaslist_mDepth | 677 global gaslist_mDepth |
472 gaslist_mDepth: | 678 gaslist_mDepth: |
473 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | 679 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change |
474 movlw .4 | 680 movf gaslist_gas,W ; load index (0-4) |
475 cpfsgt gaslist_gas ; >4? (-> Diluents) | 681 movff PLUSW1,lo ; read switch depth into lo |
476 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases | 682 decf lo,F ; decrement switch depth |
477 | 683 btfsc STATUS,N ; did depth became negative? |
478 movf gaslist_gas,W | 684 clrf lo ; YES - reset to zero |
479 movff PLUSW1,lo ; Read char_I_deco_gas_change[WREG] | 685 movff lo,PLUSW1 ; write back switch depth |
480 | |
481 decf lo,F | |
482 btfsc STATUS,N | |
483 clrf lo | |
484 | |
485 movf gaslist_gas,W | |
486 movff lo,PLUSW1 ; And write back to char_I_deco_gas_change[WREG] | |
487 return | 686 return |
488 | 687 |
489 global gaslist_spplus | 688 global gaslist_spplus |
490 gaslist_spplus: | 689 gaslist_spplus: |
491 movf gaslist_gas,W | 690 movf gaslist_gas,W |
492 lfsr FSR1,char_I_setpoint_cbar | 691 lfsr FSR1,char_I_setpoint_cbar |
493 movff PLUSW1,lo ; Read char_I_setpoint_cbar[WREG] | 692 movff PLUSW1,lo ; read setpoint |
494 movlw gaslist_sp_stepsize | 693 movlw gaslist_sp_stepsize |
495 addwf lo,F | 694 addwf lo,F |
496 movlw gaslist_sp_max | 695 movlw gaslist_sp_max |
497 cpfsgt lo | 696 cpfsgt lo |
498 bra gaslist_spplus2 | 697 bra gaslist_spplus2 |
499 movlw gaslist_sp_min | 698 movlw gaslist_sp_min |
500 movwf lo | 699 movwf lo |
501 gaslist_spplus2: | 700 gaslist_spplus2: |
502 movf gaslist_gas,W | 701 movf gaslist_gas,W |
503 movff lo,PLUSW1 ; Write back to char_I_setpoint_cbar | 702 movff lo,PLUSW1 ; write back setpoint |
504 return | 703 return |
505 | 704 |
506 global gaslist_spdepthplus | 705 global gaslist_spdepthplus |
507 gaslist_spdepthplus: | 706 gaslist_spdepthplus: |
508 movf gaslist_gas,W | 707 movf gaslist_gas,W ; get setpoint number (0-4) |
509 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m | 708 bz gaslist_spdepthplus2 ; setpoint number = 0? YES - force depth to always be 0m |
510 lfsr FSR1,char_I_setpoint_change | 709 lfsr FSR1,char_I_setpoint_change ; load base address of char_I_setpoint_change |
511 movff PLUSW1,lo ; Read char_I_deco_gas_change[WREG] | 710 movff PLUSW1,lo ; read setpoint depth into lo |
512 incf lo,F | 711 incf lo,F ; increment depth |
513 movlw gaslist_max_change_depth | 712 movlw gaslist_max_change_depth ; get max. depth |
514 cpfsgt lo | 713 cpfsgt lo ; switch depth > max. depth? |
515 bra gaslist_spdepthplus_1 | 714 bra gaslist_spdepthplus_1 ; NO |
516 movlw gaslist_max_change_depth | 715 movwf lo ; YES - copy to lo |
517 movwf lo | |
518 gaslist_spdepthplus_1: | 716 gaslist_spdepthplus_1: |
519 movf gaslist_gas,W | 717 movf gaslist_gas,W ; re-load index |
520 movff lo,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] | 718 movff lo,PLUSW1 ; write back setpoint depth |
521 return | |
522 | |
523 gaslist_spdepthplus3: | |
524 movlw .0 | |
525 movff WREG,char_I_setpoint_change+0 ; Reset to 0m | |
526 return | 719 return |
527 | 720 |
528 global gaslist_spdepthminus | 721 global gaslist_spdepthminus |
529 gaslist_spdepthminus: | 722 gaslist_spdepthminus: |
530 movf gaslist_gas,W | 723 movf gaslist_gas,W ; get setpoint number (0-4) |
531 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m | 724 bz gaslist_spdepthminus2 ; setpoint number = 0? YES - force depth to always be 0m |
532 lfsr FSR1,char_I_setpoint_change | 725 lfsr FSR1,char_I_setpoint_change ; load base address of char_I_setpoint_change |
533 movff PLUSW1,lo ; Read char_I_deco_gas_change[WREG] | 726 movff PLUSW1,lo ; read setpoint depth into lo |
534 decf lo,F | 727 decf lo,F ; decrement switch depth |
535 btfsc STATUS,N | 728 btfsc STATUS,N ; did depth became negative? |
536 clrf lo | 729 clrf lo ; YES - reset to zero |
537 movf gaslist_gas,W | 730 movff lo,PLUSW1 ; write back setpoint depth |
538 movff lo,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] | 731 return |
539 return | 732 |
540 | 733 gaslist_spdepthplus2: |
541 ;---------------------------------------------------------------------------- | 734 gaslist_spdepthminus2: |
542 ; Compute MOD from char_I_ppO2_max/char_I_ppO2_max_deco and current O2 Ratio. | 735 movlw .0 |
736 movff WREG,char_I_setpoint_change+0 ; hard reset to 0m | |
737 return | |
738 | |
739 | |
740 ;---------------------------------------------------------------------------- | |
741 ; Compute MOD from char_I_ppO2_max/char_I_ppO2_max_deco and current O2 ratio | |
543 ; | 742 ; |
544 ; Input: gaslist_gas = current gas index. | 743 ; Input: gaslist_gas = current gas index. |
545 ; opt_gas_O2_ratio[gaslist_gas] = current O2 ratio | 744 ; opt_gas_O2_ratio[gaslist_gas] = current O2 ratio |
546 ; Output: WREG = MOD [m] | 745 ; Output: WREG = MOD [m] |
547 ; | 746 ; |
548 gaslist_calc_mod: | 747 gaslist_calc_mod: |
549 movf gaslist_gas,W ; get gas number (0...5) | 748 movf gaslist_gas,W ; load index (0...9) |
550 lfsr FSR1,opt_gas_O2_ratio ; read opt_gas_O2_ratio[WREG] | 749 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio |
551 movf PLUSW1,W | 750 movff PLUSW1,xB+0 ; read O2 ratio into xB+0 |
552 | 751 lfsr FSR1,opt_gas_type ; load base address of opt_gas_type |
553 btfsc divemode ; in divemode? | 752 movff PLUSW1,xA+0 ; read gas/dil type into xA+0 (used as temp here) |
554 bra gaslist_calc_mod_divemode ; YES | 753 movff char_I_ppO2_max_deco,xB+1 ; get max ppO2 for deco into xB+1 (used as temp here) |
555 | 754 movlw .3 ; type code for deco gases |
556 ; Pamb max = ppO2 Max / O2 ratio | 755 cpfseq xA+0 ; is it a deco gas? |
557 movwf xB+0 | 756 movff char_I_ppO2_max,xB+1 ; NO - overwrite ppO2 max with none-deco max |
558 | 757 movf xB+1,W ; copy resulting ppO2 max into WREG |
559 movf gaslist_gas,W ; get gas number (0...5) | 758 clrf xB+1 ; clear xB+1 for div16x16 operation |
560 lfsr FSR1,opt_gas_type ; 0=Disabled, 1=First, 2=Travel, 3=Deco for OC gases and 0=Disabled, 1=First, 2=Normal for diluents | 759 mullw .10 ; multiply ppO2 max value with 10 |
561 movff PLUSW1,xA+0 ; xA+0 used as temp here -> holds type | 760 movff PRODL,xA+0 ; copy result to xA |
562 | |
563 movff char_I_ppO2_max_deco,xB+1 ; xB+1 used as temp here | |
564 movlw .3 | |
565 cpfseq xA+0 ; Deco? | |
566 movff char_I_ppO2_max,xB+1 ; No, overwrite with travel/bottom max | |
567 movf xB+1,W ; Result in WREG | |
568 | |
569 clrf xB+1 ; Clear for div16x16 | |
570 mullw .10 | |
571 movff PRODL,xA+0 | |
572 movff PRODH,xA+1 | 761 movff PRODH,xA+1 |
573 call div16x16 | 762 call div16x16 ; xC = xA / xB with xA as remainder |
574 | 763 movf xC+0,W ; copy result to WREG |
575 ; Prof = Pamb - 1 bar | 764 addlw -.10 ; subtract 10 cbar |
576 movf xC+0,W | 765 return ; return with final result in WREG |
577 addlw -.10 | |
578 return | |
579 | |
580 gaslist_calc_mod_divemode: | |
581 movwf hi ; Copy O2% | |
582 call TFT_color_code_gaslist ; Color-code current row in Gaslist (%O2 in hi), char_I_ppO2_max/char_I_ppO2_max_deco as threshold | |
583 return | |
584 | 766 |
585 ;---------------------------------------------------------------------------- | 767 ;---------------------------------------------------------------------------- |
586 | 768 |
587 global gaslist_ppo2 | 769 global gaslist_ppo2 |
588 gaslist_ppo2: | 770 gaslist_ppo2: |
589 STRCAT_TEXT tppO2 ; ppO2: | 771 STRCAT_TEXT tppO2 ; ppO2: |
590 movf gaslist_gas,W | 772 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change |
591 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents | 773 movf gaslist_gas,W ; load index (0-9) |
592 btfss ccr_diluent_setup ; In CCR-Menu? | 774 movf PLUSW1,W ; read change depth into WREG |
593 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC/Bailout Gases | 775 mullw .10 ; PROD = depth in mbar/10 (100 = 1.00 bar) |
594 movf PLUSW1,W | 776 movlw .100 ; add 1 bar |
595 mullw .10 ; PROD=Depth in mbar/10 (100 = 1.00 bar) | |
596 movlw .100 | |
597 addwf PRODL,F | 777 addwf PRODL,F |
598 movlw .0 | 778 movlw .0 |
599 addwfc PRODH,F ; add 1bar | 779 addwfc PRODH,F |
600 movff PRODL,xA+0 | 780 movff PRODL,xA+0 ; copy result to xA |
601 movff PRODH,xA+1 | 781 movff PRODH,xA+1 |
602 movf gaslist_gas,W ; Read current gas O2 ratio | 782 lfsr FSR1,opt_gas_O2_ratio ; load base address of opt_gas_O2_ratio |
603 lfsr FSR1,opt_dil_O2_ratio-.5 ; Read dil_gas_O2_ratio[WREG] | 783 movf gaslist_gas,W ; load index (0-9) |
604 btfss ccr_diluent_setup ; In CCR-Menu? | 784 movff PLUSW1,xB+0 ; read O2 ratio into xB+0 |
605 lfsr FSR1,opt_gas_O2_ratio ; No, read opt_gas_O2_ratio[WREG] | 785 clrf xB+1 ; clear xB+1 |
606 movff PLUSW1,xB+0 | 786 call mult16x16 ; calculate char_I_O2_ratio * (p_amb/10) |
607 clrf xB+1 | 787 movff xC+0,xA+0 ; copy result to xA |
608 call mult16x16 ; char_I_O2_ratio * (p_amb/10) | |
609 movff xC+0,xA+0 | |
610 movff xC+1,xA+1 | 788 movff xC+1,xA+1 |
611 movlw d'100' | 789 movlw d'100' ; load 100 to xB |
612 movwf xB+0 | 790 movwf xB+0 |
613 clrf xB+1 | 791 clrf xB+1 |
614 call div16x16 ; xC=(char_I_O2_ratio * p_amb/10)/100 | 792 call div16x16 ; xC = xA / xB = (char_I_O2_ratio * p_amb/10)/100 |
615 ; Check very high ppO2 manually | 793 ; check for very high ppO2 |
616 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? | 794 tstfsz xC+2 ; xC+2 remains from mult16x16, xC+2 > 0 (-> ppO2 is > 6.55 bar) ? |
617 bra gaslist_ppo2_2 ; Yes, display fixed Value! | 795 bra gaslist_ppo2_1 ; YES - display a fixed max value |
618 movff xC+0,lo | 796 movff xC+0,lo ; copy result to lo, hi |
619 movff xC+1,hi | 797 movff xC+1,hi |
620 bcf ignore_digit4 | 798 bcf ignore_digit4 |
621 bsf leftbind | 799 bsf leftbind |
622 output_16dp d'3' ; x.xx | 800 output_16dp d'3' ; print ppO2 as x.xx |
623 STRCAT_TEXT tbar ; bar | 801 STRCAT_TEXT tbar ; print "bar" |
624 return | 802 return |
625 gaslist_ppo2_2: | 803 gaslist_ppo2_1: |
626 STRCAT ">6.6" | 804 STRCAT ">6.6" |
627 return | 805 return |
628 | 806 |
629 global gaslist_MOD_END | 807 global gaslist_MOD_END |
630 gaslist_MOD_END: | 808 gaslist_MOD_END: |
631 rcall gaslist_calc_mod ; Compute MOD into WREG | 809 STRCAT_TEXT tMOD ; print "MOD:" |
632 movwf lo ; Copy to lo | 810 rcall gaslist_calc_mod ; compute MOD into WREG |
633 STRCAT_TEXT tMOD ; MOD: | 811 movwf lo ; copy result to lo |
634 TSTOSS opt_units ; 0=Meters, 1=Feets | 812 call gaslist_strcat_depth ; print depth in meters or feet as configured |
635 bra gaslist_MOD_metric | 813 PUTC "/" ; print "/" |
636 ;gaslist_MOD_imperial: | 814 STRCAT_TEXT tEND ; print "END:" |
637 movf lo,W | 815 rcall gaslist_calc_mod ; compute MOD into WREG |
638 mullw .100 ; convert meters to mbar | 816 addlw .10 ; compute MOD = MOD + 10m |
639 movff PRODL,lo | |
640 movff PRODH,hi | |
641 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
642 bsf leftbind | |
643 output_16_3 ; limit to 999 and display only (0-999) | |
644 STRCAT_TEXT tFeets ; "ft" | |
645 bra gaslist_MOD_common | |
646 gaslist_MOD_metric: | |
647 output_8 | |
648 STRCAT_TEXT tMeters ; m | |
649 gaslist_MOD_common: | |
650 PUTC "/" | |
651 STRCAT_TEXT tEND ; END: | |
652 rcall gaslist_calc_mod ; Output: WREG = MOD [m] | |
653 addlw .10 ; MOD=MOD+10m | |
654 movwf xB+0 | 817 movwf xB+0 |
655 clrf xB+1 | 818 clrf xB+1 |
656 movlw d'100' | 819 movlw d'100' |
657 movwf xA+0 | 820 movwf xA+0 |
658 movf gaslist_gas,W ; get gas number (0...5) | 821 lfsr FSR1,opt_gas_He_ratio ; load base address of opt_gas_He_ratio |
659 lfsr FSR1,opt_gas_He_ratio ; read opt_gas_O2_ratio[WREG] | 822 movf gaslist_gas,W ; load index (0...9) |
660 movf PLUSW1,W ; He value in % | 823 movf PLUSW1,W ; read He ration into WREG |
661 subwf xA+0,F ; xA+0 = 100 - He Value in % | 824 subwf xA+0,F ; xA+0 = 100 - He ratio in % |
662 clrf xA+1 | 825 clrf xA+1 |
663 call mult16x16 ; xA*xB=xC | 826 call mult16x16 ; xA*xB=xC |
664 movff xC+0,xA+0 | 827 movff xC+0,xA+0 |
665 movff xC+1,xA+1 | 828 movff xC+1,xA+1 |
666 movlw d'100' | 829 movlw d'100' |
667 movwf xB+0 | 830 movwf xB+0 |
668 clrf xB+1 | 831 clrf xB+1 |
669 call div16x16 ; xA/xB=xC with xA as remainder | 832 call div16x16 ; xC = xA / xB with xA as remainder |
670 ; ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100 | 833 ; ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100 |
671 movlw d'10' | 834 movlw d'10' ; subtract 10 m |
672 subwf xC+0,F ; Subtract 10m... | 835 subwf xC+0,F ; ... |
673 movff xC+0,lo | 836 movff xC+0,lo ; copy result to lo |
674 ;; END 8Bit only | 837 bra gaslist_strcat_depth ; print depth in meters or feet as configured and return |
675 ;movlw d'0' | 838 |
676 ;subwfb xC+1,F | 839 |
677 ;movff xC+1,hi | |
678 TSTOSS opt_units ; 0=Meter, 1=Feet | |
679 bra gaslist_END_metric | |
680 ;gaslist_END_imperial: | |
681 movf lo,W | |
682 mullw .100 ; convert meters to mbar | |
683 movff PRODL,lo | |
684 movff PRODH,hi | |
685 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
686 bsf leftbind | |
687 output_16_3 ; limit to 999 and display only (0-999) | |
688 STRCAT_TEXT tFeets ; "ft" | |
689 return | |
690 gaslist_END_metric: | |
691 output_8 | |
692 STRCAT_TEXT tMeters ; m | |
693 return | |
694 | |
695 ;---------------------------------------------------------------------------- | |
696 global gaslist_reset_mod_title | 840 global gaslist_reset_mod_title |
697 gaslist_reset_mod_title: | 841 gaslist_reset_mod_title: |
698 STRCAT_TEXT tDepthReset | 842 STRCAT_TEXT tDepthReset |
699 | 843 rcall gaslist_calc_mod ; compute MOD into WREG |
700 gaslist_reset_mod_title2: | 844 movwf lo ; copy result to lo |
701 rcall gaslist_calc_mod ; Compute MOD into WREG | 845 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change |
702 movwf lo ; Copy to lo | 846 movf gaslist_gas,W ; load index (0-9) |
703 | 847 movf PLUSW1,W ; read change depth into WREG |
704 movf gaslist_gas,W ; Compare to switch depth | 848 cpfslt lo ; change depth > MOD ? |
705 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents | 849 bra gaslist_strcat_depth ; NO - return |
706 btfss ccr_diluent_setup ; In CCR-Menu? | 850 call TFT_warnings_color ; YES - use red color |
707 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases | 851 bra gaslist_strcat_depth ; - return |
708 movf PLUSW1,W | 852 |
709 cpfslt lo | 853 |
710 bra gaslist_strcat_5 ; and return... | |
711 call TFT_warnings_color ; turn red if bigger ! | |
712 bra gaslist_strcat_5 ; and return... | |
713 | |
714 ;---------------------------------------------------------------------------- | |
715 global gaslist_reset_mod | 854 global gaslist_reset_mod |
716 gaslist_reset_mod: | 855 gaslist_reset_mod: |
717 rcall gaslist_calc_mod ; Compute MOD, it is returned in WREG | 856 rcall gaslist_calc_mod ; compute MOD into WREG |
718 movwf lo ; buffer MOD to lo | 857 movwf lo ; copy result to lo |
719 movf gaslist_gas,W ; Read current gas O2 ratio | 858 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change |
720 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents | 859 movf gaslist_gas,W ; load index (0-9) |
721 btfss ccr_diluent_setup ; In CCR-Menu? | |
722 lfsr FSR1,opt_OC_bail_gas_change ; NO - setup OC Gases | |
723 movff lo,PLUSW1 ; write back new change depth | 860 movff lo,PLUSW1 ; write back new change depth |
724 return | 861 return |
862 | |
725 ;---------------------------------------------------------------------------- | 863 ;---------------------------------------------------------------------------- |
726 END | 864 END |