Mercurial > public > hwos_code
comparison src/gaslist.asm @ 582:b455b31ce022
work on 2.97 stable
author | heinrichsweikamp |
---|---|
date | Mon, 26 Feb 2018 16:40:28 +0100 |
parents | b7eb98dbd800 |
children | ca4556fb60b9 |
comparison
equal
deleted
inserted
replaced
581:f5de1ff88814 | 582:b455b31ce022 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File gaslist.asm ## V2.95 | 3 ; File gaslist.asm ## V2.98 |
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 | 18 #include "shared_definitions.h" |
19 #include "shared_definitions.h" | 19 |
20 | 20 extern convert_mbar_to_feet |
21 CBLOCK tmp+0x40 ; Keep space for menu processor | 21 extern customview_show_mix |
22 gaslist_gas ; Check ram position in menu_tree.asm, too! | 22 extern tGasDisabled |
23 gaslist_O2 | 23 extern tDilDisabled |
24 gaslist_He | 24 extern tbar |
25 gaslist_depth | 25 |
26 gaslist_Type | 26 gui CODE |
27 ; Reserved to tmp+0x5F | 27 |
28 ENDC | |
29 | |
30 extern convert_mbar_to_feet | |
31 | |
32 gui CODE | |
33 ;============================================================================= | 28 ;============================================================================= |
34 ; Append gas description to current string. | 29 ; Append gas description to current string. |
35 ; Input: PRODL : gas number (0..4) | 30 ; Input: PRODL : gas number (0..4) |
36 ; FSR2 : Current string position. | 31 ; FSR2 : Current string position. |
37 ; Output: Text appended into buffer pointed by FSR2. | 32 ; Output: Text appended into buffer pointed by FSR2. |
38 extern customview_show_mix | 33 |
39 global gaslist_strcat_gas | 34 global gaslist_strcat_gas |
40 gaslist_strcat_gas: | 35 gaslist_strcat_gas: |
41 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents) | 36 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents) |
42 ; Retrieve gas definition: | 37 ; Retrieve gas definition: |
43 gaslist_strcat_gas_0: | 38 gaslist_strcat_gas_0: |
44 movf gaslist_gas,W | 39 movf gaslist_gas,W |
45 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | 40 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] |
46 movff PLUSW1,gaslist_O2 | 41 movff PLUSW1,lo ; O2 ratio |
47 movf gaslist_gas,W | 42 ;movf gaslist_gas,W |
48 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | 43 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] |
49 movff PLUSW1,gaslist_He | 44 movff PLUSW1,hi ; He ratio |
50 | 45 goto customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and RETURN |
51 movff gaslist_O2,lo | |
52 movff gaslist_He,hi | |
53 goto customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and RETURN | |
54 | |
55 | |
56 | 46 |
57 ;============================================================================= | 47 ;============================================================================= |
58 ; Append current mix to current string (For divemode) | 48 ; Append current mix to current string (For divemode) |
59 ; Input: FSR2 : Current string position. | 49 ; Input: FSR2 : Current string position. |
60 ; Output: Text appended into buffer pointed by FSR2. | 50 ; Output: Text appended into buffer pointed by FSR2. |
61 global gaslist_strcat_gas6 | 51 global gaslist_strcat_gas6 |
62 gaslist_strcat_gas6: ; Show current O2/He mix | 52 gaslist_strcat_gas6: ; Show current O2/He mix |
63 STRCAT_TEXT tGas | 53 STRCAT_TEXT tGas |
64 STRCAT ": " | 54 STRCAT ": " |
65 movff gas6_O2_ratio,lo | 55 movff gas6_O2_ratio,lo |
66 movff gas6_He_ratio,hi | 56 movff gas6_He_ratio,hi |
67 goto customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and RETURN | 57 goto customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2, and RETURN |
68 | 58 |
69 global gaslist_show_type | 59 |
70 extern tGasDisabled | 60 global gaslist_show_type |
71 extern tDilDisabled | |
72 gaslist_show_type: | 61 gaslist_show_type: |
73 movf gaslist_gas,W | 62 movf gaslist_gas,W |
74 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | 63 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] |
75 movff PLUSW1,gaslist_Type | 64 movff PLUSW1,lo ; lo holds gas type |
76 STRCAT_TEXT tType | 65 STRCAT_TEXT tType |
77 lfsr FSR1,tGasDisabled ; Base text number | 66 lfsr FSR1,tGasDisabled ; Base text number |
78 btfsc ccr_diluent_setup ; In CCR setup? | 67 btfsc ccr_diluent_setup ; In CCR setup? |
79 lfsr FSR1,tDilDisabled ; Base text number | 68 lfsr FSR1,tDilDisabled ; Base text number |
80 movff gaslist_Type,WREG ; 0-3 | 69 movff lo,WREG ; 0-3 |
81 rlncf WREG ; x2 | 70 rlncf WREG ; x2 |
82 addwf FSR1L,F | 71 addwf FSR1L,F |
83 movlw .0 | 72 movlw .0 |
84 addwfc FSR1H,F | 73 addwfc FSR1H,F |
85 call strcat_text | 74 call strcat_text |
86 return | 75 return |
87 | 76 |
88 global gaslist_toggle_type | 77 global gaslist_toggle_type |
89 gaslist_toggle_type: | 78 gaslist_toggle_type: |
90 movf gaslist_gas,W | 79 movf gaslist_gas,W |
91 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | 80 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] |
92 movff PLUSW1,gaslist_Type | 81 movff PLUSW1,lo ; lo holds gas type |
93 incf gaslist_Type,F ; 0-3/0-2 | 82 incf lo,F ; 0-3/0-2 |
94 btfsc ccr_diluent_setup ; In CCR setup? | 83 btfsc ccr_diluent_setup ; In CCR setup? |
95 bra gaslist_toggle_type2 ; Yes | 84 bra gaslist_toggle_type2 ; Yes |
96 btfsc gaslist_Type,2 ; >3? | 85 btfsc lo,2 ; >3? |
97 clrf gaslist_Type ; Clear to zero | 86 clrf lo ; Clear to zero |
98 movff gaslist_Type,PLUSW1 ; Copy back result | 87 movff lo,PLUSW1 ; Copy back result |
99 return | 88 return |
100 | |
101 gaslist_toggle_type2: | 89 gaslist_toggle_type2: |
102 movlw .3 | 90 movlw .3 |
103 cpfslt gaslist_Type ; >2? | 91 cpfslt lo ; >2? |
104 clrf gaslist_Type ; Clear to zero | 92 clrf lo ; Clear to zero |
105 movf gaslist_gas,W | 93 movf gaslist_gas,W |
106 movff gaslist_Type,PLUSW1 ; Copy back result | 94 movff lo,PLUSW1 ; Copy back result |
107 return | 95 return |
108 | 96 |
109 global gaslist_setSP | 97 global gaslist_setSP |
110 gaslist_setSP: | 98 gaslist_setSP: |
111 movff PRODL,gaslist_gas ; 0-4 | 99 movff PRODL,gaslist_gas ; 0-4 |
112 return | 100 return |
113 | 101 |
114 extern tbar | 102 |
115 global gaslist_strcat_setpoint | 103 global gaslist_strcat_setpoint |
116 global gaslist_strcat_setpoint_0 | 104 global gaslist_strcat_setpoint_0 |
117 gaslist_strcat_setpoint: | 105 gaslist_strcat_setpoint: |
118 call gaslist_setSP | 106 call gaslist_setSP |
119 gaslist_strcat_setpoint_0: | 107 gaslist_strcat_setpoint_0: |
120 bsf leftbind | 108 bsf leftbind |
121 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | 109 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint |
122 bra gaslist_strcat_setpoint2 ; Short version | 110 bra gaslist_strcat_setpoint2 ; Short version |
123 STRCAT_TEXT tSP | 111 STRCAT_TEXT tSP |
124 incf gaslist_gas,W | 112 incf gaslist_gas,W |
125 movwf lo | 113 movwf lo |
126 output_8 | 114 output_8 |
127 bcf leftbind | 115 bcf leftbind |
128 PUTC ":" | 116 PUTC ":" |
129 gaslist_strcat_setpoint2: ; Short version | 117 gaslist_strcat_setpoint2: ; Short version |
130 btfsc divemode | 118 btfsc divemode |
131 bra gaslist_strcat_setpoint4 ; no "*" in divemode | 119 bra gaslist_strcat_setpoint4 ; no "*" in divemode |
132 movf gaslist_gas,W ; Number-1 into WREG | 120 movf gaslist_gas,W ; Number-1 into WREG |
133 bnz gaslist_strcat_setpoint3 ; Not SP1 | 121 bnz gaslist_strcat_setpoint3 ; Not SP1 |
134 PUTC "*" | 122 PUTC "*" |
135 bra gaslist_strcat_setpoint4 | 123 bra gaslist_strcat_setpoint4 |
136 gaslist_strcat_setpoint3: | 124 gaslist_strcat_setpoint3: |
137 PUTC " " | 125 PUTC " " |
138 gaslist_strcat_setpoint4: | 126 gaslist_strcat_setpoint4: |
139 movf gaslist_gas,W | 127 movf gaslist_gas,W |
140 lfsr FSR1,char_I_setpoint_cbar | 128 lfsr FSR1,char_I_setpoint_cbar |
141 movf PLUSW1,W | 129 movf PLUSW1,W |
142 movwf lo | 130 movwf lo |
143 clrf hi | 131 clrf hi |
144 bsf leftbind | 132 bsf leftbind |
145 output_16dp d'3' | 133 output_16dp d'3' |
146 btfsc divemode | 134 btfsc divemode |
147 bra gaslist_strcat_setpoint5 ; Skip text in divemode | 135 bra gaslist_strcat_setpoint5 ; Skip text in divemode |
148 STRCAT_TEXT tbar | 136 STRCAT_TEXT tbar |
149 gaslist_strcat_setpoint5: | 137 gaslist_strcat_setpoint5: |
150 PUTC " " | 138 PUTC " " |
151 ; Read switch depth | 139 ; Read switch depth |
152 movf gaslist_gas,W | 140 movf gaslist_gas,W |
153 lfsr FSR1,char_I_setpoint_change | 141 lfsr FSR1,char_I_setpoint_change |
154 movff PLUSW1,lo | 142 movff PLUSW1,lo |
155 | 143 |
156 bsf ccr_diluent_setup ; inhibit output of "----" for depth | 144 bsf ccr_diluent_setup ; inhibit output of "----" for depth |
157 call gaslist_strcat_5 | 145 call gaslist_strcat_5 |
158 bcf ccr_diluent_setup | 146 bcf ccr_diluent_setup |
159 return | 147 return |
160 | 148 |
161 ;---------------------------------------------------------------------------- | 149 ;---------------------------------------------------------------------------- |
162 ; Append gas description to current string. | 150 ; Append gas description to current string. |
163 ; Input: PRODL : gas number (0..4) | 151 ; Input: PRODL : gas number (0..4) |
164 ; FSR2 : Current string position. | 152 ; FSR2 : Current string position. |
165 ; Output: Text appended into buffer pointed by FSR2. | 153 ; Output: Text appended into buffer pointed by FSR2. |
166 ; | 154 ; |
167 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry. | 155 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry. |
168 | 156 |
169 gaslist_strcat_gas_better: ; Yes, check if this is a "better gas" | 157 gaslist_strcat_gas_better: ; Yes, check if this is a "better gas" |
170 bcf win_invert | 158 bcf win_invert |
171 decf better_gas_number,W ; better_gas_number-1 -> WREG | 159 movff better_gas_number,WREG ; get better gas number into WREG |
172 btfsc ccr_diluent_setup ; in CCR menus? | 160 decf WREG,W ; better_gas_number = better_gas_number -1 |
173 addlw .5 ; Yes, offset to gases 5-9 | 161 btfsc ccr_diluent_setup ; in CCR menus? |
174 cpfseq gaslist_gas ; 0-4 for OC/Bailout, 5-9 for Diluents | 162 addlw .5 ; Yes, offset to gases 5-9 |
175 return | 163 cpfseq gaslist_gas ; 0-4 for OC/Bailout, 5-9 for Diluents |
176 call TFT_attention_color ; show in yellow | 164 return |
177 bsf win_invert ; And invert | 165 call TFT_attention_color ; show in yellow |
178 return | 166 bsf win_invert ; And invert |
179 | 167 return |
180 global gaslist_strcat_gas_mod | 168 |
169 global gaslist_strcat_gas_mod | |
181 gaslist_strcat_gas_mod: | 170 gaslist_strcat_gas_mod: |
182 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents) | 171 rcall gaslist_setgas ; Sets gaslist_gas (0-4 for OC/Bailout, 5-9 for Diluents) |
183 | 172 bsf space_gas_decriptions ; add a space in front for gas numbers < 10 for alignment |
184 global gaslist_gastitle | 173 ;bra gaslist_gastitle |
174 | |
175 global gaslist_gastitle | |
185 gaslist_gastitle: | 176 gaslist_gastitle: |
186 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | 177 btfsc short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint |
187 bra gaslist_gastitle2 ; Short version | 178 bra gaslist_gastitle1 ; Short version |
188 STRCAT_TEXT tGas | 179 STRCAT_TEXT tGas |
189 incf gaslist_gas,W | 180 incf gaslist_gas,W |
190 movwf lo | 181 movwf lo |
191 bsf leftbind | 182 btfss space_gas_decriptions ; add a space in front for gas numbers < 10 for alignment? |
192 output_8 | 183 bra gaslist_gastitle0 ; NO |
193 bcf leftbind | 184 bcf space_gas_decriptions ; YES - clear flag again |
194 PUTC ":" | 185 movlw .10 ; load a 10 |
195 | 186 cpfslt lo ; gas# < 10 ? |
196 gaslist_gastitle2: ; Short version | 187 bra gaslist_gastitle0 ; NO |
197 lfsr FSR1,opt_gas_type | 188 PUTC " " ; YES - add a space |
198 btfsc divemode | 189 gaslist_gastitle0: |
199 bra gaslist_gastitle3 ; no "*" in divemode | 190 bsf leftbind |
200 movf gaslist_gas,W | 191 output_8 |
201 decf PLUSW1,W ; Type-1 into WREG | 192 bcf leftbind |
202 bnz gaslist_gastitle1 ; Not "First" | 193 PUTC ":" |
203 PUTC "*" | |
204 bra gaslist_gastitle3 | |
205 gaslist_gastitle1: | 194 gaslist_gastitle1: |
206 PUTC " " | 195 lfsr FSR1,opt_gas_type |
207 gaslist_gastitle3: ; Short version | 196 btfsc divemode |
208 call TFT_standard_color | 197 bra gaslist_gastitle3 ; no "*" in divemode |
209 | 198 movf gaslist_gas,W |
210 btfsc divemode ; In divemode? | 199 decf PLUSW1,W ; Type-1 into WREG |
211 rcall gaslist_strcat_gas_better ; Yes, check if this is a "better gas" | 200 bnz gaslist_gastitle2 ; Not "First" |
212 | 201 PUTC "*" |
213 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) | 202 bra gaslist_gastitle3 |
214 movf PLUSW1,W | 203 gaslist_gastitle2: |
215 bnz gaslist_strcat_3 | 204 PUTC " " |
216 call TFT_disabled_color | 205 gaslist_gastitle3: |
217 bra gaslist_strcat_4 ; NEW ; No MOD-check and red color for disabled gases | 206 call TFT_standard_color |
207 btfsc divemode ; In divemode? | |
208 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) | |
210 movf PLUSW1,W | |
211 bnz gaslist_strcat_3 | |
212 call TFT_disabled_color | |
213 bra gaslist_strcat_4 ; no MOD-check and red color for disabled gases | |
218 gaslist_strcat_3: | 214 gaslist_strcat_3: |
219 rcall gaslist_strcat_gas_0 | 215 rcall gaslist_strcat_gas_0 |
220 PUTC " " | 216 PUTC " " |
221 ; Read switch depth | 217 ; Read switch depth |
222 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | 218 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 |
223 movlw .4 | 219 movlw .4 |
224 cpfsgt gaslist_gas ; >4? (-> Diluents) | 220 cpfsgt gaslist_gas ; >4? (-> Diluents) |
225 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases | 221 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases |
226 | 222 |
227 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) | 223 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) |
228 movff PLUSW1,lo | 224 movff PLUSW1,lo |
229 rcall gaslist_calc_mod ; Compute MOD into WREG | 225 rcall gaslist_calc_mod ; Compute MOD into WREG |
230 cpfsgt lo | 226 cpfsgt lo ; within MOD range? |
231 bra gaslist_strcat_5 | 227 bra gaslist_strcat_5 ; YES |
232 call TFT_warnings_color ; Turn red if bigger | 228 call TFT_warnings_color ; NO - turn red |
233 bra gaslist_strcat_5 ; skip gaslist_strcat_gas_0 here | 229 bra gaslist_strcat_5 ; skip gaslist_strcat_gas_0 here |
234 gaslist_strcat_4: | 230 gaslist_strcat_4: |
235 rcall gaslist_strcat_gas_0 | 231 rcall gaslist_strcat_gas_0 |
236 PUTC " " | 232 PUTC " " |
237 | 233 ; Dummy code, needs some cleanup someday... |
238 ; Dummy code, needs some cleanup somedays... | 234 ; Read switch depth |
239 ; Read switch depth | 235 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 |
240 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | 236 movlw .4 |
241 movlw .4 | 237 cpfsgt gaslist_gas ; >4? (-> Diluents) |
242 cpfsgt gaslist_gas ; >4? (-> Diluents) | 238 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases |
243 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases | 239 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) |
244 | 240 movff PLUSW1,lo |
245 movf gaslist_gas,W ; (0-4 for OC/Bailout, 5-9 for Diluents) | 241 rcall gaslist_calc_mod ; Compute MOD into WREG |
246 movff PLUSW1,lo | |
247 ;rcall gaslist_calc_mod ; Compute MOD into WREG | |
248 | |
249 gaslist_strcat_5: | 242 gaslist_strcat_5: |
250 TSTOSS opt_units ; 0=Meters, 1=Feets | 243 PUTC " " |
251 bra gaslist_strcat_3_metric | 244 TSTOSS opt_units ; 0=Meter, 1=Feet |
245 bra gaslist_strcat_3_metric | |
252 ;gaslist_strcat_3_imperial: | 246 ;gaslist_strcat_3_imperial: |
253 btfsc ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") | 247 btfsc ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") |
254 bra gaslist_imperial_non_travel | 248 bra gaslist_imperial_non_travel |
255 movf gaslist_gas,W | 249 movf gaslist_gas,W |
256 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | 250 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] |
257 movff PLUSW1,gaslist_Type | 251 movff PLUSW1,up ; up holds gas type |
258 movlw .2 ; 2=Travel | 252 movlw .2 ; 2=Travel |
259 cpfseq gaslist_Type | 253 cpfseq up ; compare gas type with type 2=Travel |
260 bra gaslist_imperial_non_travel ; Non-Travel Gas | 254 bra gaslist_imperial_non_travel ; Non-Travel Gas |
261 bra gaslist_strcat_depth_travel ; Show "---" instead of "0m"... | 255 bra gaslist_strcat_depth_travel ; Show "---" instead of "0m"... |
262 | |
263 gaslist_imperial_non_travel: | 256 gaslist_imperial_non_travel: |
264 movf lo,W | 257 movf lo,W |
265 mullw .100 ; convert meters to mbar | 258 mullw .100 ; convert meters to mbar |
266 movff PRODL,lo | 259 movff PRODL,lo |
267 movff PRODH,hi | 260 movff PRODH,hi |
268 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | 261 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet |
269 bsf leftbind | 262 bsf leftbind |
270 output_16_3 ; limit to 999 and display only (0-999) | 263 output_16_3 ; limit to 999 and display only (0-999) |
271 STRCAT_TEXT tFeets ; "ft" | 264 STRCAT_TEXT tFeets ; "ft" |
272 return | 265 return |
273 | |
274 gaslist_strcat_3_metric: | 266 gaslist_strcat_3_metric: |
275 btfsc ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") | 267 btfsc ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") |
276 bra gaslist_metric_non_travel | 268 bra gaslist_metric_non_travel |
277 movf gaslist_gas,W | 269 movf gaslist_gas,W |
278 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | 270 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] |
279 movff PLUSW1,gaslist_Type | 271 movff PLUSW1,up ; up holds gas type |
280 movlw .2 ; 2=Travel | 272 movlw .2 ; 2=Travel |
281 cpfseq gaslist_Type | 273 cpfseq up ; compare gas type with type 2=Travel |
282 bra gaslist_metric_non_travel ; Non-Travel Gas | 274 bra gaslist_metric_non_travel ; Non-Travel Gas |
283 gaslist_strcat_depth_travel: ; Show "---" instead of "0m"... | 275 gaslist_strcat_depth_travel: ; Show "---" instead of "0m"... |
284 STRCAT "---" | 276 STRCAT "---" |
285 return | 277 return |
286 gaslist_metric_non_travel: | 278 gaslist_metric_non_travel: |
287 output_99 | 279 output_99 |
288 STRCAT_TEXT tMeters ; "m" | 280 STRCAT_TEXT tMeters ; "m" |
289 return | 281 return |
290 | 282 |
291 ;---------------------------------------------------------------------------- | 283 ;---------------------------------------------------------------------------- |
292 ; Store current menu item, and display gas description later. | 284 ; Store current menu item, and display gas description later. |
293 ; Input: PRODL : gas number (0..4) | 285 ; Input: PRODL : gas number (0..4) |
294 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry. | 286 ; NOTE: used in the menu-tree for the MENU_CALLBACK entry. |
295 global gaslist_setgas | 287 |
288 global gaslist_setgas | |
296 gaslist_setgas: | 289 gaslist_setgas: |
297 movff PRODL,gaslist_gas | 290 movff PRODL,gaslist_gas |
298 movlw .5 | 291 movlw .5 |
299 btfsc ccr_diluent_setup ; in CCR menus? | 292 btfsc ccr_diluent_setup ; in CCR menus? |
300 addwf gaslist_gas,F ; Yes, offset to gases 5-9 | 293 addwf gaslist_gas,F ; Yes, offset to gases 5-9 |
301 return | 294 return |
302 | 295 |
303 | 296 |
304 global gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth | 297 global gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth |
305 gaslist_cleanup_list: | 298 gaslist_cleanup_list: |
306 bcf ignore_last_edited_gas | 299 bcf ignore_last_edited_gas |
307 movlw .0 | 300 movlw .0 |
308 btfsc ccr_diluent_setup ; In CCR-Menu? | 301 btfsc ccr_diluent_setup ; In CCR-Menu? |
309 addlw .5 ; Yes, adjust offset | 302 addlw .5 ; Yes, adjust offset |
310 subwf gaslist_gas,F | 303 subwf gaslist_gas,F |
311 gaslist_cleanup_list1: | 304 gaslist_cleanup_list1: |
312 clrf lo | 305 clrf lo |
313 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] | 306 lfsr FSR1,opt_gas_type ; Read opt_gas_type[WREG] |
314 movlw .5 ; Check 5 gases | 307 movlw .5 ; Check 5 gases |
315 movwf hi | 308 movwf hi |
316 gaslist_cleanup_list2: | 309 gaslist_cleanup_list2: |
317 decf hi,w ; 0-4 | 310 decf hi,w ; 0-4 |
318 btfsc ccr_diluent_setup ; In CCR-Menu? | 311 btfsc ccr_diluent_setup ; In CCR-Menu? |
319 addlw .5 ; Yes, adjust offset | 312 addlw .5 ; Yes, adjust offset |
320 movff PLUSW1,hi_temp | 313 movff PLUSW1,WREG ; read gas type |
321 movlw .1 | 314 decfsz WREG ; is gas = first (ex 1)? |
322 cpfseq hi_temp ; gas = first ? | 315 bra gaslist_cleanup_list3 ; NO |
323 bra gaslist_cleanup_list3 ; No | 316 incf lo,F ; YES - count "first gases" |
324 incf lo,F ; Yes, count "first gases" | 317 btfss ignore_last_edited_gas ; If we are not in the second-pass mode |
325 | 318 bra gaslist_cleanup_list2b |
326 btfss ignore_last_edited_gas ; If we are not in the second-pass mode | 319 decf hi,w ; 0-4 |
327 bra gaslist_cleanup_list2b | 320 cpfseq gaslist_gas ; Do not disable last edited gas |
328 | |
329 decf hi,w ; 0-4 | |
330 cpfseq gaslist_gas ; Do not disable last edited gas | |
331 gaslist_cleanup_list2b: | 321 gaslist_cleanup_list2b: |
332 movff hi,lo_temp ; Keep the last "first gas" found | 322 movff hi,up ; Keep the last "first gas" found |
333 gaslist_cleanup_list3: | 323 gaslist_cleanup_list3: |
334 decfsz hi,F | 324 decfsz hi,F |
335 bra gaslist_cleanup_list2 ; Loop | 325 bra gaslist_cleanup_list2 ; Loop |
336 | 326 tstfsz lo ; No gas active? |
337 tstfsz lo ; No gas active? | 327 bra gaslist_cleanup_list4 ; No, at least one is active |
338 bra gaslist_cleanup_list4 ; No, at least one is active | 328 btfsc ccr_diluent_setup ; In CCR-Menu? |
339 | 329 bra gaslist_cleanup_list3a ; Yes. |
340 btfsc ccr_diluent_setup ; In CCR-Menu? | 330 ; make gas1 first and zero |
341 bra gaslist_cleanup_list3a ; Yes. | 331 movlw .1 ; First |
342 ; make gas1 first and zero | 332 movwf up |
343 movlw .1 ; First | 333 movwf INDF1 |
344 movwf lo_temp | 334 bra gaslist_cleanup_list5 ; Set change depth to zero |
345 movwf INDF1 | |
346 bra gaslist_cleanup_list5 ; Set change depth to zero | |
347 | |
348 gaslist_cleanup_list3a: | 335 gaslist_cleanup_list3a: |
349 movlw .5 | 336 movlw .5 |
350 addwf FSR1L,F | 337 addwf FSR1L,F |
351 movlw .0 | 338 movlw .0 |
352 addwfc FSR1H,F ; Setup to Diluents | 339 addwfc FSR1H,F ; Setup to Diluents |
353 ; make dil1 first and zero | 340 ; make dil1 first and zero |
354 movlw .1 ; First | 341 movlw .1 ; First |
355 movwf lo_temp | 342 movwf up |
356 movwf INDF1 | 343 movwf INDF1 |
357 bra gaslist_cleanup_list5 ; Set change depth to zero | 344 bra gaslist_cleanup_list5 ; Set change depth to zero |
358 | |
359 gaslist_cleanup_list4: | 345 gaslist_cleanup_list4: |
360 movlw .1 | 346 movlw .1 |
361 cpfsgt lo ; More then one "first gas"? | 347 cpfsgt lo ; More then one "first gas"? |
362 bra gaslist_cleanup_list5 ; No, done. | 348 bra gaslist_cleanup_list5 ; No, done. |
363 ; More then one Gas is "first gas" | 349 ; More then one Gas is "first gas" |
364 ; Disable last found "first gas" but keep it's change depth | 350 ; Disable last found "first gas" but keep it's change depth |
365 decf lo_temp,W ; 0-4 | 351 decf up,W ; 0-4 |
366 cpfseq gaslist_gas ; Do not disable last edited gas | 352 cpfseq gaslist_gas ; Do not disable last edited gas |
367 bra gaslist_cleanup_list4b | 353 bra gaslist_cleanup_list4b |
368 ; Do not disable last edited gas | 354 ; Do not disable last edited gas |
369 ; search again but ignore last edited gas | 355 ; search again but ignore last edited gas |
370 bsf ignore_last_edited_gas | 356 bsf ignore_last_edited_gas |
371 bra gaslist_cleanup_list1 ; Loop until only one "first gas" is left | 357 bra gaslist_cleanup_list1 ; Loop until only one "first gas" is left |
372 | |
373 gaslist_cleanup_list4b: | 358 gaslist_cleanup_list4b: |
374 btfsc ccr_diluent_setup ; In CCR-Menu? | 359 btfsc ccr_diluent_setup ; In CCR-Menu? |
375 addlw .5 ; Yes, adjust offset | 360 addlw .5 ; Yes, adjust offset |
376 clrf PLUSW1 ; Disable gas | 361 clrf PLUSW1 ; Disable gas |
377 bra gaslist_cleanup_list ; Loop until only one "first gas" is left | 362 bra gaslist_cleanup_list ; Loop until only one "first gas" is left |
378 | |
379 gaslist_cleanup_list5: | 363 gaslist_cleanup_list5: |
380 ; Read switch depth | 364 ; Read switch depth |
381 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | 365 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 |
382 btfss ccr_diluent_setup ; In CCR-Menu? | 366 btfss ccr_diluent_setup ; In CCR-Menu? |
383 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases | 367 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases |
384 decf lo_temp,W | 368 decf up,W |
385 btfsc ccr_diluent_setup ; In CCR-Menu? | 369 btfsc ccr_diluent_setup ; In CCR-Menu? |
386 addlw .5 ; Yes, adjust offset | 370 addlw .5 ; Yes, adjust offset |
387 clrf PLUSW1 ; Set First gas to zero m | 371 clrf PLUSW1 ; Set First gas to zero m |
388 return | 372 return |
389 | 373 |
390 ;---------------------------------------------------------------------------- | 374 ;---------------------------------------------------------------------------- |
391 ; Increment/Decrement O2 ratio | 375 ; Increment/Decrement O2 ratio |
392 global gaslist_pO2 | 376 |
377 global gaslist_pO2 | |
393 gaslist_pO2: | 378 gaslist_pO2: |
394 movf gaslist_gas,W | 379 movf gaslist_gas,W |
395 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | 380 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] |
396 movff PLUSW1,gaslist_He | 381 movff PLUSW1,hi ; hi holds He ratio |
397 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | 382 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] |
398 movff PLUSW1,gaslist_O2 | 383 movff PLUSW1,lo ; lo holds O2 ratio |
399 | 384 |
400 incf gaslist_O2,F ; O2++ | 385 incf lo,F ; O2++ |
401 movf gaslist_He,W | 386 movf hi,W ; get He ratio into WREG |
402 addwf gaslist_O2,W | 387 addwf lo,W ; add O2 ratio to WREG |
403 movwf lo | 388 movwf up ; move sum He + O2 to up |
404 movlw .101 | 389 movlw .101 ; |
405 cpfslt lo ; O2+He<101? | 390 cpfslt up ; O2 + He < 101? |
406 decf gaslist_O2,F ; O2-- (Unchanged) | 391 decf lo,F ; O2-- (revoke ++) |
407 | 392 movf gaslist_gas,W |
408 movf gaslist_gas,W | 393 movff lo,PLUSW1 ; write back O2 ratio to opt_gas_O2_ratio[WREG] |
409 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG] | 394 return |
410 return | 395 |
411 | 396 global gaslist_mO2 |
412 global gaslist_mO2 | |
413 gaslist_mO2: | 397 gaslist_mO2: |
414 movf gaslist_gas,W | 398 movf gaslist_gas,W |
415 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | 399 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] |
416 movff PLUSW1,gaslist_O2 | 400 movff PLUSW1,lo ; lo holds O2 ratio |
417 | 401 |
418 decf gaslist_O2,F | 402 decf lo,F ; O2-- |
419 movlw gaslist_min_o2 | 403 movlw gaslist_min_o2 ; get minimum allowed O2 ratio |
420 cpfslt gaslist_O2 | 404 cpfslt lo ; current O2 ratio below allowed minimum? |
421 bra gaslist_mO2_1 | 405 bra gaslist_mO2_1 ; NO |
422 movlw gaslist_min_o2 | 406 movlw gaslist_min_o2 ; YES - load minimum |
423 movwf gaslist_O2 | 407 movwf lo ; write minimum to current O2 ratio |
424 gaslist_mO2_1: | 408 gaslist_mO2_1: |
425 movf gaslist_gas,W | 409 movf gaslist_gas,W |
426 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG] | 410 movff lo,PLUSW1 ; write back O2 ratio to opt_gas_O2_ratio[WREG] |
427 return | 411 return |
428 | 412 |
429 ;---------------------------------------------------------------------------- | 413 ;---------------------------------------------------------------------------- |
430 ; Increment/Decrement He ratio | 414 ; Increment/Decrement He ratio |
431 global gaslist_pHe | 415 |
416 global gaslist_pHe | |
432 gaslist_pHe: | 417 gaslist_pHe: |
433 movf gaslist_gas,W | 418 movf gaslist_gas,W |
434 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | 419 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] |
435 movff PLUSW1,gaslist_O2 | 420 movff PLUSW1,lo ; lo holds O2 ratio |
436 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | 421 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] |
437 movff PLUSW1,gaslist_He | 422 movff PLUSW1,hi ; hi holds He ratio |
438 | 423 |
439 incf gaslist_He,F ; He++ | 424 incf hi,F ; He++ |
440 movf gaslist_He,W | 425 movf hi,W ; get He ratio into WREG |
441 addwf gaslist_O2,W | 426 addwf lo,W ; add O2 ratio to WREG |
442 movwf lo | 427 movwf up ; move sum He + O2 to up |
443 movlw .101 | 428 movlw .101 ; |
444 cpfslt lo ; O2+He<101? | 429 cpfslt up ; O2 + He < 101? |
445 decf gaslist_He,F ; Yes, He-- (Unchanged) | 430 decf hi,F ; He-- (revoke ++) |
446 | 431 movf gaslist_gas,W |
447 movf gaslist_gas,W | 432 movff hi,PLUSW1 ; write back He ratio to opt_gas_He_ratio[WREG] |
448 movff gaslist_He,PLUSW1 ; And write back to opt_gas_He_ratio[WREG] | 433 return |
449 return | 434 |
450 | 435 global gaslist_mHe |
451 global gaslist_mHe | |
452 gaslist_mHe: | 436 gaslist_mHe: |
453 movf gaslist_gas,W | 437 movf gaslist_gas,W |
454 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] | 438 lfsr FSR1,opt_gas_He_ratio ; Read opt_gas_He_ratio[WREG] |
455 movff PLUSW1,gaslist_He | 439 movff PLUSW1,hi ; hi holds He ratio |
456 | 440 |
457 decf gaslist_He,F | 441 decf hi,F ; He-- |
458 bnn gaslist_mHe_1 | 442 bnn gaslist_mHe_1 ; He ratio negative? |
459 clrf gaslist_He | 443 clrf hi ; YES - set He to 0 |
460 gaslist_mHe_1: | 444 gaslist_mHe_1: |
461 movf gaslist_gas,W | 445 movf gaslist_gas,W |
462 movff gaslist_He,PLUSW1 ; And write back to opt_gas_He_ratio[WREG] | 446 movff hi,PLUSW1 ; write back He ratio to opt_gas_He_ratio[WREG] |
463 return | 447 return |
464 | 448 |
465 ;---------------------------------------------------------------------------- | 449 ;---------------------------------------------------------------------------- |
466 ; Increment/Decrement switch depth | 450 ; Increment/Decrement switch depth |
467 global gaslist_pDepth | 451 |
452 global gaslist_pDepth | |
468 gaslist_pDepth: | 453 gaslist_pDepth: |
469 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | 454 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 |
470 movlw .4 | 455 movlw .4 |
471 cpfsgt gaslist_gas ; >4? (-> Diluents) | 456 cpfsgt gaslist_gas ; >4? (-> Diluents) |
472 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases | 457 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases |
473 | 458 movf gaslist_gas,W |
474 movf gaslist_gas,W | 459 movff PLUSW1,lo ; Read char_I_deco_gas_change[WREG] |
475 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG] | 460 incf lo,F |
476 | 461 movlw gaslist_max_change_depth |
477 incf gaslist_O2,F | 462 cpfsgt lo |
478 movlw gaslist_max_change_depth | 463 bra gaslist_pDepth_1 |
479 cpfsgt gaslist_O2 | 464 movlw gaslist_max_change_depth |
480 bra gaslist_pDepth_1 | 465 movwf lo |
481 movlw gaslist_max_change_depth | |
482 movwf gaslist_O2 | |
483 gaslist_pDepth_1: | 466 gaslist_pDepth_1: |
484 movf gaslist_gas,W | 467 movf gaslist_gas,W |
485 movff gaslist_O2,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] | 468 movff lo,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] |
486 return | 469 return |
487 | 470 |
488 global gaslist_mDepth | 471 global gaslist_mDepth |
489 gaslist_mDepth: | 472 gaslist_mDepth: |
490 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 | 473 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents-5 |
491 movlw .4 | 474 movlw .4 |
492 cpfsgt gaslist_gas ; >4? (-> Diluents) | 475 cpfsgt gaslist_gas ; >4? (-> Diluents) |
493 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases | 476 lfsr FSR1,opt_OC_bail_gas_change ; Setup OC Gases |
494 | 477 |
495 movf gaslist_gas,W | 478 movf gaslist_gas,W |
496 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG] | 479 movff PLUSW1,lo ; Read char_I_deco_gas_change[WREG] |
497 | 480 |
498 decf gaslist_O2,F | 481 decf lo,F |
499 btfsc STATUS,N | 482 btfsc STATUS,N |
500 clrf gaslist_O2 | 483 clrf lo |
501 | 484 |
502 movf gaslist_gas,W | 485 movf gaslist_gas,W |
503 movff gaslist_O2,PLUSW1 ; And write back to char_I_deco_gas_change[WREG] | 486 movff lo,PLUSW1 ; And write back to char_I_deco_gas_change[WREG] |
504 return | 487 return |
505 | 488 |
506 global gaslist_spplus | 489 global gaslist_spplus |
507 gaslist_spplus: | 490 gaslist_spplus: |
508 movf gaslist_gas,W | 491 movf gaslist_gas,W |
509 lfsr FSR1,char_I_setpoint_cbar | 492 lfsr FSR1,char_I_setpoint_cbar |
510 movff PLUSW1,lo ; Read char_I_setpoint_cbar[WREG] | 493 movff PLUSW1,lo ; Read char_I_setpoint_cbar[WREG] |
511 movlw gaslist_sp_stepsize | 494 movlw gaslist_sp_stepsize |
512 addwf lo,F | 495 addwf lo,F |
513 movlw gaslist_sp_max | 496 movlw gaslist_sp_max |
514 cpfsgt lo | 497 cpfsgt lo |
515 bra gaslist_spplus2 | 498 bra gaslist_spplus2 |
516 movlw gaslist_sp_min | 499 movlw gaslist_sp_min |
517 movwf lo | 500 movwf lo |
518 gaslist_spplus2: | 501 gaslist_spplus2: |
519 movf gaslist_gas,W | 502 movf gaslist_gas,W |
520 movff lo,PLUSW1 ; Write back to char_I_setpoint_cbar | 503 movff lo,PLUSW1 ; Write back to char_I_setpoint_cbar |
521 return | 504 return |
522 | 505 |
523 global gaslist_spdepthplus | 506 global gaslist_spdepthplus |
524 gaslist_spdepthplus: | 507 gaslist_spdepthplus: |
525 movf gaslist_gas,W | 508 movf gaslist_gas,W |
526 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m | 509 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m |
527 lfsr FSR1,char_I_setpoint_change | 510 lfsr FSR1,char_I_setpoint_change |
528 movff PLUSW1,gaslist_O2 ; Read char_I_deco_gas_change[WREG] | 511 movff PLUSW1,lo ; Read char_I_deco_gas_change[WREG] |
529 incf gaslist_O2,F | 512 incf lo,F |
530 movlw gaslist_max_change_depth | 513 movlw gaslist_max_change_depth |
531 cpfsgt gaslist_O2 | 514 cpfsgt lo |
532 bra gaslist_spdepthplus_1 | 515 bra gaslist_spdepthplus_1 |
533 movlw gaslist_max_change_depth | 516 movlw gaslist_max_change_depth |
534 movwf gaslist_O2 | 517 movwf lo |
535 gaslist_spdepthplus_1: | 518 gaslist_spdepthplus_1: |
536 movf gaslist_gas,W | 519 movf gaslist_gas,W |
537 movff gaslist_O2,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] | 520 movff lo,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] |
538 return | 521 return |
539 | 522 |
540 gaslist_spdepthplus3: | 523 gaslist_spdepthplus3: |
541 movlw .0 | 524 movlw .0 |
542 movff WREG,char_I_setpoint_change+0 ; Reset to 0m | 525 movff WREG,char_I_setpoint_change+0 ; Reset to 0m |
543 return | 526 return |
544 | 527 |
545 global gaslist_spdepthminus | 528 global gaslist_spdepthminus |
546 gaslist_spdepthminus: | 529 gaslist_spdepthminus: |
547 movf gaslist_gas,W | 530 movf gaslist_gas,W |
548 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m | 531 bz gaslist_spdepthplus3 ; Setpoint 1 is always 0m |
549 lfsr FSR1,char_I_setpoint_change | 532 lfsr FSR1,char_I_setpoint_change |
550 movff PLUSW1,gaslist_O2 ; Read opt_gas_O2_ratio[WREG] | 533 movff PLUSW1,lo ; Read char_I_deco_gas_change[WREG] |
551 decf gaslist_O2,F | 534 decf lo,F |
552 btfsc STATUS,N | 535 btfsc STATUS,N |
553 clrf gaslist_O2 | 536 clrf lo |
554 movf gaslist_gas,W | 537 movf gaslist_gas,W |
555 movff gaslist_O2,PLUSW1 ; And write back to opt_gas_O2_ratio[WREG] | 538 movff lo,PLUSW1 ; Write back to char_I_deco_gas_change[WREG] |
556 return | 539 return |
557 | 540 |
558 ;---------------------------------------------------------------------------- | 541 ;---------------------------------------------------------------------------- |
559 ; Compute MOD from char_I_ppO2_max/char_I_ppO2_max_deco and current O2 Ratio. | 542 ; Compute MOD from char_I_ppO2_max/char_I_ppO2_max_deco and current O2 Ratio. |
560 ; | 543 ; |
561 ; Input: gaslist_gas = current gas index. | 544 ; Input: gaslist_gas = current gas index. |
562 ; opt_gas_O2_ratio[gaslist_gas] = current O2 ratio | 545 ; opt_gas_O2_ratio[gaslist_gas] = current O2 ratio |
563 ; Output: WREG = MOD [m] | 546 ; Output: WREG = MOD [m] |
564 ; | 547 ; |
565 gaslist_calc_mod: | 548 gaslist_calc_mod: |
566 movff gaslist_gas,gaslist_gas_global ; copy for color coding | 549 movf gaslist_gas,W ; get gas number (0...5) |
567 movf gaslist_gas,W ; Read current gas O2 ratio | 550 lfsr FSR1,opt_gas_O2_ratio ; read opt_gas_O2_ratio[WREG] |
568 lfsr FSR1,opt_gas_O2_ratio ; Read opt_gas_O2_ratio[WREG] | 551 movf PLUSW1,W |
569 movf PLUSW1,W | 552 |
570 | 553 btfsc divemode ; in divemode? |
571 btfsc divemode ; In divemode? | 554 bra gaslist_calc_mod_divemode ; YES |
572 bra gaslist_calc_mod_divemode ; Yes. | 555 |
573 | 556 ; Pamb max = ppO2 Max / O2 ratio |
574 ; Pamb max = ppO2 Max / O2 ratio | 557 movwf xB+0 |
575 movwf xB+0 | 558 |
576 | 559 movf gaslist_gas,W ; get gas number (0...5) |
577 movf gaslist_gas,W ; Read current gas O2 ratio | 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 |
578 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 | 561 movff PLUSW1,xA+0 ; xA+0 used as temp here -> holds type |
579 movff PLUSW1,xA+0 ; xA+0 used as temp here -> holds type | 562 |
580 | 563 movff char_I_ppO2_max_deco,xB+1 ; xB+1 used as temp here |
581 movff char_I_ppO2_max_deco,xB+1 ; xB+1 used as temp here | 564 movlw .3 |
582 movlw .3 | 565 cpfseq xA+0 ; Deco? |
583 cpfseq xA+0 ; Deco? | 566 movff char_I_ppO2_max,xB+1 ; No, overwrite with travel/bottom max |
584 movff char_I_ppO2_max,xB+1 ; No, overwrite with travel/bottom max | 567 movf xB+1,W ; Result in WREG |
585 movf xB+1,W ; Result in WREG | 568 |
586 | 569 clrf xB+1 ; Clear for div16x16 |
587 clrf xB+1 ; Clear for div16x16 | 570 mullw .10 |
588 mullw .10 | 571 movff PRODL,xA+0 |
589 movff PRODL,xA+0 | 572 movff PRODH,xA+1 |
590 movff PRODH,xA+1 | 573 call div16x16 |
591 call div16x16 | 574 |
592 | 575 ; Prof = Pamb - 1 bar |
593 ; Prof = Pamb - 1bar. | 576 movf xC+0,W |
594 movf xC+0,W | 577 addlw -.10 |
595 addlw -.10 | 578 return |
596 return | |
597 | 579 |
598 gaslist_calc_mod_divemode: | 580 gaslist_calc_mod_divemode: |
599 extern TFT_color_code1 | 581 movwf hi ; Copy O2% |
600 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 |
601 movlw warn_gas_in_gaslist | 583 return |
602 call TFT_color_code1 ; Color-code current row in Gaslist (%O2 in hi), char_I_ppO2_max/char_I_ppO2_max_deco as threshold | 584 |
603 return | 585 ;---------------------------------------------------------------------------- |
604 ;---------------------------------------------------------------------------- | 586 |
605 | 587 global gaslist_ppo2 |
606 global gaslist_ppo2 | |
607 gaslist_ppo2: | 588 gaslist_ppo2: |
608 STRCAT_TEXT tppO2 ; ppO2: | 589 STRCAT_TEXT tppO2 ; ppO2: |
609 movf gaslist_gas,W | 590 movf gaslist_gas,W |
610 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents | 591 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents |
611 btfss ccr_diluent_setup ; In CCR-Menu? | 592 btfss ccr_diluent_setup ; In CCR-Menu? |
612 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC/Bailout Gases | 593 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC/Bailout Gases |
613 movf PLUSW1,W | 594 movf PLUSW1,W |
614 mullw .10 ; PROD=Depth in mbar/10 (100 = 1.00 bar) | 595 mullw .10 ; PROD=Depth in mbar/10 (100 = 1.00 bar) |
615 movlw .100 | 596 movlw .100 |
616 addwf PRODL,F | 597 addwf PRODL,F |
617 movlw .0 | 598 movlw .0 |
618 addwfc PRODH,F ; add 1bar | 599 addwfc PRODH,F ; add 1bar |
619 movff PRODL,xA+0 | 600 movff PRODL,xA+0 |
620 movff PRODH,xA+1 | 601 movff PRODH,xA+1 |
621 movf gaslist_gas,W ; Read current gas O2 ratio | 602 movf gaslist_gas,W ; Read current gas O2 ratio |
622 lfsr FSR1,opt_dil_O2_ratio-.5 ; Read dil_gas_O2_ratio[WREG] | 603 lfsr FSR1,opt_dil_O2_ratio-.5 ; Read dil_gas_O2_ratio[WREG] |
623 btfss ccr_diluent_setup ; In CCR-Menu? | 604 btfss ccr_diluent_setup ; In CCR-Menu? |
624 lfsr FSR1,opt_gas_O2_ratio ; No, read opt_gas_O2_ratio[WREG] | 605 lfsr FSR1,opt_gas_O2_ratio ; No, read opt_gas_O2_ratio[WREG] |
625 movff PLUSW1,xB+0 | 606 movff PLUSW1,xB+0 |
626 clrf xB+1 | 607 clrf xB+1 |
627 call mult16x16 ; char_I_O2_ratio * (p_amb/10) | 608 call mult16x16 ; char_I_O2_ratio * (p_amb/10) |
628 movff xC+0,xA+0 | 609 movff xC+0,xA+0 |
629 movff xC+1,xA+1 | 610 movff xC+1,xA+1 |
630 movlw d'100' | 611 movlw d'100' |
631 movwf xB+0 | 612 movwf xB+0 |
632 clrf xB+1 | 613 clrf xB+1 |
633 call div16x16 ; xC=(char_I_O2_ratio * p_amb/10)/100 | 614 call div16x16 ; xC=(char_I_O2_ratio * p_amb/10)/100 |
634 ; Check very high ppO2 manually | 615 ; Check very high ppO2 manually |
635 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? | 616 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? |
636 bra gaslist_ppo2_2 ; Yes, display fixed Value! | 617 bra gaslist_ppo2_2 ; Yes, display fixed Value! |
637 movff xC+0,lo | 618 movff xC+0,lo |
638 movff xC+1,hi | 619 movff xC+1,hi |
639 bcf ignore_digit4 | 620 bcf ignore_digit4 |
640 bsf leftbind | 621 bsf leftbind |
641 output_16dp d'3' ; x.xx | 622 output_16dp d'3' ; x.xx |
642 STRCAT_TEXT tbar ; bar | 623 STRCAT_TEXT tbar ; bar |
643 return | 624 return |
644 gaslist_ppo2_2: | 625 gaslist_ppo2_2: |
645 STRCAT ">6.6" | 626 STRCAT ">6.6" |
646 return | 627 return |
647 | 628 |
648 global gaslist_MOD_END | 629 global gaslist_MOD_END |
649 gaslist_MOD_END: | 630 gaslist_MOD_END: |
650 rcall gaslist_calc_mod ; Compute MOD into WREG | 631 rcall gaslist_calc_mod ; Compute MOD into WREG |
651 movwf lo ; Copy to lo | 632 movwf lo ; Copy to lo |
652 STRCAT_TEXT tMOD ; MOD: | 633 STRCAT_TEXT tMOD ; MOD: |
653 TSTOSS opt_units ; 0=Meters, 1=Feets | 634 TSTOSS opt_units ; 0=Meters, 1=Feets |
654 bra gaslist_MOD_metric | 635 bra gaslist_MOD_metric |
655 ;gaslist_MOD_imperial: | 636 ;gaslist_MOD_imperial: |
656 movf lo,W | 637 movf lo,W |
657 mullw .100 ; convert meters to mbar | 638 mullw .100 ; convert meters to mbar |
658 movff PRODL,lo | 639 movff PRODL,lo |
659 movff PRODH,hi | 640 movff PRODH,hi |
660 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | 641 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet |
661 bsf leftbind | 642 bsf leftbind |
662 output_16_3 ; limit to 999 and display only (0-999) | 643 output_16_3 ; limit to 999 and display only (0-999) |
663 STRCAT_TEXT tFeets ; "ft" | 644 STRCAT_TEXT tFeets ; "ft" |
664 bra gaslist_MOD_common | 645 bra gaslist_MOD_common |
665 gaslist_MOD_metric: | 646 gaslist_MOD_metric: |
666 output_8 | 647 output_8 |
667 STRCAT_TEXT tMeters ; m | 648 STRCAT_TEXT tMeters ; m |
668 gaslist_MOD_common: | 649 gaslist_MOD_common: |
669 PUTC "/" | 650 PUTC "/" |
670 STRCAT_TEXT tEND ; END: | 651 STRCAT_TEXT tEND ; END: |
671 rcall gaslist_calc_mod ; Output: WREG = MOD [m] | 652 rcall gaslist_calc_mod ; Output: WREG = MOD [m] |
672 addlw .10 ; MOD=MOD+10m | 653 addlw .10 ; MOD=MOD+10m |
673 movwf xB+0 | 654 movwf xB+0 |
674 clrf xB+1 | 655 clrf xB+1 |
675 movlw d'100' | 656 movlw d'100' |
676 movwf xA+0 | 657 movwf xA+0 |
677 movf gaslist_He,W ; He value in % -> WREG | 658 movf gaslist_gas,W ; get gas number (0...5) |
678 subwf xA+0,F ; xA+0 = 100 - He Value in % | 659 lfsr FSR1,opt_gas_He_ratio ; read opt_gas_O2_ratio[WREG] |
679 clrf xA+1 | 660 movf PLUSW1,W ; He value in % |
680 call mult16x16 ; xA*xB=xC | 661 subwf xA+0,F ; xA+0 = 100 - He Value in % |
681 movff xC+0,xA+0 | 662 clrf xA+1 |
682 movff xC+1,xA+1 | 663 call mult16x16 ; xA*xB=xC |
683 movlw d'100' | 664 movff xC+0,xA+0 |
684 movwf xB+0 | 665 movff xC+1,xA+1 |
685 clrf xB+1 | 666 movlw d'100' |
686 call div16x16 ; xA/xB=xC with xA as remainder | 667 movwf xB+0 |
687 ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100 | 668 clrf xB+1 |
688 movlw d'10' | 669 call div16x16 ; xA/xB=xC with xA as remainder |
689 subwf xC+0,F ; Subtract 10m... | 670 ; ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100 |
690 movff xC+0,lo | 671 movlw d'10' |
691 ; END 8Bit only | 672 subwf xC+0,F ; Subtract 10m... |
692 ; movlw d'0' | 673 movff xC+0,lo |
693 ; subwfb xC+1,F | 674 ;; END 8Bit only |
694 ; movff xC+1,hi | 675 ;movlw d'0' |
695 TSTOSS opt_units ; 0=Meters, 1=Feets | 676 ;subwfb xC+1,F |
696 bra gaslist_END_metric | 677 ;movff xC+1,hi |
697 ;gaslist_END_imperial: | 678 TSTOSS opt_units ; 0=Meter, 1=Feet |
698 movf lo,W | 679 bra gaslist_END_metric |
699 mullw .100 ; convert meters to mbar | 680 ;gaslist_END_imperial: |
700 movff PRODL,lo | 681 movf lo,W |
701 movff PRODH,hi | 682 mullw .100 ; convert meters to mbar |
702 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | 683 movff PRODL,lo |
703 bsf leftbind | 684 movff PRODH,hi |
704 output_16_3 ; limit to 999 and display only (0-999) | 685 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet |
705 STRCAT_TEXT tFeets ; "ft" | 686 bsf leftbind |
706 return | 687 output_16_3 ; limit to 999 and display only (0-999) |
688 STRCAT_TEXT tFeets ; "ft" | |
689 return | |
707 gaslist_END_metric: | 690 gaslist_END_metric: |
708 output_8 | 691 output_8 |
709 STRCAT_TEXT tMeters ; m | 692 STRCAT_TEXT tMeters ; m |
710 return | 693 return |
711 | 694 |
712 ;---------------------------------------------------------------------------- | 695 ;---------------------------------------------------------------------------- |
713 global gaslist_reset_mod_title | 696 global gaslist_reset_mod_title |
714 gaslist_reset_mod_title: | 697 gaslist_reset_mod_title: |
715 STRCAT_TEXT tDepthReset | 698 STRCAT_TEXT tDepthReset |
716 | 699 |
717 gaslist_reset_mod_title2: | 700 gaslist_reset_mod_title2: |
718 rcall gaslist_calc_mod ; Compute MOD into WREG | 701 rcall gaslist_calc_mod ; Compute MOD into WREG |
719 movwf lo ; Copy to lo | 702 movwf lo ; Copy to lo |
720 | 703 |
721 movf gaslist_gas,W ; Compare to switch depth | 704 movf gaslist_gas,W ; Compare to switch depth |
722 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents | 705 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents |
723 btfss ccr_diluent_setup ; In CCR-Menu? | 706 btfss ccr_diluent_setup ; In CCR-Menu? |
724 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases | 707 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases |
725 movf PLUSW1,W | 708 movf PLUSW1,W |
726 cpfslt lo | 709 cpfslt lo |
727 bra gaslist_strcat_5 ; And return... | 710 bra gaslist_strcat_5 ; and return... |
728 call TFT_warnings_color ; Turn red if bigger ! | 711 call TFT_warnings_color ; turn red if bigger ! |
729 bra gaslist_strcat_5 ; And return... | 712 bra gaslist_strcat_5 ; and return... |
730 | 713 |
731 ;---------------------------------------------------------------------------- | 714 ;---------------------------------------------------------------------------- |
732 global gaslist_reset_mod | 715 global gaslist_reset_mod |
733 gaslist_reset_mod: | 716 gaslist_reset_mod: |
734 rcall gaslist_calc_mod ; Compute MOD | 717 rcall gaslist_calc_mod ; Compute MOD, it is returned in WREG |
735 movwf gaslist_depth | 718 movwf lo ; buffer MOD to lo |
736 | 719 movf gaslist_gas,W ; Read current gas O2 ratio |
737 movf gaslist_gas,W ; Read current gas O2 ratio | 720 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents |
738 | 721 btfss ccr_diluent_setup ; In CCR-Menu? |
739 lfsr FSR1,char_I_dil_change-.5 ; Setup Diluents | 722 lfsr FSR1,opt_OC_bail_gas_change ; NO - setup OC Gases |
740 btfss ccr_diluent_setup ; In CCR-Menu? | 723 movff lo,PLUSW1 ; write back new change depth |
741 lfsr FSR1,opt_OC_bail_gas_change ; No, setup OC Gases | 724 return |
742 | 725 ;---------------------------------------------------------------------------- |
743 movff gaslist_depth,PLUSW1 ; And save new change depth | 726 END |
744 return | |
745 ;---------------------------------------------------------------------------- | |
746 END |