Mercurial > public > hwos_code
annotate src/divemenu_tree.asm @ 582:b455b31ce022
work on 2.97 stable
author | heinrichsweikamp |
---|---|
date | Mon, 26 Feb 2018 16:40:28 +0100 |
parents | e6d5a1f02daf |
children | 6636cbe64c6d |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
582 | 3 ; File divemenu_tree.asm REFACTORED VERSION V2.98 |
0 | 4 ; |
275 | 5 ; OSTC dive mode menu |
0 | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2013-02-02 : [mH] Made out of menu_tree.asm | |
11 | |
582 | 12 #include "hwos.inc" ; Mandatory header |
13 #include "menu_processor.inc" | |
14 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | |
15 #include "tft_outputs.inc" | |
16 #include "customview.inc" | |
17 #include "strings.inc" | |
18 #include "calibrate.inc" | |
19 | |
20 extern timeout_divemode_menu2 | |
21 extern diveloop_loop4 | |
0 | 22 |
560 | 23 |
582 | 24 divegui CODE |
25 | |
0 | 26 ;============================================================================= |
27 ; Main Menu | |
582 | 28 global do_main_divemenu |
0 | 29 do_main_divemenu: |
582 | 30 call menu_processor_reset ; restart from first icon |
31 movlw .1 | |
32 movwf menupos1 ; set to first option in divemode menu | |
560 | 33 btfsc FLAG_ccr_mode |
34 bra main_divemenu_loop ; goto CCR / pSCR Menu menu | |
35 btfsc FLAG_pscr_mode | |
36 bra main_divemenu_loop ; goto CCR / pSCR Menu menu | |
37 | |
582 | 38 main_divemenu_OC: |
560 | 39 bcf ccr_diluent_setup |
40 bcf is_bailout_menu | |
582 | 41 |
42 MENU_BEGIN tMainMenu, .5 | |
43 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | |
44 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
45 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf | |
46 MENU_CALL tDivemenu_Marker, do_set_marker | |
47 MENU_CALL tExit, do_exit_divemode_menu | |
560 | 48 MENU_END |
0 | 49 |
560 | 50 main_divemenu_loop: |
582 | 51 bsf ccr_diluent_setup ; default to operations on diluents |
560 | 52 bcf is_bailout_menu ; default to none-bailout menu |
582 | 53 btfsc FLAG_pscr_mode |
54 bra main_divemenu_pscr ; PSCR Menu | |
55 | |
56 MENU_BEGIN tMainMenu, .6 | |
57 MENU_CALL tDiveBailout, do_divemode_gaslist_bail | |
58 MENU_CALL tDivemenu_Setpoint, do_divemode_splist | |
59 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | |
60 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
61 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf | |
62 MENU_CALL tExit, do_exit_divemode_menu | |
63 MENU_END | |
64 | |
485 | 65 main_divemenu_pscr: |
582 | 66 btfsc analog_o2_input ; do we have an analog input? |
67 bra main_divemenu_pscr_sensors ; YES | |
68 btfsc s8_digital ; do we have a digital input? | |
69 bra main_divemenu_pscr_sensors ; YES | |
560 | 70 |
71 main_divemenu_pscr_no_sensors: | |
582 | 72 MENU_BEGIN tMainMenu, .6 |
73 MENU_CALL tDiveBailout, do_divemode_gaslist_bail | |
74 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | |
75 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
76 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf | |
77 MENU_CALL tDivemenu_Marker, do_set_marker | |
78 MENU_CALL tExit, do_exit_divemode_menu | |
79 MENU_END | |
80 | |
81 main_divemenu_pscr_sensors: | |
82 MENU_BEGIN tMainMenu, .6 | |
83 MENU_CALL tDiveBailout, do_divemode_gaslist_bail | |
84 MENU_CALL tCCRSensor, do_divemode_setpoint_pscr | |
85 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | |
86 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
87 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf | |
88 MENU_CALL tExit, do_exit_divemode_menu | |
89 MENU_END | |
90 | |
0 | 91 |
560 | 92 do_toggle_gf: |
582 | 93 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF |
94 decfsz WREG,W ; Toggle GF only in GF modes - in GF mode? | |
95 bra do_main_divemenu ; No, do nothing and return | |
96 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater | |
97 bra do_main_divemenu ; No, do nothing and return | |
98 movlw .4 ; Set customview to 5 (GF informations) | |
560 | 99 movwf menupos3 ; Customview to come-1 |
100 bsf toggle_customview ; Set flag, the customview will be toggled very soon now... | |
101 movlw .1 | |
582 | 102 movwf menupos1 ; Set to first option in divemode menu |
103 | |
104 MENU_BEGIN tDivemenu_ToggleGF, .2 | |
105 MENU_CALL tDivemenu_ToggleGF, do_togglegf | |
106 MENU_CALL tBack, do_main_divemenu | |
107 MENU_END | |
0 | 108 |
560 | 109 do_togglegf: |
582 | 110 ;TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater ; check is now done before entering menu |
560 | 111 ;bra do_exit_divemode_menu ; continue with exiting menu code |
112 bsf toggle_gf ; Set flag... | |
113 bra do_exit_divemode_menu ; continue with exiting menu code | |
582 | 114 |
115 | |
560 | 116 do_set_marker: |
582 | 117 bsf FLAG_set_marker ; set flag... |
118 bra do_exit_divemode_menu ; ... and exit | |
119 | |
53
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
0
diff
changeset
|
120 |
560 | 121 do_reset_average: |
582 | 122 bsf reset_average_depth ; Set Flag |
123 bra do_exit_divemode_menu ; continue with exiting menu code | |
0 | 124 |
582 | 125 |
560 | 126 do_switch_sensor: ; entry point when coming from switch to sensor |
582 | 127 movlw .1 ; Switch to Sensor |
128 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP | |
129 ; enable all sensors | |
130 bsf use_O2_sensor1 | |
131 bsf use_O2_sensor2 | |
132 bsf use_O2_sensor3 | |
133 bra do_switch_sp_com ; continue with common part | |
134 | |
560 | 135 do_switch_sp: ; entry point when coming from manual setpoint selection (CCR) |
582 | 136 decf menupos1,W ; 1-5 -> 0-4 |
137 lfsr FSR1,char_I_setpoint_cbar | |
138 movff PLUSW1,char_I_const_ppO2 ; setup fixed setpoint | |
139 movff char_I_const_ppO2,WREG | |
140 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics | |
560 | 141 bcf setpoint_fallback ; clear fallback condition (stops fallback warning) |
142 clrf WREG ; Switch to fixed SP | |
143 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP | |
144 bra do_switch_sp_com | |
0 | 145 |
560 | 146 do_switch_sp_calc: ; entry point when coming from switch to calculated ppO2 (pSCR) |
147 bcf setpoint_fallback ; clear fallback condition (stops fallback warning) | |
582 | 148 clrf WREG ; Switch to fixed SP |
149 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP | |
560 | 150 movff WREG,char_I_const_ppO2 ; set setpoint to 0, this forces deco engine to take the computed ppO2 |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
151 |
560 | 152 do_switch_sp_com: ; merge point to common part |
582 | 153 bsf event_occured ; set global event byte |
154 bsf setpoint_changed ; set flag (for profile) | |
155 | |
156 ; Clear some flags in case we were in bailout before... | |
157 bcf is_bailout ; end bailout mode | |
158 ;bcf is_bailout_menu ; not needed | |
159 bcf better_gas_available ; =1: A better gas is available and a gas change is advised in divemode | |
160 bcf blinking_better_gas ; clear blinking flag | |
161 call customview_mask ; update customview mask to (eventually) rewrite ppO2(Dil): to ppO2: | |
0 | 162 |
582 | 163 bsf FLAG_back_to_loop ; indicate that it is a switchback from OC bailout to CCR/pSCR loop |
164 bsf divemode_gaschange ; initiate reconfiguration to loop mode on last diluent | |
165 | |
166 bra do_exit_divemode_menu ; continue with exiting menu code | |
167 | |
0 | 168 |
560 | 169 do_divemode_gaslist_bail: ; entry point from CCR/pSCR to bailout to OC gases |
582 | 170 bcf ccr_diluent_setup ; switch to OC gases |
171 bsf is_bailout_menu ; flag it is a bailout action | |
560 | 172 do_divemode_gaslist: ; entry point for switching: OC -> gases, loop -> diluents |
582 | 173 btfsc is_bailout ; in bailout mode? |
174 bcf ccr_diluent_setup ; yes - for safety reasons, redirect to OC (bailout) gases | |
175 do_divemode_gaslist_com: | |
560 | 176 bsf short_gas_decriptions |
177 movlw .1 | |
582 | 178 movwf menupos1 ; Set to first option in divemode menu |
179 MENU_BEGIN tGaslist, .6 | |
180 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | |
181 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | |
182 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | |
183 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | |
184 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | |
185 MENU_CALL tMore, do_divemode_gaslist_more | |
186 MENU_END | |
187 | |
0 | 188 |
189 do_divemode_gaslist_more: | |
560 | 190 movlw .1 |
582 | 191 movwf menupos1 ; Set to first option in divemode menu |
192 | |
560 | 193 movff char_I_O2_ratio,gas6_O2_ratio ; initialize gas6 with currently breathed gas - O2 ratio |
194 movff char_I_He_ratio,gas6_He_ratio ; initialize gas6 with currently breathed gas - He ratio | |
582 | 195 |
196 do_divemode_gaslist_more_common: | |
197 MENU_BEGIN tGaslist, .6 | |
198 MENU_CALL tO2Plus, do_dive_pO2 | |
199 MENU_CALL tO2Minus, do_dive_mO2 | |
200 MENU_CALL tHePlus, do_dive_pHe | |
201 MENU_CALL tHeMinus, do_dive_mHe | |
202 MENU_DYNAMIC gaslist_strcat_gas6, do_switch_gas6 | |
203 MENU_CALL tDivemenu_LostGas, do_lost_gas | |
204 MENU_END | |
205 | |
403
6e60012bb3fc
NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents:
401
diff
changeset
|
206 |
6e60012bb3fc
NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents:
401
diff
changeset
|
207 do_lost_gas: |
560 | 208 movlw .1 |
582 | 209 movwf menupos1 ; Set to first option in divemode menu |
210 do_lost_gas_common: | |
560 | 211 bsf short_gas_decriptions |
582 | 212 MENU_BEGIN tDivemenu_LostGas, .6 |
213 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active | |
214 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active | |
215 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active | |
216 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active | |
217 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active | |
218 MENU_CALL tExit, do_exit_divemode_menu | |
219 MENU_END | |
0 | 220 |
560 | 221 |
222 do_switch_gas6: | |
582 | 223 movlw .6 ; gas 6 |
224 movwf menupos1 ; transfer register for selected gas towards gas_switched_common: | |
225 bsf gas6_changed ; set flag for profile recording | |
560 | 226 ;bra do_switch_gas ; continue with common gas-switched code |
227 | |
228 do_switch_gas: | |
229 bsf divemode_gaschange ; Set flag, will also trigger restart of deco_engine | |
230 btfsc is_bailout_menu ; Bailout confirmed? | |
231 bsf is_bailout ; begin bailout mode | |
232 call customview_mask ; update custom view mask to (eventually) rewrite ppO2(Dil): to ppO2: | |
233 ;bra do_exit_divemode_menu ; continue with exiting menu code | |
582 | 234 |
560 | 235 do_exit_divemode_menu: |
236 call timeout_divemode_menu2 | |
237 clrf STKPTR | |
238 goto diveloop_loop4 | |
239 | |
240 | |
403
6e60012bb3fc
NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents:
401
diff
changeset
|
241 do_toggle_active: |
560 | 242 extern restart_deco_engine_wo_ceiling |
243 call restart_deco_engine_wo_ceiling | |
582 | 244 movlw .5 |
245 btfsc ccr_diluent_setup ; diluents? | |
246 addwf menupos1,F ; yes 1-5 -> 6-10 | |
247 decf menupos1,W ; -> 0-4 for gases / 5-9 for diluents | |
248 lfsr FSR1,opt_gas_type+0 | |
249 movff PLUSW1,lo | |
250 tstfsz lo ; Already disabled? | |
251 bra do_toggle_active2 ; No, disable now! | |
252 lfsr FSR1,opt_gas_type_backup+0 ; copy opt_gas_type_backup+W back to opt_gas_type+W | |
253 movff PLUSW1,lo | |
254 lfsr FSR1,opt_gas_type+0 | |
255 movff lo,PLUSW1 | |
256 lfsr FSR1,opt_OC_bail_gas_change_backup+0 ; copy opt_OC_bail_gas_change_backup+W back to opt_OC_bail_gas_change+W | |
257 movff PLUSW1,lo | |
258 lfsr FSR1,opt_OC_bail_gas_change+0 | |
259 movff lo,PLUSW1 | |
260 bra do_toggle_active3 | |
560 | 261 do_toggle_active2: |
582 | 262 clrf PLUSW1 ; 0=Disabled, 1=First, 2=Travel, 3=Deco |
263 lfsr FSR1,opt_OC_bail_gas_change+0 | |
264 clrf PLUSW1 ; also delete change depth here to have the menu updated immediately | |
560 | 265 do_toggle_active3: |
582 | 266 movlw .5 |
267 btfsc ccr_diluent_setup ; use OC gases? | |
268 subwf menupos1,F ; back to 1-5 | |
269 bra do_lost_gas ; return to list and show updated result | |
511
7db10ebae205
BUGFIX: Lost Diluent now possible in CCR and PSCR mode
heinrichsweikamp
parents:
502
diff
changeset
|
270 |
0 | 271 |
272 do_dive_pO2: | |
560 | 273 banksel gas6_O2_ratio |
274 incf gas6_O2_ratio,F ; O2++ | |
275 movf gas6_He_ratio,W | |
276 addwf gas6_O2_ratio,W | |
277 movwf gas6_temp | |
278 movlw .101 | |
582 | 279 cpfslt gas6_temp ; O2 + He < 101 ? |
280 decf gas6_O2_ratio,F ; O2-- (unchanged) | |
281 banksel common | |
282 bra do_divemode_gaslist_more_common | |
283 | |
0 | 284 do_dive_mO2: |
582 | 285 banksel gas6_O2_ratio |
286 decf gas6_O2_ratio,F ; O2-- | |
287 movlw gaslist_min_o2 | |
288 cpfslt gas6_O2_ratio ; O2 < minimum allowed %O2? | |
289 bra do_dive_mO2_done ; NO | |
290 movlw gaslist_min_o2 ; YES - restore minimum | |
291 movwf gas6_O2_ratio | |
560 | 292 do_dive_mO2_done: |
582 | 293 banksel common |
294 bra do_divemode_gaslist_more_common | |
0 | 295 |
296 do_dive_pHe: | |
582 | 297 banksel gas6_O2_ratio |
298 incf gas6_He_ratio,F ; He++ | |
299 movf gas6_He_ratio,W | |
300 addwf gas6_O2_ratio,W | |
301 movwf lo | |
302 movlw .101 | |
303 cpfslt lo ; O2 + He < 101 ? | |
304 decf gas6_He_ratio,F ; Yes, He-- (Unchanged) | |
305 banksel common | |
306 bra do_divemode_gaslist_more_common | |
0 | 307 |
308 do_dive_mHe: | |
560 | 309 banksel gas6_O2_ratio |
582 | 310 decf gas6_He_ratio,F ; He-- |
311 bnn do_dive_mHe_done ; H2 < 0? | |
312 clrf gas6_He_ratio ; YES - reset to 0 | |
560 | 313 do_dive_mHe_done: |
582 | 314 banksel common |
315 bra do_divemode_gaslist_more_common | |
316 | |
0 | 317 |
318 do_divemode_splist: | |
560 | 319 bsf short_gas_decriptions |
320 movlw .1 | |
582 | 321 movwf menupos1 ; set to first option in divemode menu |
560 | 322 |
582 | 323 do_divemode_splist_common: |
324 btfsc analog_o2_input ; do we have an analog input? | |
325 bra do_divemode_splist_sensor ; YES | |
326 btfsc s8_digital ; do we have a digital input? | |
327 bra do_divemode_splist_sensor ; YES | |
0 | 328 |
560 | 329 do_divemode_splist_no_sensor: |
582 | 330 MENU_BEGIN tGaslist, .5 |
331 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
332 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
333 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
334 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
335 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
336 MENU_END | |
337 | |
338 do_divemode_splist_sensor: | |
339 MENU_BEGIN tGaslist, .6 | |
340 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
341 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
342 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
343 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
344 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
345 MENU_CALL tCCRSensor, do_divemode_sensor | |
346 MENU_END | |
249 | 347 |
348 | |
0 | 349 do_divemode_sensor: |
560 | 350 clrf menupos3 ; show customview 1 (HUD Data) |
351 bsf toggle_customview | |
582 | 352 movlw .1 |
353 movwf menupos1 ; Set to 1st option: use sensors | |
354 | |
355 do_return_divemode_sensor: | |
356 MENU_BEGIN tGaslist, .6 | |
357 MENU_CALL tDivemenu_UseSensor, do_switch_sensor | |
560 | 358 MENU_CALL tBack, do_divemode_splist |
582 | 359 MENU_CALL tExit, do_exit_divemode_menu |
560 | 360 MENU_CALL tDiveHudMask1, do_toggle_sensor |
361 MENU_CALL tDiveHudMask2, do_toggle_sensor | |
362 MENU_CALL tDiveHudMask3, do_toggle_sensor | |
582 | 363 MENU_END |
0 | 364 |
560 | 365 do_divemode_setpoint_pscr: |
582 | 366 movlw .1 |
367 movwf menupos1 ; Set to 1st option: use calculated ppO2 | |
368 MENU_BEGIN tGaslist, .6 | |
560 | 369 MENU_CALL tCalculated, do_switch_sp_calc |
582 | 370 MENU_CALL tDivemenu_UseSensor, do_switch_sensor |
371 MENU_CALL tExit, do_exit_divemode_menu | |
560 | 372 MENU_CALL tDiveHudMask1, do_toggle_sensor |
373 MENU_CALL tDiveHudMask2, do_toggle_sensor | |
374 MENU_CALL tDiveHudMask3, do_toggle_sensor | |
582 | 375 MENU_END |
376 | |
0 | 377 |
560 | 378 do_toggle_sensor: |
582 | 379 movff menupos1,lo ; backup position |
380 decf menupos1,f ; 4, 5, 6 -> 3, 4, 5 | |
381 decf menupos1,f ; 3, 4, 5 -> 2, 3, 4 | |
382 decf menupos1,f ; 2, 3, 4 -> 1, 2, 3 | |
383 dcfsnz menupos1 ; 1, 2, 3 -> 0, 1, 2 | |
384 btg use_O2_sensor1 ; = | |
385 dcfsnz menupos1 ; 0, 1, 2 -> -1, 0, 1 | |
386 btg use_O2_sensor2 ; = | |
387 dcfsnz menupos1 ; -1,0, 1 -> -2,-1, 0 | |
388 btg use_O2_sensor3 ; = | |
389 movff lo,menupos1 ; restore position | |
390 bra do_return_divemode_sensor | |
560 | 391 |
582 | 392 END |