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