Mercurial > public > hwos_code
annotate src/divemenu_tree.asm @ 632:0347acdf6d8e
changelog updates
author | heinrichsweikamp |
---|---|
date | Sat, 29 Feb 2020 16:57:45 +0100 |
parents | 185ba2f91f59 |
children | 4050675965ea |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
631 | 3 ; File divemenu_tree.asm combined next generation V3.08.8 |
0 | 4 ; |
275 | 5 ; OSTC dive mode menu |
0 | 6 ; |
623 | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all rights reserved. |
0 | 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 | |
604 | 21 extern restart_deco_engine_wo_ceiling |
623 | 22 extern diveloop_menu_exit |
0 | 23 |
560 | 24 |
623 | 25 dmenu_tree CODE |
582 | 26 |
0 | 27 ;============================================================================= |
631 | 28 ; |
29 ; Dive Mode Menu | |
30 ; | |
604 | 31 |
32 do_return_main_divemenu: | |
33 call menu_processor_double_pop ; drop exit line and back to last line | |
34 incf selected_item,W ; item numbers start with 0, menu positions with 1 | |
623 | 35 movwf menu_pos_cur ; position cursor where we came from |
604 | 36 bra do_main_divemenu_common |
37 | |
582 | 38 global do_main_divemenu |
0 | 39 do_main_divemenu: |
631 | 40 movff active_customview,backup_customview ; back up current custom view |
41 call menu_processor_reset ; restart from first icon | |
42 movlw .1 ; set cursor to first menu item | |
43 movwf menu_pos_cur ; ... | |
604 | 44 |
45 do_main_divemenu_common: | |
623 | 46 IFDEF _ccr_pscr |
560 | 47 btfsc FLAG_ccr_mode |
48 bra main_divemenu_loop ; goto CCR / pSCR Menu menu | |
49 btfsc FLAG_pscr_mode | |
50 bra main_divemenu_loop ; goto CCR / pSCR Menu menu | |
623 | 51 ENDIF |
560 | 52 |
582 | 53 main_divemenu_OC: |
623 | 54 IFDEF _ccr_pscr |
55 bcf is_diluent_menu ; selecting OC gases ... | |
56 bcf is_bailout_menu ; ... not for bailout reason | |
57 ENDIF | |
582 | 58 |
604 | 59 IFDEF _cave_mode |
631 | 60 TSTOSS opt_cave_mode ; cave mode switched on? |
61 bra main_divemenu_OC_nocave ; NO - use version without cave mode entry | |
62 ;bra main_divemenu_OC_cave ; YES - use version with cave mode entry | |
604 | 63 |
631 | 64 main_divemenu_OC_cave: |
604 | 65 MENU_BEGIN tMainMenu, .6 |
66 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | |
67 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
631 | 68 MENU_DYNAMIC label_do_toggle_gf, do_toggle_gf |
604 | 69 MENU_CALL tDivemenu_Marker, do_set_marker |
631 | 70 MENU_CALL tCaveMode, do_main_cavemenu |
604 | 71 MENU_CALL tExit, do_exit_divemode_menu |
72 MENU_END | |
73 ENDIF | |
74 | |
631 | 75 main_divemenu_OC_nocave: |
582 | 76 MENU_BEGIN tMainMenu, .5 |
604 | 77 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist |
78 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
631 | 79 MENU_DYNAMIC label_do_toggle_gf, do_toggle_gf |
604 | 80 MENU_CALL tDivemenu_Marker, do_set_marker |
81 MENU_CALL tExit, do_exit_divemode_menu | |
560 | 82 MENU_END |
0 | 83 |
631 | 84 |
623 | 85 ;============================================================================= |
86 | |
87 IFDEF _ccr_pscr | |
604 | 88 |
560 | 89 main_divemenu_loop: |
623 | 90 bsf is_diluent_menu ; selecting diluents ... |
91 bcf is_bailout_menu ; ... (definitely) not for bailout reason | |
631 | 92 btfsc FLAG_pscr_mode ; in pSCR mode? |
93 bra main_divemenu_pscr ; YES - show pSCR menu | |
582 | 94 |
95 MENU_BEGIN tMainMenu, .6 | |
604 | 96 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
97 MENU_CALL tDivemenu_Setpoint, do_divemode_splist | |
98 MENU_CALL tDivemenu_Diluent, do_divemode_gaslist | |
99 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr | |
631 | 100 MENU_DYNAMIC label_do_toggle_gf, do_toggle_gf |
604 | 101 MENU_CALL tExit, do_exit_divemode_menu |
582 | 102 MENU_END |
103 | |
623 | 104 |
485 | 105 main_divemenu_pscr: |
623 | 106 IFDEF _external_sensor |
604 | 107 btfsc analog_o2_input ; do we have an analog input (OSTC cR)? |
631 | 108 bra main_divemenu_pscr_sensors ; YES - do menu with calibration |
604 | 109 btfsc optical_input ; do we have an optical input (OSTC 3)? |
631 | 110 bra main_divemenu_pscr_sensors ; YES - do menu with calibration |
623 | 111 ENDIF |
560 | 112 |
113 main_divemenu_pscr_no_sensors: | |
582 | 114 MENU_BEGIN tMainMenu, .6 |
604 | 115 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
116 MENU_CALL tDivemenu_Premix, do_divemode_gaslist | |
117 MENU_CALL tBackToLoop, do_switch_sp_calc | |
118 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr | |
631 | 119 MENU_DYNAMIC label_do_toggle_gf, do_toggle_gf |
604 | 120 MENU_CALL tExit, do_exit_divemode_menu |
582 | 121 MENU_END |
122 | |
631 | 123 main_divemenu_pscr_sensors: |
623 | 124 IFDEF _external_sensor |
582 | 125 MENU_BEGIN tMainMenu, .6 |
604 | 126 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
127 MENU_CALL tCCRSensor, do_divemode_setpoint_pscr | |
128 MENU_CALL tDivemenu_Premix, do_divemode_gaslist | |
129 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr | |
631 | 130 MENU_DYNAMIC label_do_toggle_gf, do_toggle_gf |
604 | 131 MENU_CALL tExit, do_exit_divemode_menu |
582 | 132 MENU_END |
623 | 133 ENDIF ; _external_sensor |
582 | 134 |
623 | 135 ENDIF ; _ccr_pscr |
136 | |
137 ;============================================================================= | |
0 | 138 |
631 | 139 |
140 do_return_toggle_gf: | |
141 call menu_processor_pop ; drop selection from menu stack | |
142 bra do_toggle_gf_1 ; re-draw the custom view and enter the menu again | |
143 | |
560 | 144 do_toggle_gf: |
631 | 145 TSTOSS char_I_model ; toggle GF only in GF modes - in GF mode? (0 = ZH-L16, 1 = ZH-L16-GF) |
604 | 146 bra do_main_divemenu_common ; NO - do nothing and return |
582 | 147 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater |
604 | 148 bra do_main_divemenu_common ; NO - do nothing and return |
631 | 149 bsf custom_view_locked ; lock custom view |
150 do_toggle_gf_1: | |
151 movlw index_gf_factors ; get number of GF factors custom view | |
152 movwf active_customview ; set custom view number | |
153 call dive_customview_callup ; draw custom view | |
154 movlw .1 ; set to first option in dive mode menu | |
155 movwf menu_pos_cur ; ... | |
582 | 156 |
157 MENU_BEGIN tDivemenu_ToggleGF, .2 | |
631 | 158 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf_toggle |
159 MENU_CALL tExit, do_exit_divemode_menu | |
582 | 160 MENU_END |
0 | 161 |
631 | 162 do_toggle_gf_toggle: |
163 bsf request_toggle_GF ; set request flag to have the deco engine restarted | |
164 btg use_aGF ; toggle normal / alternative GF factor selection | |
165 btfsc use_aGF ; alternative GF factors activated? | |
166 bra do_togglegf_agf ; YES - branch to using alternative GF | |
167 ;bra do_togglegf_ngf ; NO - branch to using normal GF | |
168 | |
169 do_togglegf_ngf: | |
170 movff opt_GF_low, char_I_GF_Low_percentage ; use normal GF factor low | |
171 movff opt_GF_high,char_I_GF_High_percentage ; use normal GF factor high | |
172 bra do_return_toggle_gf ; back to menu | |
173 | |
174 do_togglegf_agf: | |
175 movff opt_aGF_low, char_I_GF_Low_percentage ; use alternative GF factor low | |
176 movff opt_aGF_high,char_I_GF_High_percentage ; use alternative GF factor high | |
177 bra do_return_toggle_gf ; back to menu | |
582 | 178 |
179 | |
604 | 180 do_reset_avg_set_mkr: |
631 | 181 movlw .1 ; set to first option in dive mode menu |
182 movwf menu_pos_cur ; ... | |
604 | 183 |
184 MENU_BEGIN tDivemenu_Avg_Mkr, .3 | |
185 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
186 MENU_CALL tDivemenu_Marker, do_set_marker | |
187 MENU_CALL tBack, do_return_main_divemenu | |
188 MENU_END | |
189 | |
190 | |
191 do_reset_average: | |
623 | 192 bsf request_reset_avg ; request reset of resettable average depth and dive time |
193 IFDEF _min_depth_option | |
194 bsf reset_trip_pressure ; request ISR to reset the min and max trip-wise pressures | |
195 ENDIF | |
631 | 196 bra do_exit_divemode_menu ; continue exiting the menu |
623 | 197 |
604 | 198 |
560 | 199 do_set_marker: |
623 | 200 bsf request_set_marker ; set request flag |
631 | 201 bra do_exit_divemode_menu ; continue exiting the menu |
623 | 202 |
203 ;============================================================================= | |
204 | |
205 IFDEF _ccr_pscr | |
582 | 206 |
560 | 207 do_switch_sp: ; entry point when coming from manual setpoint selection (CCR) |
623 | 208 decf menu_pos_cur,W ; 1-5 -> 0-4 |
631 | 209 lfsr FSR1,opt_setpoint_cbar ; load base address |
210 movff PLUSW1,char_I_const_ppO2 ; set selected setpoint | |
623 | 211 IFDEF _external_sensor |
582 | 212 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics |
623 | 213 ENDIF |
214 bcf sp_fallback ; clear fallback condition (stops fallback warning) | |
604 | 215 clrf WREG ; switch to fixed SP |
560 | 216 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP |
631 | 217 bra do_switch_sp_com ; continue with common part |
0 | 218 |
623 | 219 |
560 | 220 do_switch_sp_calc: ; entry point when coming from switch to calculated ppO2 (pSCR) |
623 | 221 bcf sp_fallback ; clear fallback condition (stops fallback warning) |
222 clrf WREG ; switch to fixed SP | |
582 | 223 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP |
560 | 224 movff WREG,char_I_const_ppO2 ; set setpoint to 0, this forces deco engine to take the computed ppO2 |
631 | 225 ;bra do_switch_sp_com ; continue with common part |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
226 |
623 | 227 |
228 do_switch_sp_com: ; common part | |
229 bsf event_occured ; set global event byte | |
230 bsf event_SP_change ; set setpoint event flag | |
582 | 231 |
232 ; Clear some flags in case we were in bailout before... | |
623 | 233 bcf bailout_mode ; end bailout mode |
604 | 234 bcf better_gas_available ; =1: a better gas is available and a gas change is advised in dive mode |
235 bcf better_dil_available ; =1: a better diluent is available and a gas change is advised in dive mode | |
623 | 236 bcf better_gas_blinking ; clear blinking flag |
237 bcf better_dil_blinking ; clear blinking flag | |
631 | 238 call dive_customview_callup ; redraw custom view mask to (if applicable) rewrite "ppO2(Dil)" to "ppO2" or SAC label |
0 | 239 |
623 | 240 bsf request_back_to_loop ; indicate that it is a switchback from OC bailout to CCR/pSCR loop |
631 | 241 bsf request_gas_change ; initiate reconfiguration to loop mode on last diluent |
582 | 242 |
631 | 243 bra do_exit_divemode_menu ; continue exiting the menu |
582 | 244 |
0 | 245 |
560 | 246 do_divemode_gaslist_bail: ; entry point from CCR/pSCR to bailout to OC gases |
623 | 247 bcf is_diluent_menu ; select OC gases |
582 | 248 bsf is_bailout_menu ; flag it is a bailout action |
623 | 249 ;bra do_divemode_gaslist |
250 | |
251 ENDIF ; _ccr_pscr | |
252 | |
253 ;============================================================================= | |
254 | |
560 | 255 do_divemode_gaslist: ; entry point for switching: OC -> gases, loop -> diluents |
623 | 256 IFDEF _ccr_pscr |
257 btfsc bailout_mode ; in bailout mode? | |
258 bcf is_diluent_menu ; YES - for safety reasons, redirect to selecting OC (bailout) gases | |
259 ENDIF | |
260 bsf short_gas_descriptions ; do not show "Gas x" etc. | |
604 | 261 bsf better_gas_hint ; mark the gas which is the best gas/diluent |
631 | 262 bsf color_code_gases ; color-code the gases/diluents by their ppO2 and current depth |
604 | 263 movf best_gas_number,W ; load number of best gas (1-5)into WREG |
623 | 264 IFDEF _ccr_pscr |
265 btfsc is_diluent_menu ; in diluent selection? | |
604 | 266 movf best_dil_number,W ; YES - overwrite with best diluent (1-5) |
623 | 267 ENDIF |
604 | 268 bnz do_divemode_gaslist_1 ; best gas/dil number = 0 (none available) ? |
269 movlw .1 ; YES - default to first gas/dil | |
270 btfsc WREG,7 ; best gas/dil number >= 128 (not computed yet) ? | |
271 movlw .1 ; YES - default to first gas/dil | |
272 do_divemode_gaslist_1: | |
623 | 273 movwf menu_pos_cur ; position cursor to best gas/dil (or first option if none avail) |
631 | 274 |
582 | 275 MENU_BEGIN tGaslist, .6 |
604 | 276 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas |
277 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas | |
278 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas | |
279 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas | |
280 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas | |
631 | 281 MENU_CALL tDivemenu_LostGas, do_lost_gas |
582 | 282 MENU_END |
283 | |
0 | 284 |
631 | 285 do_gas6_or_exit: |
286 btfsc gas6_or_EXIT ; shall exit? | |
287 bra do_exit_divemode_menu ; YES - continue exiting menu | |
288 movlw .1 ; NO - select first item | |
289 movwf menu_pos_cur ; - set cursor | |
290 movff char_I_O2_ratio,gas6_O2_ratio ; - initialize gas6 with currently breathed gas - O2 ratio | |
623 | 291 IFDEF _helium |
631 | 292 movff char_I_He_ratio,gas6_He_ratio ; - initialize gas6 with currently breathed gas - He ratio |
623 | 293 ENDIF |
582 | 294 |
295 do_divemode_gaslist_more_common: | |
623 | 296 IFDEF _helium |
582 | 297 MENU_BEGIN tGaslist, .6 |
298 MENU_CALL tO2Plus, do_dive_pO2 | |
299 MENU_CALL tO2Minus, do_dive_mO2 | |
300 MENU_CALL tHePlus, do_dive_pHe | |
301 MENU_CALL tHeMinus, do_dive_mHe | |
302 MENU_DYNAMIC gaslist_strcat_gas6, do_switch_gas6 | |
631 | 303 MENU_CALL tExit, do_exit_divemode_menu |
582 | 304 MENU_END |
623 | 305 ELSE |
306 MENU_BEGIN tGaslist, .4 | |
307 MENU_CALL tO2Plus, do_dive_pO2 | |
308 MENU_CALL tO2Minus, do_dive_mO2 | |
309 MENU_DYNAMIC gaslist_strcat_gas6, do_switch_gas6 | |
310 MENU_CALL tExit, do_exit_divemode_menu | |
311 MENU_END | |
312 ENDIF | |
582 | 313 |
403
6e60012bb3fc
NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents:
401
diff
changeset
|
314 |
6e60012bb3fc
NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents:
401
diff
changeset
|
315 do_lost_gas: |
631 | 316 movlw .1 ; set to first option in dive mode menu |
317 movwf menu_pos_cur ; ... | |
318 bcf gas6_or_EXIT ; default to presenting gas6 option | |
582 | 319 do_lost_gas_common: |
623 | 320 bsf short_gas_descriptions ; do not show "Gas x" etc. |
604 | 321 bcf better_gas_hint ; do not mark the best gas/diluent |
631 | 322 bcf color_code_gases ; do not color-code the gases/diluents by their ppO2 |
323 | |
582 | 324 MENU_BEGIN tDivemenu_LostGas, .6 |
631 | 325 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_staged_lost |
326 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_staged_lost | |
327 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_staged_lost | |
328 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_staged_lost | |
329 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_staged_lost | |
330 MENU_DYNAMIC label_do_gas6_or_exit, do_gas6_or_exit | |
582 | 331 MENU_END |
0 | 332 |
560 | 333 |
334 do_switch_gas6: | |
582 | 335 movlw .6 ; gas 6 |
623 | 336 movwf menu_pos_cur ; transfer register for selected gas towards gas_switched_common |
337 bsf event_gas_change_gas6 ; set flag for profile recording | |
560 | 338 ;bra do_switch_gas ; continue with common gas-switched code |
339 | |
623 | 340 |
560 | 341 do_switch_gas: |
631 | 342 bsf request_gas_change ; initiate gas change, will also trigger restart of deco_engine |
343 IFDEF _ccr_pscr | |
604 | 344 btfss is_bailout_menu ; doing a bailout? |
345 bra do_switch_gas_1 ; NO | |
623 | 346 bsf bailout_mode ; YES - begin bailout mode |
631 | 347 ENDIF |
604 | 348 IFDEF _cave_mode |
631 | 349 btfsc cave_mode ; - cave mode switched on? |
350 bsf request_turn_turn ; YES - request to turn the dive | |
351 ENDIF | |
352 IFDEF _ccr_pscr | |
353 do_switch_gas_1: | |
354 bcf sp_fallback ; terminate fallback mode and get rid of its warning if applicable | |
355 call dive_customview_callup ; redraw custom view mask to rewrite "ppO2(Dil)" to "ppO2" or SAC label if applicable | |
604 | 356 ENDIF |
631 | 357 ; revoke staged and lost state on the selected gas |
358 lfsr FSR1,opt_gas_type ; load base address of gas types | |
359 movff menu_pos_cur,lo ; copy selected gas to lo | |
360 IFDEF _ccr_pscr | |
361 movlw .5 ; load WREG with diluent offset | |
362 btfsc is_diluent_menu ; operating on diluents? | |
363 addwf lo,F ; YES - add diluent offset to shift 1-5 -> 6-10 | |
364 ENDIF ; _ccr_pscr | |
365 decf lo,W ; 1-10 -> 0-4 for gases / 5-9 for diluents with result into WREG | |
366 bcf PLUSW1,gas_lost ; revoke lost state | |
367 IFDEF _cave_mode | |
368 bcf PLUSW1,gas_staged ; revoke staged state | |
369 ENDIF | |
370 ;bra do_exit_divemode_menu ; continue exiting the menu | |
582 | 371 |
623 | 372 |
631 | 373 ; +++ Dive Mode and Cave Mode common exit point +++ |
560 | 374 do_exit_divemode_menu: |
631 | 375 call timeout_divemode_menu2 ; check for timeout and do some cleanup |
376 clrf STKPTR ; reset the stack | |
377 goto diveloop_menu_exit ; back to the dive loop | |
560 | 378 |
379 | |
631 | 380 do_toggle_staged_lost: |
381 movff menu_pos_cur,lo ; copy selected gas/diluent to lo (1-5) | |
382 movf active_gas,W ; copy currently used gas to WREG (1-5) | |
623 | 383 IFDEF _ccr_pscr |
631 | 384 btfsc FLAG_oc_mode ; in OC mode? |
385 bra do_toggle_staged_lost_check ; YES - can't be in diluent menu then, check selected gas against gas in use | |
386 btfsc bailout_mode ; NO - in bailout? | |
387 bra do_toggle_staged_lost_check ; YES - can't be in diluent menu then, check selected gas against bailout gas in use | |
388 btfss is_diluent_menu ; NO - breathing a diluent then, in diluent menu? | |
389 bra do_toggle_staged_lost_exec ; NO - can modify any gas, no need for a check | |
390 movf active_dil,W ; YES - check selected diluent against diluent in use | |
623 | 391 ENDIF |
631 | 392 do_toggle_staged_lost_check: |
393 cpfseq lo ; selected gas/dil = currently used gas/dil? | |
394 bra do_toggle_staged_lost_exec ; NO - can set selected gas/dil to lost or staged | |
395 bra do_lost_gas_common ; YES - gas/dil in use, can not set to lost or staged, back to menu | |
396 do_toggle_staged_lost_exec: | |
604 | 397 lfsr FSR1,opt_gas_type ; load base address of gas types |
631 | 398 bcf better_gas_blinking ; clear blinking flag for gases to avoid "leftovers" |
623 | 399 IFDEF _ccr_pscr |
631 | 400 bcf better_dil_blinking ; clear blinking flag for diluents to avoid "leftovers" |
401 movlw .5 ; load WREG with diluent offset | |
623 | 402 btfsc is_diluent_menu ; operating on diluents? |
631 | 403 addwf lo,F ; YES - add diluent offset to shift 1-5 -> 6-10 |
404 ENDIF ; _ccr_pscr | |
405 IFDEF _cave_mode | |
406 TSTOSS opt_cave_mode ; cave mode switched on? | |
407 bra do_toggle_staged_lost_3 ; NO - just toggle lost state | |
408 decf lo,W ; YES - 1-10 -> 0-4 for gases / 5-9 for diluents with result into WREG | |
409 btfsc PLUSW1,gas_staged ; - gas currently set as staged? | |
410 bra do_toggle_staged_lost_1 ; YES - set as lost now | |
411 btfsc PLUSW1,gas_lost ; NO - gas currently set as lost? | |
412 bra do_toggle_staged_lost_2 ; YES - set as available now | |
413 ;bra do_toggle_staged_lost_0 ; NO - set as staged now | |
414 do_toggle_staged_lost_0: | |
415 bsf PLUSW1,gas_staged ; set staged state | |
416 bra do_toggle_staged_lost_4 ; continue with restarting deco engine | |
417 do_toggle_staged_lost_1: | |
418 bcf PLUSW1,gas_staged ; revoke staged state | |
419 bsf PLUSW1,gas_lost ; set lost state | |
420 bra do_toggle_staged_lost_4 ; continue with restarting deco engine | |
421 do_toggle_staged_lost_2: | |
422 bcf PLUSW1,gas_lost ; revoke lost state | |
423 bra do_toggle_staged_lost_4 ; continue with restarting deco engine | |
424 ENDIF ; _cave_mode | |
425 do_toggle_staged_lost_3: | |
426 decf lo,W ; 1-10 -> 0-4 for gases / 5-9 for diluents with result into WREG | |
427 btg PLUSW1,gas_lost ; toggle lost state | |
428 do_toggle_staged_lost_4: | |
429 bsf request_gas_update ; request to update the gases | |
430 bsf gas6_or_EXIT ; switch 6th menu item from gas6 to exit | |
431 bra do_lost_gas_common ; back to the menu | |
0 | 432 |
623 | 433 |
0 | 434 do_dive_pO2: |
631 | 435 incf gas6_O2_ratio,F ; increment O2 % |
623 | 436 IFDEF _helium |
631 | 437 movf gas6_He_ratio,W ; get He % |
438 addwf gas6_O2_ratio,W ; add O2 % | |
623 | 439 ELSE |
631 | 440 movf gas6_O2_ratio,W ; get O2 % |
623 | 441 ENDIF |
631 | 442 movwf lo ; copy to lo |
443 movlw .101 ; O2 + He < 101 | |
444 cpfslt lo ; ... ? | |
445 decf gas6_O2_ratio,F ; NO - decrement O2 again | |
582 | 446 bra do_divemode_gaslist_more_common |
447 | |
623 | 448 |
0 | 449 do_dive_mO2: |
631 | 450 decf gas6_O2_ratio,F ; decrement O2 % |
451 movlw gaslist_min_o2 ; get minimum value | |
623 | 452 cpfslt gas6_O2_ratio ; O2 < minimum allowed %O2 ? |
631 | 453 bra do_dive_mO2_done ; NO - value is valid |
454 movwf gas6_O2_ratio ; YES - set O2 % to minimum | |
560 | 455 do_dive_mO2_done: |
582 | 456 bra do_divemode_gaslist_more_common |
0 | 457 |
623 | 458 ;============================================================================= |
459 | |
460 IFDEF _helium | |
461 | |
0 | 462 do_dive_pHe: |
631 | 463 incf gas6_He_ratio,F ; increment He % |
464 movf gas6_He_ratio,W ; get He % | |
465 addwf gas6_O2_ratio,W ; add O2 % | |
466 movwf lo ; copy to lo | |
467 movlw .101 ; O2 + He < 101 | |
468 cpfslt lo ; ... ? | |
469 decf gas6_He_ratio,F ; YES - decrement He again | |
582 | 470 bra do_divemode_gaslist_more_common |
0 | 471 |
472 do_dive_mHe: | |
631 | 473 decf gas6_He_ratio,F ; decrement He % |
623 | 474 bnn do_dive_mHe_done ; H2 < 0 ? |
582 | 475 clrf gas6_He_ratio ; YES - reset to 0 |
560 | 476 do_dive_mHe_done: |
582 | 477 bra do_divemode_gaslist_more_common |
478 | |
623 | 479 ENDIF |
480 | |
481 ;============================================================================= | |
482 | |
483 IFDEF _ccr_pscr | |
0 | 484 |
485 do_divemode_splist: | |
623 | 486 bsf short_gas_descriptions ; do not show "SP" etc. |
487 movlw .1 ; default to first menu item | |
488 movff opt_ccr_mode,lo ; get CCR mode (0: Fixed SP, 1: Sensor, 2: Auto SP) | |
489 dcfsnz lo,F ; mode = sensor ? | |
490 movlw .6 ; YES - load menu item number for 'sensor' | |
491 btfsc sp_fallback ; in fallback condition? | |
492 movlw .1 ; YES - revert to first menu item | |
493 movwf menu_pos_cur ; set cursor position | |
560 | 494 |
582 | 495 do_divemode_splist_common: |
623 | 496 |
497 IFDEF _external_sensor | |
498 btfsc analog_o2_input ; do we have an analog or S8 digital input (OSTC cR)? | |
582 | 499 bra do_divemode_splist_sensor ; YES |
604 | 500 btfsc optical_input ; do we have an optical input (OSTC 3)? |
582 | 501 bra do_divemode_splist_sensor ; YES |
623 | 502 ENDIF |
0 | 503 |
560 | 504 do_divemode_splist_no_sensor: |
582 | 505 MENU_BEGIN tGaslist, .5 |
506 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
507 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
508 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
509 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
510 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
511 MENU_END | |
512 | |
623 | 513 |
514 IFDEF _external_sensor | |
515 | |
582 | 516 do_divemode_splist_sensor: |
517 MENU_BEGIN tGaslist, .6 | |
518 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
519 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
520 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
521 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
522 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
523 MENU_CALL tCCRSensor, do_divemode_sensor | |
524 MENU_END | |
249 | 525 |
526 | |
0 | 527 do_divemode_sensor: |
631 | 528 movlw index_ppo2_sensors ; number of ppO2 sensors custom view |
529 movwf active_customview ; set the custom view number | |
530 call dive_customview_callup ; call-up the custom view | |
531 movlw .1 ; set to 1st option: use sensors | |
532 movwf menu_pos_cur ; ... | |
582 | 533 |
534 do_return_divemode_sensor: | |
535 MENU_BEGIN tGaslist, .6 | |
536 MENU_CALL tDivemenu_UseSensor, do_switch_sensor | |
560 | 537 MENU_CALL tBack, do_divemode_splist |
582 | 538 MENU_CALL tExit, do_exit_divemode_menu |
560 | 539 MENU_CALL tDiveHudMask1, do_toggle_sensor |
540 MENU_CALL tDiveHudMask2, do_toggle_sensor | |
541 MENU_CALL tDiveHudMask3, do_toggle_sensor | |
582 | 542 MENU_END |
0 | 543 |
560 | 544 do_divemode_setpoint_pscr: |
582 | 545 movlw .1 |
623 | 546 movwf menu_pos_cur ; set to 1st option: use calculated ppO2 |
631 | 547 |
582 | 548 MENU_BEGIN tGaslist, .6 |
560 | 549 MENU_CALL tCalculated, do_switch_sp_calc |
582 | 550 MENU_CALL tDivemenu_UseSensor, do_switch_sensor |
551 MENU_CALL tExit, do_exit_divemode_menu | |
560 | 552 MENU_CALL tDiveHudMask1, do_toggle_sensor |
553 MENU_CALL tDiveHudMask2, do_toggle_sensor | |
554 MENU_CALL tDiveHudMask3, do_toggle_sensor | |
582 | 555 MENU_END |
556 | |
631 | 557 do_switch_sensor: ; entry point when coming from switch to sensor |
558 movlw .1 ; switch to sensor | |
559 movff WREG,opt_ccr_mode ; =0: fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP | |
560 bra do_switch_sp_com ; continue with common part | |
0 | 561 |
560 | 562 do_toggle_sensor: |
623 | 563 movff menu_pos_cur,lo ; backup position |
564 decf menu_pos_cur,f ; 4, 5, 6 -> 3, 4, 5 | |
565 decf menu_pos_cur,f ; 3, 4, 5 -> 2, 3, 4 | |
566 decf menu_pos_cur,f ; 2, 3, 4 -> 1, 2, 3 | |
567 dcfsnz menu_pos_cur ; 1, 2, 3 -> 0, 1, 2 | |
631 | 568 btg use_O2_sensor1 ; = |
623 | 569 dcfsnz menu_pos_cur ; 0, 1, 2 -> -1, 0, 1 |
631 | 570 btg use_O2_sensor2 ; = |
623 | 571 dcfsnz menu_pos_cur ; -1,0, 1 -> -2,-1, 0 |
631 | 572 btg use_O2_sensor3 ; = |
623 | 573 movff lo,menu_pos_cur ; restore position |
582 | 574 bra do_return_divemode_sensor |
560 | 575 |
623 | 576 ENDIF ; _external_sensor |
577 ENDIF ; _ccr_pscr | |
578 | |
579 ;============================================================================= | |
631 | 580 ; |
581 ; Cave Mode Menu | |
582 ; | |
583 | |
584 IFDEF _cave_mode | |
585 | |
586 do_return_main_cavemenu: | |
587 call menu_processor_pop ; drop selection from menu stack | |
588 incf selected_item,W ; item numbers start with 0, menu positions with 1 | |
589 movwf menu_pos_cur ; position cursor where we came from | |
590 bra do_main_cavemenu_common ; continue with common part | |
591 | |
592 global do_main_cavemenu | |
593 do_main_cavemenu: | |
594 bsf custom_view_locked ; lock custom view | |
595 movff active_customview,backup_customview ; back up current custom view | |
596 call menu_processor_reset ; restart from first icon | |
597 movlw .1 ; set cursor to first menu item by default | |
598 btfsc dive_turned ; dive turned ? | |
599 movlw .4 ; YES - set cursor on waypoint out item | |
600 btfss cave_mode ; cave mode switched off ? | |
601 movlw .3 ; YES - set cursor on cave mode off/on menu item | |
602 movwf menu_pos_cur ; actually set cursor position | |
603 | |
604 ; The helper functions for MENU_DYNAMIC can be found in | |
605 ; gaslist.asm as it does not work to include them here. | |
606 | |
607 do_main_cavemenu_common: | |
608 movlw index_cave_waypoints ; get number of cave waypoints custom view | |
609 movwf active_customview ; set custom view number | |
610 call dive_customview_callup ; draw custom view | |
611 | |
612 MENU_BEGIN tMainMenu, .6 | |
613 MENU_DYNAMIC label_do_wp_set, do_waypoint_set ; 1 | |
614 MENU_DYNAMIC label_do_turn_dive, do_turndive_toggle ; 2 | |
615 MENU_CALL tDivemenu_off_on, do_cavemode_toggle ; 3 | |
616 MENU_DYNAMIC label_do_wp_out, do_waypoint_out ; 4 | |
617 MENU_DYNAMIC label_do_wp_in, do_waypoint_in ; 5 | |
618 MENU_CALL tExit, do_exit_divemode_menu ; 6 | |
619 MENU_END | |
620 | |
621 | |
622 do_waypoint_set: | |
623 bsf request_waypoint_set ; set request flag | |
624 bra do_return_main_cavemenu ; back to menu | |
625 | |
626 do_turndive_toggle: | |
627 bsf request_turn_toggle ; set request flag | |
628 bra do_return_main_cavemenu ; back to menu | |
629 | |
630 do_cavemode_toggle: | |
631 bsf request_cave_toggle ; set request flag | |
632 bra do_return_main_cavemenu ; back to menu | |
633 | |
634 do_waypoint_out: | |
635 bsf request_waypoint_out ; set request flag | |
636 bra do_return_main_cavemenu ; back to menu | |
637 | |
638 do_waypoint_in: | |
639 bsf request_waypoint_in ; set request flag | |
640 bra do_return_main_cavemenu ; back to menu | |
641 | |
642 ENDIF ; _cave_mode | |
643 | |
644 ;============================================================================= | |
623 | 645 |
646 END |