Mercurial > public > hwos_code
annotate src/divemenu_tree.asm @ 634:4050675965ea
3.10 stable release
author | heinrichsweikamp |
---|---|
date | Tue, 28 Apr 2020 17:34:31 +0200 |
parents | 185ba2f91f59 |
children | 8c1f1f334275 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
634 | 3 ; File divemenu_tree.asm * combined next generation V3.09.5 |
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 | |
634 | 12 |
13 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
14 ; | |
15 ; ATTENTION | |
16 ; | |
17 ; All Calls made via the Menu Macros need to go to Addresses within 0x0xxxx ! | |
18 ; | |
19 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
20 | |
21 | |
22 #include "hwos.inc" | |
23 #include "shared_definitions.h" | |
582 | 24 #include "menu_processor.inc" |
25 #include "tft_outputs.inc" | |
26 #include "customview.inc" | |
27 #include "strings.inc" | |
28 #include "calibrate.inc" | |
634 | 29 #include "gaslist.inc" |
30 #include "colorschemes.inc" | |
0 | 31 |
560 | 32 |
634 | 33 extern diveloop_menu_exit |
34 | |
35 IFDEF _cave_mode | |
36 extern cavemode_turndive_check | |
37 extern cavemode_waypoint_set_check | |
38 extern cavemode_waypoint_out_check | |
39 extern cavemode_waypoint_in_check | |
40 ENDIF | |
41 | |
582 | 42 |
0 | 43 ;============================================================================= |
634 | 44 dive_menu CODE 0x02000 ; needs to be at 0x0xxxx |
45 ;============================================================================= | |
46 | |
47 | |
48 ;----------------------------------------------------------------------------- | |
49 ; Return to Main Dive Mode Menu | |
631 | 50 ; |
604 | 51 do_return_main_divemenu: |
52 call menu_processor_double_pop ; drop exit line and back to last line | |
53 incf selected_item,W ; item numbers start with 0, menu positions with 1 | |
623 | 54 movwf menu_pos_cur ; position cursor where we came from |
634 | 55 bra do_main_divemenu_common ; continue with common part |
56 | |
604 | 57 |
634 | 58 ;----------------------------------------------------------------------------- |
59 ; Entry Point for Main Dive Mode Menu | |
60 ; | |
582 | 61 global do_main_divemenu |
0 | 62 do_main_divemenu: |
631 | 63 movff active_customview,backup_customview ; back up current custom view |
64 call menu_processor_reset ; restart from first icon | |
65 movlw .1 ; set cursor to first menu item | |
66 movwf menu_pos_cur ; ... | |
634 | 67 ;bra do_main_divemenu_common ; continue with common part |
604 | 68 |
634 | 69 |
70 ;----------------------------------------------------------------------------- | |
71 ; Common Part for Main Dive Mode Menu, 1st Layer | |
72 ; | |
604 | 73 do_main_divemenu_common: |
623 | 74 IFDEF _ccr_pscr |
634 | 75 btfsc FLAG_ccr_mode ; in CCR mode? |
76 bra main_divemenu_loop ; YES - goto CCR / pSCR Menu menu | |
77 btfsc FLAG_pscr_mode ; in pSCR mode? | |
78 bra main_divemenu_loop ; YES - goto CCR / pSCR Menu menu | |
79 ENDIF ; _ccr_pscr | |
560 | 80 |
582 | 81 main_divemenu_OC: |
623 | 82 IFDEF _ccr_pscr |
83 bcf is_diluent_menu ; selecting OC gases ... | |
84 bcf is_bailout_menu ; ... not for bailout reason | |
634 | 85 ENDIF ; _ccr_pscr |
582 | 86 |
604 | 87 IFDEF _cave_mode |
631 | 88 TSTOSS opt_cave_mode ; cave mode switched on? |
89 bra main_divemenu_OC_nocave ; NO - use version without cave mode entry | |
90 ;bra main_divemenu_OC_cave ; YES - use version with cave mode entry | |
604 | 91 |
631 | 92 main_divemenu_OC_cave: |
634 | 93 MENU_BEGIN_DIVE .6 |
604 | 94 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist |
95 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
634 | 96 MENU_DYNAMIC dyn_toggle_gf, do_toggle_gf |
604 | 97 MENU_CALL tDivemenu_Marker, do_set_marker |
631 | 98 MENU_CALL tCaveMode, do_main_cavemenu |
604 | 99 MENU_CALL tExit, do_exit_divemode_menu |
100 MENU_END | |
634 | 101 ENDIF ; _cave_mode |
604 | 102 |
631 | 103 main_divemenu_OC_nocave: |
634 | 104 MENU_BEGIN_DIVE .5 |
604 | 105 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist |
106 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
634 | 107 MENU_DYNAMIC dyn_toggle_gf, do_toggle_gf |
604 | 108 MENU_CALL tDivemenu_Marker, do_set_marker |
109 MENU_CALL tExit, do_exit_divemode_menu | |
560 | 110 MENU_END |
0 | 111 |
623 | 112 IFDEF _ccr_pscr |
604 | 113 |
560 | 114 main_divemenu_loop: |
623 | 115 bsf is_diluent_menu ; selecting diluents ... |
116 bcf is_bailout_menu ; ... (definitely) not for bailout reason | |
631 | 117 btfsc FLAG_pscr_mode ; in pSCR mode? |
118 bra main_divemenu_pscr ; YES - show pSCR menu | |
582 | 119 |
634 | 120 MENU_BEGIN_DIVE .6 |
604 | 121 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
122 MENU_CALL tDivemenu_Setpoint, do_divemode_splist | |
123 MENU_CALL tDivemenu_Diluent, do_divemode_gaslist | |
124 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr | |
634 | 125 MENU_DYNAMIC dyn_toggle_gf, do_toggle_gf |
604 | 126 MENU_CALL tExit, do_exit_divemode_menu |
582 | 127 MENU_END |
128 | |
623 | 129 |
485 | 130 main_divemenu_pscr: |
623 | 131 IFDEF _external_sensor |
634 | 132 btfsc ext_input_s8_ana ; do we have an S8/analog input (OSTC cR)? |
631 | 133 bra main_divemenu_pscr_sensors ; YES - do menu with calibration |
634 | 134 btfsc ext_input_optical ; do we have an optical input (OSTC 3)? |
631 | 135 bra main_divemenu_pscr_sensors ; YES - do menu with calibration |
634 | 136 ENDIF ; _external_sensor |
560 | 137 |
138 main_divemenu_pscr_no_sensors: | |
634 | 139 MENU_BEGIN_DIVE .6 |
604 | 140 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
141 MENU_CALL tDivemenu_Premix, do_divemode_gaslist | |
142 MENU_CALL tBackToLoop, do_switch_sp_calc | |
143 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr | |
634 | 144 MENU_DYNAMIC dyn_toggle_gf, do_toggle_gf |
604 | 145 MENU_CALL tExit, do_exit_divemode_menu |
582 | 146 MENU_END |
147 | |
634 | 148 IFDEF _external_sensor |
631 | 149 main_divemenu_pscr_sensors: |
634 | 150 MENU_BEGIN_DIVE .6 |
604 | 151 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
152 MENU_CALL tCCRSensor, do_divemode_setpoint_pscr | |
153 MENU_CALL tDivemenu_Premix, do_divemode_gaslist | |
154 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr | |
634 | 155 MENU_DYNAMIC dyn_toggle_gf, do_toggle_gf |
604 | 156 MENU_CALL tExit, do_exit_divemode_menu |
582 | 157 MENU_END |
623 | 158 ENDIF ; _external_sensor |
582 | 159 |
634 | 160 |
161 ;----------------------------------------------------------------------------- | |
162 ; Call Function - start Bailout Condition | |
163 ; | |
164 do_divemode_gaslist_bail: | |
165 bcf is_diluent_menu ; select OC gases | |
166 bsf is_bailout_menu ; flag it is a bailout action | |
167 bra do_divemode_gaslist ; continue with the gas menu for B/O gas selection | |
168 | |
169 | |
170 ;----------------------------------------------------------------------------- | |
171 ; Call Function - switch to calculated Setpoint (pSCR) | |
172 ; | |
173 do_switch_sp_calc: | |
174 bcf warn_det_sensors_lost ; clear fallback condition (revoke all sensors lost warning) | |
175 clrf WREG ; switch to fixed SP | |
176 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP | |
177 movff WREG,char_I_const_ppO2 ; set setpoint to 0, this forces deco engine to take the computed ppO2 | |
178 bra do_switch_sp_com ; continue with common part | |
179 | |
623 | 180 ENDIF ; _ccr_pscr |
181 | |
634 | 182 |
183 ;----------------------------------------------------------------------------- | |
184 ; dynamic Title - toggle GF | |
185 ; | |
186 dyn_toggle_gf: | |
187 movff char_I_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF | |
188 decfsz WREG,W ; toggle GF only in GF modes - in GF mode? | |
189 bra dyn_toggle_gf_1 ; NO - print in disabled color | |
190 TSTOSS opt_enable_aGF ; YES - aGF enabled? | |
191 dyn_toggle_gf_1: | |
192 FONT_COLOR_DISABLED ; NO - print in disabled color | |
193 STRCAT_TEXT tDivemenu_ToggleGF ; output label | |
194 return ; done | |
0 | 195 |
631 | 196 |
634 | 197 ;----------------------------------------------------------------------------- |
198 ; Sub-Menu: Toggle GFs | |
199 ; | |
631 | 200 do_return_toggle_gf: |
201 call menu_processor_pop ; drop selection from menu stack | |
202 bra do_toggle_gf_1 ; re-draw the custom view and enter the menu again | |
203 | |
560 | 204 do_toggle_gf: |
631 | 205 TSTOSS char_I_model ; toggle GF only in GF modes - in GF mode? (0 = ZH-L16, 1 = ZH-L16-GF) |
634 | 206 bra do_abort_toggle_gf ; NO - do nothing and return |
207 TSTOSS opt_enable_aGF ; aGF enabled? | |
208 bra do_abort_toggle_gf ; NO - do nothing and return | |
631 | 209 bsf custom_view_locked ; lock custom view |
210 do_toggle_gf_1: | |
211 movlw index_gf_factors ; get number of GF factors custom view | |
212 movwf active_customview ; set custom view number | |
213 call dive_customview_callup ; draw custom view | |
214 movlw .1 ; set to first option in dive mode menu | |
215 movwf menu_pos_cur ; ... | |
582 | 216 |
634 | 217 MENU_BEGIN_DIVE .2 |
631 | 218 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf_toggle |
219 MENU_CALL tExit, do_exit_divemode_menu | |
582 | 220 MENU_END |
0 | 221 |
634 | 222 |
223 ;----------------------------------------------------------------------------- | |
224 ; Helper Function - abort toggle GF Sub-Menu | |
225 ; | |
226 do_abort_toggle_gf: | |
227 call menu_processor_pop ; drop selection from menu stack | |
228 bra do_main_divemenu_common ; back to main menu | |
229 | |
230 | |
231 ;----------------------------------------------------------------------------- | |
232 ; Call Function - toggle GF <-> aGF | |
233 ; | |
631 | 234 do_toggle_gf_toggle: |
634 | 235 bsf request_toggle_GF ; request restart of the deco engine |
631 | 236 btg use_aGF ; toggle normal / alternative GF factor selection |
237 btfsc use_aGF ; alternative GF factors activated? | |
238 bra do_togglegf_agf ; YES - branch to using alternative GF | |
239 ;bra do_togglegf_ngf ; NO - branch to using normal GF | |
240 do_togglegf_ngf: | |
241 movff opt_GF_low, char_I_GF_Low_percentage ; use normal GF factor low | |
242 movff opt_GF_high,char_I_GF_High_percentage ; use normal GF factor high | |
243 bra do_return_toggle_gf ; back to menu | |
244 do_togglegf_agf: | |
245 movff opt_aGF_low, char_I_GF_Low_percentage ; use alternative GF factor low | |
246 movff opt_aGF_high,char_I_GF_High_percentage ; use alternative GF factor high | |
247 bra do_return_toggle_gf ; back to menu | |
582 | 248 |
249 | |
634 | 250 ;----------------------------------------------------------------------------- |
251 ; Sub-Menu: Reset average Depth & set Marker | |
252 ; | |
604 | 253 do_reset_avg_set_mkr: |
631 | 254 movlw .1 ; set to first option in dive mode menu |
255 movwf menu_pos_cur ; ... | |
604 | 256 |
634 | 257 MENU_BEGIN_DIVE .3 |
604 | 258 MENU_CALL tDivemenu_ResetAvg, do_reset_average |
259 MENU_CALL tDivemenu_Marker, do_set_marker | |
634 | 260 MENU_CALL tBack, do_return_main_divemenu ; return to main menu |
604 | 261 MENU_END |
262 | |
263 | |
634 | 264 ;----------------------------------------------------------------------------- |
265 ; Call Function - reset average Depth | |
266 ; | |
604 | 267 do_reset_average: |
623 | 268 bsf request_reset_avg ; request reset of resettable average depth and dive time |
269 IFDEF _min_depth_option | |
270 bsf reset_trip_pressure ; request ISR to reset the min and max trip-wise pressures | |
271 ENDIF | |
631 | 272 bra do_exit_divemode_menu ; continue exiting the menu |
623 | 273 |
604 | 274 |
634 | 275 ;----------------------------------------------------------------------------- |
276 ; Call Function - set a Marker in the Dive Profile Recording | |
277 ; | |
560 | 278 do_set_marker: |
623 | 279 bsf request_set_marker ; set request flag |
631 | 280 bra do_exit_divemode_menu ; continue exiting the menu |
623 | 281 |
282 | |
634 | 283 ;----------------------------------------------------------------------------- |
284 ; Sub-Menu: Switch OC / Diluent Selection | |
285 ; | |
286 do_divemode_gaslist: | |
623 | 287 IFDEF _ccr_pscr |
288 btfsc bailout_mode ; in bailout mode? | |
289 bcf is_diluent_menu ; YES - for safety reasons, redirect to selecting OC (bailout) gases | |
634 | 290 ENDIF ; _ccr_pscr |
623 | 291 bsf short_gas_descriptions ; do not show "Gas x" etc. |
604 | 292 bsf better_gas_hint ; mark the gas which is the best gas/diluent |
631 | 293 bsf color_code_gases ; color-code the gases/diluents by their ppO2 and current depth |
604 | 294 movf best_gas_number,W ; load number of best gas (1-5)into WREG |
623 | 295 IFDEF _ccr_pscr |
296 btfsc is_diluent_menu ; in diluent selection? | |
604 | 297 movf best_dil_number,W ; YES - overwrite with best diluent (1-5) |
634 | 298 ENDIF; _ccr_pscr |
604 | 299 bnz do_divemode_gaslist_1 ; best gas/dil number = 0 (none available) ? |
300 movlw .1 ; YES - default to first gas/dil | |
301 btfsc WREG,7 ; best gas/dil number >= 128 (not computed yet) ? | |
302 movlw .1 ; YES - default to first gas/dil | |
303 do_divemode_gaslist_1: | |
623 | 304 movwf menu_pos_cur ; position cursor to best gas/dil (or first option if none avail) |
631 | 305 |
634 | 306 MENU_BEGIN_DIVE .6 |
307 MENU_DYNAMIC dyn_strcat_gas_prodl, do_switch_gas | |
308 MENU_DYNAMIC dyn_strcat_gas_prodl, do_switch_gas | |
309 MENU_DYNAMIC dyn_strcat_gas_prodl, do_switch_gas | |
310 MENU_DYNAMIC dyn_strcat_gas_prodl, do_switch_gas | |
311 MENU_DYNAMIC dyn_strcat_gas_prodl, do_switch_gas | |
631 | 312 MENU_CALL tDivemenu_LostGas, do_lost_gas |
582 | 313 MENU_END |
314 | |
0 | 315 |
634 | 316 ;----------------------------------------------------------------------------- |
317 ; dynamic Title - print full Gas Description | |
318 ; | |
319 dyn_strcat_gas_prodl: | |
320 goto gaslist_strcat_gas_PRODL ; code is hosted in gaslist.asm | |
582 | 321 |
403
6e60012bb3fc
NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents:
401
diff
changeset
|
322 |
634 | 323 ;----------------------------------------------------------------------------- |
324 ; Call Function - initiate Gas Change (will also trigger restart of deco_engine) | |
325 ; | |
560 | 326 do_switch_gas: |
634 | 327 bsf request_gas_change ; request dive mode to do a gas change |
631 | 328 IFDEF _ccr_pscr |
604 | 329 btfss is_bailout_menu ; doing a bailout? |
330 bra do_switch_gas_1 ; NO | |
623 | 331 bsf bailout_mode ; YES - begin bailout mode |
634 | 332 ENDIF ; _ccr_pscr |
604 | 333 IFDEF _cave_mode |
631 | 334 btfsc cave_mode ; - cave mode switched on? |
335 bsf request_turn_turn ; YES - request to turn the dive | |
634 | 336 ENDIF ; _cave_mode |
631 | 337 IFDEF _ccr_pscr |
338 do_switch_gas_1: | |
634 | 339 bcf warn_det_sensors_lost ; terminate fallback mode and get rid of its warning if applicable |
631 | 340 call dive_customview_callup ; redraw custom view mask to rewrite "ppO2(Dil)" to "ppO2" or SAC label if applicable |
634 | 341 ENDIF ; _ccr_pscr |
631 | 342 ; revoke staged and lost state on the selected gas |
343 lfsr FSR1,opt_gas_type ; load base address of gas types | |
344 movff menu_pos_cur,lo ; copy selected gas to lo | |
345 IFDEF _ccr_pscr | |
346 movlw .5 ; load WREG with diluent offset | |
347 btfsc is_diluent_menu ; operating on diluents? | |
348 addwf lo,F ; YES - add diluent offset to shift 1-5 -> 6-10 | |
349 ENDIF ; _ccr_pscr | |
350 decf lo,W ; 1-10 -> 0-4 for gases / 5-9 for diluents with result into WREG | |
351 bcf PLUSW1,gas_lost ; revoke lost state | |
352 IFDEF _cave_mode | |
353 bcf PLUSW1,gas_staged ; revoke staged state | |
634 | 354 ENDIF ; _cave_mode |
355 bra do_exit_divemode_menu ; continue exiting the menu | |
582 | 356 |
623 | 357 |
634 | 358 ;----------------------------------------------------------------------------- |
359 ; Sub-Menu: lost / staged Gas | |
360 ; | |
361 do_lost_gas: | |
362 movlw .1 ; set to first option in dive mode menu | |
363 movwf menu_pos_cur ; ... | |
364 bcf gas6_or_EXIT ; default to presenting gas6 option | |
365 do_lost_gas_common: | |
366 bsf short_gas_descriptions ; do not show "Gas x" etc. | |
367 bcf better_gas_hint ; do not mark the best gas/diluent | |
368 bcf color_code_gases ; do not color-code the gases/diluents by their ppO2 | |
369 | |
370 MENU_BEGIN_DIVE .6 | |
371 MENU_DYNAMIC dyn_strcat_gas_prodl, do_toggle_staged_lost | |
372 MENU_DYNAMIC dyn_strcat_gas_prodl, do_toggle_staged_lost | |
373 MENU_DYNAMIC dyn_strcat_gas_prodl, do_toggle_staged_lost | |
374 MENU_DYNAMIC dyn_strcat_gas_prodl, do_toggle_staged_lost | |
375 MENU_DYNAMIC dyn_strcat_gas_prodl, do_toggle_staged_lost | |
376 MENU_DYNAMIC dyn_gas6_or_exit, do_gas6_or_exit | |
377 MENU_END | |
560 | 378 |
379 | |
634 | 380 ;----------------------------------------------------------------------------- |
381 ; dynamic Title - print full Gas Description | |
382 ; | |
383 ;dyn_strcat_gas_prodl: | |
384 ; goto gaslist_strcat_gas_PRODL ; code is hosted in gaslist.asm | |
385 | |
386 | |
387 ;----------------------------------------------------------------------------- | |
388 ; Call Function - toggle a Gas between available, lost and staged | |
389 ; | |
631 | 390 do_toggle_staged_lost: |
391 movff menu_pos_cur,lo ; copy selected gas/diluent to lo (1-5) | |
392 movf active_gas,W ; copy currently used gas to WREG (1-5) | |
623 | 393 IFDEF _ccr_pscr |
631 | 394 btfsc FLAG_oc_mode ; in OC mode? |
395 bra do_toggle_staged_lost_check ; YES - can't be in diluent menu then, check selected gas against gas in use | |
396 btfsc bailout_mode ; NO - in bailout? | |
397 bra do_toggle_staged_lost_check ; YES - can't be in diluent menu then, check selected gas against bailout gas in use | |
398 btfss is_diluent_menu ; NO - breathing a diluent then, in diluent menu? | |
399 bra do_toggle_staged_lost_exec ; NO - can modify any gas, no need for a check | |
400 movf active_dil,W ; YES - check selected diluent against diluent in use | |
634 | 401 ENDIF ; _ccr_pscr |
631 | 402 do_toggle_staged_lost_check: |
403 cpfseq lo ; selected gas/dil = currently used gas/dil? | |
404 bra do_toggle_staged_lost_exec ; NO - can set selected gas/dil to lost or staged | |
405 bra do_lost_gas_common ; YES - gas/dil in use, can not set to lost or staged, back to menu | |
406 do_toggle_staged_lost_exec: | |
604 | 407 lfsr FSR1,opt_gas_type ; load base address of gas types |
631 | 408 bcf better_gas_blinking ; clear blinking flag for gases to avoid "leftovers" |
623 | 409 IFDEF _ccr_pscr |
631 | 410 bcf better_dil_blinking ; clear blinking flag for diluents to avoid "leftovers" |
411 movlw .5 ; load WREG with diluent offset | |
623 | 412 btfsc is_diluent_menu ; operating on diluents? |
631 | 413 addwf lo,F ; YES - add diluent offset to shift 1-5 -> 6-10 |
414 ENDIF ; _ccr_pscr | |
415 IFDEF _cave_mode | |
416 TSTOSS opt_cave_mode ; cave mode switched on? | |
417 bra do_toggle_staged_lost_3 ; NO - just toggle lost state | |
418 decf lo,W ; YES - 1-10 -> 0-4 for gases / 5-9 for diluents with result into WREG | |
419 btfsc PLUSW1,gas_staged ; - gas currently set as staged? | |
420 bra do_toggle_staged_lost_1 ; YES - set as lost now | |
421 btfsc PLUSW1,gas_lost ; NO - gas currently set as lost? | |
422 bra do_toggle_staged_lost_2 ; YES - set as available now | |
423 ;bra do_toggle_staged_lost_0 ; NO - set as staged now | |
424 do_toggle_staged_lost_0: | |
425 bsf PLUSW1,gas_staged ; set staged state | |
426 bra do_toggle_staged_lost_4 ; continue with restarting deco engine | |
427 do_toggle_staged_lost_1: | |
428 bcf PLUSW1,gas_staged ; revoke staged state | |
429 bsf PLUSW1,gas_lost ; set lost state | |
430 bra do_toggle_staged_lost_4 ; continue with restarting deco engine | |
431 do_toggle_staged_lost_2: | |
432 bcf PLUSW1,gas_lost ; revoke lost state | |
433 bra do_toggle_staged_lost_4 ; continue with restarting deco engine | |
434 ENDIF ; _cave_mode | |
435 do_toggle_staged_lost_3: | |
436 decf lo,W ; 1-10 -> 0-4 for gases / 5-9 for diluents with result into WREG | |
437 btg PLUSW1,gas_lost ; toggle lost state | |
438 do_toggle_staged_lost_4: | |
439 bsf request_gas_update ; request to update the gases | |
440 bsf gas6_or_EXIT ; switch 6th menu item from gas6 to exit | |
441 bra do_lost_gas_common ; back to the menu | |
0 | 442 |
623 | 443 |
634 | 444 ;----------------------------------------------------------------------------- |
445 ; dynamic Title - print Gas 6 Item or Exit Item | |
446 ; | |
447 dyn_gas6_or_exit: | |
448 btfsc gas6_or_EXIT ; shall print exit? | |
449 bra dyn_gas6_or_exit_1 ; YES - print exit label | |
450 STRCAT_TEXT tGas6 ; NO - print gas 6 label | |
451 return ; - done | |
452 dyn_gas6_or_exit_1: | |
453 STRCAT_TEXT tExit ; print exit label | |
454 return ; done | |
455 | |
456 | |
457 ;----------------------------------------------------------------------------- | |
458 ; Sub-Menu: Gas 6 / Menu-Exit | |
459 ; | |
460 do_gas6_or_exit: | |
461 btfsc gas6_or_EXIT ; shall exit? | |
462 bra do_exit_divemode_menu ; YES - exit the menu | |
463 movlw .1 ; NO - select first item | |
464 movwf menu_pos_cur ; - set cursor | |
465 movff char_I_O2_ratio,opt_gas6_O2_ratio ; - initialize gas6 with currently breathed gas - O2 ratio | |
623 | 466 IFDEF _helium |
634 | 467 movff char_I_He_ratio,opt_gas6_He_ratio ; - initialize gas6 with currently breathed gas - He ratio |
623 | 468 ELSE |
634 | 469 clrf WREG ; - set gas6 helium to zero |
470 movff WREG,opt_gas6_He_ratio ; - ... | |
471 ENDIF ; _helium | |
472 bsf block_option_value ; suspend displaying of option values | |
582 | 473 |
623 | 474 |
634 | 475 IFDEF _helium |
476 MENU_BEGIN_DIVE .6 | |
477 MENU_OPT_INCS tO2Plus, oGas6O2 | |
478 MENU_OPT_DECS tO2Minus, oGas6O2 | |
479 MENU_OPT_INCS tHePlus, oGas6He | |
480 MENU_OPT_DECS tHeMinus, oGas6He | |
481 MENU_DYNAMIC dyn_show_gas6, do_gas6_switch | |
482 MENU_CALL tExit, do_exit_divemode_menu | |
483 MENU_END | |
484 ELSE | |
485 MENU_BEGIN_DIVE .4 | |
486 MENU_OPT_INCS tO2Plus, oGas6O2 | |
487 MENU_OPT_DECS tO2Minus, oGas6O2 | |
488 MENU_DYNAMIC dyn_show_gas6, do_gas6_switch | |
489 MENU_CALL tExit, do_exit_divemode_menu | |
490 MENU_END | |
491 ENDIF; _helium | |
0 | 492 |
623 | 493 |
634 | 494 ;----------------------------------------------------------------------------- |
495 ; dynamic Title: show Gas 6 Mix | |
496 ; | |
497 dyn_show_gas6: | |
498 STRCAT_TEXT tTakeGas ; print "take" | |
499 PUTC " " ; print one space | |
500 movff opt_gas6_O2_ratio,hi ; TFT_color_code_gaslist needs O2 ratio in hi | |
501 call TFT_color_code_gaslist ; color-code according to O2 ratio and depth | |
502 movff opt_gas6_O2_ratio,lo ; gaslist_strcat_mix needs O2 ratio in lo | |
503 IFDEF _helium | |
504 movff opt_gas6_He_ratio,hi ; ... and He ratio in hi | |
505 ELSE | |
506 clrf hi ; ... and He ration will be zero | |
507 ENDIF ; _helium | |
508 goto gaslist_strcat_mix ; print "Nxlo", "Txlo/hi", "Air" or "O2" and return | |
0 | 509 |
582 | 510 |
634 | 511 ;----------------------------------------------------------------------------- |
512 ; Call Function - switch to Gas 6 | |
513 ; | |
514 do_gas6_switch: | |
515 movlw .6 ; gas 6 | |
516 movwf menu_pos_cur ; transfer register for selected gas towards gas_switched_common | |
517 bsf event_gas_change_gas6 ; set flag for profile recording | |
518 bra do_switch_gas ; continue with common gas-switched code | |
623 | 519 |
520 | |
521 IFDEF _ccr_pscr | |
0 | 522 |
634 | 523 ;----------------------------------------------------------------------------- |
524 ; Sub Menu - select Setpoint | |
525 ; | |
0 | 526 do_divemode_splist: |
623 | 527 bsf short_gas_descriptions ; do not show "SP" etc. |
528 movlw .1 ; default to first menu item | |
529 movff opt_ccr_mode,lo ; get CCR mode (0: Fixed SP, 1: Sensor, 2: Auto SP) | |
530 dcfsnz lo,F ; mode = sensor ? | |
531 movlw .6 ; YES - load menu item number for 'sensor' | |
634 | 532 btfsc warn_det_sensors_lost ; all sensors lost? |
623 | 533 movlw .1 ; YES - revert to first menu item |
534 movwf menu_pos_cur ; set cursor position | |
560 | 535 |
623 | 536 IFDEF _external_sensor |
634 | 537 btfsc ext_input_s8_ana ; do we have an S8/analog input (OSTC cR)? |
582 | 538 bra do_divemode_splist_sensor ; YES |
634 | 539 btfsc ext_input_optical ; do we have an optical input (OSTC 3)? |
582 | 540 bra do_divemode_splist_sensor ; YES |
634 | 541 ENDIF ; _external_sensor |
0 | 542 |
560 | 543 do_divemode_splist_no_sensor: |
634 | 544 MENU_BEGIN_DIVE .5 |
545 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp | |
546 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp | |
547 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp | |
548 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp | |
549 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp | |
582 | 550 MENU_END |
551 | |
623 | 552 |
553 IFDEF _external_sensor | |
554 | |
582 | 555 do_divemode_splist_sensor: |
634 | 556 MENU_BEGIN_DIVE .6 |
557 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp | |
558 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp | |
559 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp | |
560 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp | |
561 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_switch_sp | |
582 | 562 MENU_CALL tCCRSensor, do_divemode_sensor |
563 MENU_END | |
249 | 564 |
634 | 565 ENDIF ; _external_sensor |
249 | 566 |
634 | 567 |
568 ;----------------------------------------------------------------------------- | |
569 ; dynamic Title - print Setpoint | |
570 ; | |
571 dyn_strcat_setpoint_prodl: | |
572 goto gaslist_strcat_setpoint_PRODL ; function is hosted in gaslist.asm | |
573 | |
574 | |
575 ;----------------------------------------------------------------------------- | |
576 ; Call Function - switch to manually selected Setpoint (CCR) | |
577 ; | |
578 do_switch_sp: | |
579 decf menu_pos_cur,W ; 1-5 -> 0-4 | |
580 lfsr FSR1,opt_setpoint_cbar ; load base address | |
581 movff PLUSW1,char_I_const_ppO2 ; set selected setpoint | |
582 IFDEF _external_sensor | |
583 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics | |
584 ENDIF | |
585 bcf warn_det_sensors_lost ; clear fallback condition (revoke all sensors lost warning) | |
586 clrf WREG ; switch to fixed SP | |
587 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP | |
588 ;bra do_switch_sp_com ; continue with common part | |
589 | |
590 | |
591 ;----------------------------------------------------------------------------- | |
592 ; Helper Function - common Part of Setpoint Switching | |
593 ; | |
594 do_switch_sp_com: ; common part | |
595 bsf event_occured ; set global event byte | |
596 bsf event_SP_change ; set setpoint event flag | |
597 | |
598 ; Clear some flags in case we were in bailout before... | |
599 bcf bailout_mode ; end bailout mode | |
600 bcf better_gas_available ; =1: a better gas is available and a gas change is advised in dive mode | |
601 bcf better_dil_available ; =1: a better diluent is available and a gas change is advised in dive mode | |
602 bcf better_gas_blinking ; clear blinking flag | |
603 bcf better_dil_blinking ; clear blinking flag | |
604 call dive_customview_callup ; redraw custom view mask to (if applicable) rewrite "ppO2(Dil)" to "ppO2" or SAC label | |
605 | |
606 bsf request_back_to_loop ; indicate that it is a switchback from OC bailout to CCR/pSCR loop | |
607 bsf request_gas_change ; initiate reconfiguration to loop mode on last diluent | |
608 | |
609 bra do_exit_divemode_menu ; continue exiting the menu | |
610 | |
611 | |
612 IFDEF _external_sensor | |
613 | |
614 | |
615 ;----------------------------------------------------------------------------- | |
616 ; Return to Sub Menu toggle Sensor Usage / select Sensors from Menu Action | |
617 ; | |
618 do_return_divemode_sensor: | |
619 call menu_processor_pop ; drop selection from menu stack | |
620 bra do_return_divemode_common ; back to menu | |
621 | |
622 ;----------------------------------------------------------------------------- | |
623 ; Sub Menu - toggle Sensor Usage / select Sensors | |
624 ; | |
0 | 625 do_divemode_sensor: |
631 | 626 movlw index_ppo2_sensors ; number of ppO2 sensors custom view |
627 movwf active_customview ; set the custom view number | |
628 call dive_customview_callup ; call-up the custom view | |
629 movlw .1 ; set to 1st option: use sensors | |
630 movwf menu_pos_cur ; ... | |
582 | 631 |
634 | 632 do_return_divemode_common: |
633 MENU_BEGIN_DIVE .6 | |
582 | 634 MENU_CALL tDivemenu_UseSensor, do_switch_sensor |
560 | 635 MENU_CALL tBack, do_divemode_splist |
582 | 636 MENU_CALL tExit, do_exit_divemode_menu |
560 | 637 MENU_CALL tDiveHudMask1, do_toggle_sensor |
638 MENU_CALL tDiveHudMask2, do_toggle_sensor | |
639 MENU_CALL tDiveHudMask3, do_toggle_sensor | |
582 | 640 MENU_END |
0 | 641 |
560 | 642 do_divemode_setpoint_pscr: |
582 | 643 movlw .1 |
623 | 644 movwf menu_pos_cur ; set to 1st option: use calculated ppO2 |
631 | 645 |
634 | 646 MENU_BEGIN_DIVE .6 |
560 | 647 MENU_CALL tCalculated, do_switch_sp_calc |
582 | 648 MENU_CALL tDivemenu_UseSensor, do_switch_sensor |
649 MENU_CALL tExit, do_exit_divemode_menu | |
560 | 650 MENU_CALL tDiveHudMask1, do_toggle_sensor |
651 MENU_CALL tDiveHudMask2, do_toggle_sensor | |
652 MENU_CALL tDiveHudMask3, do_toggle_sensor | |
582 | 653 MENU_END |
654 | |
634 | 655 |
656 ;----------------------------------------------------------------------------- | |
657 ; Call Function - switch to using Sensors | |
658 ; | |
659 do_switch_sensor: | |
660 movlw .1 ; switch to sensor (0: fixed/ calculated SP, 1: Sensor, 2: AutoSP) | |
661 movff WREG,opt_ccr_mode ; ... | |
0 | 662 |
634 | 663 ; check for external HUD/ppO2 Monitor |
664 btfss ext_input_optical ; do we have an optical input? | |
665 bra do_switch_sp_com ; NO - continue with common part | |
666 btfsc sensor1_active ; YES - process flags from HUD/ppO2 Monitor | |
667 bsf use_O2_sensor1 ; - ... | |
668 btfsc sensor2_active ; - ... | |
669 bsf use_O2_sensor2 ; - ... | |
670 btfsc sensor3_active ; - ... | |
671 bsf use_O2_sensor3 ; - ... | |
672 bra do_switch_sp_com ; - continue with common part | |
673 | |
674 | |
675 ;----------------------------------------------------------------------------- | |
676 ; Call Function - toggle Sensor Usage | |
677 ; | |
560 | 678 do_toggle_sensor: |
634 | 679 movf menu_pos_cur,W ; copy position to WREG |
680 addlw -.3 ; skip first 3 menu items | |
681 dcfsnz WREG ; cursor on item sensor 1 ? | |
682 btg use_O2_sensor1 ; YES - toggle sensor 1 state | |
683 dcfsnz WREG ; cursor on item sensor 2 ? | |
684 btg use_O2_sensor2 ; YES - toggle sensor 2 state | |
685 dcfsnz WREG ; cursor on item sensor 3 ? | |
686 btg use_O2_sensor3 ; YES - toggle sensor 3 state | |
687 bra do_return_divemode_sensor ; back to same menu | |
560 | 688 |
623 | 689 ENDIF ; _external_sensor |
690 ENDIF ; _ccr_pscr | |
691 | |
631 | 692 |
693 IFDEF _cave_mode | |
694 | |
634 | 695 ;----------------------------------------------------------------------------- |
696 ; Return to Cave Mode Main Menu | |
697 ; | |
631 | 698 do_return_main_cavemenu: |
699 call menu_processor_pop ; drop selection from menu stack | |
700 incf selected_item,W ; item numbers start with 0, menu positions with 1 | |
701 movwf menu_pos_cur ; position cursor where we came from | |
702 bra do_main_cavemenu_common ; continue with common part | |
703 | |
634 | 704 |
705 ;----------------------------------------------------------------------------- | |
706 ; Cave Mode Main Menu | |
707 ; | |
631 | 708 global do_main_cavemenu |
709 do_main_cavemenu: | |
710 bsf custom_view_locked ; lock custom view | |
711 movff active_customview,backup_customview ; back up current custom view | |
712 call menu_processor_reset ; restart from first icon | |
713 movlw .1 ; set cursor to first menu item by default | |
714 btfsc dive_turned ; dive turned ? | |
715 movlw .4 ; YES - set cursor on waypoint out item | |
716 btfss cave_mode ; cave mode switched off ? | |
717 movlw .3 ; YES - set cursor on cave mode off/on menu item | |
718 movwf menu_pos_cur ; actually set cursor position | |
634 | 719 ;bra do_main_cavemenu_common ; continue with common part |
631 | 720 |
721 do_main_cavemenu_common: | |
722 movlw index_cave_waypoints ; get number of cave waypoints custom view | |
723 movwf active_customview ; set custom view number | |
724 call dive_customview_callup ; draw custom view | |
725 | |
634 | 726 MENU_BEGIN_DIVE .6 |
727 MENU_DYNAMIC dyn_waypoint_set, do_waypoint_set ; 1 | |
728 MENU_DYNAMIC dyn_turndive_toggle, do_turndive_toggle ; 2 | |
631 | 729 MENU_CALL tDivemenu_off_on, do_cavemode_toggle ; 3 |
634 | 730 MENU_DYNAMIC dyn_waypoint_out, do_waypoint_out ; 4 |
731 MENU_DYNAMIC dyn_waypoint_in, do_waypoint_in ; 5 | |
631 | 732 MENU_CALL tExit, do_exit_divemode_menu ; 6 |
733 MENU_END | |
734 | |
735 | |
634 | 736 ;------------------------------------------------------------------- |
737 ; dynamic Title - set a Waypoint | |
738 ; | |
739 dyn_waypoint_set: | |
740 call cavemode_waypoint_set_check ; check if command is allowed to execute | |
741 tstfsz WREG ; command allowed? | |
742 FONT_COLOR_DISABLED ; NO - switch to disabled color | |
743 STRCAT_TEXT tDivemenu_wp_set ; print label | |
744 return ; done | |
745 | |
746 | |
747 ;------------------------------------------------------------------- | |
748 ; dynamic Title - turn the Dive | |
749 ; | |
750 dyn_turndive_toggle: | |
751 call cavemode_turndive_check ; check if command is allowed | |
752 tstfsz WREG ; command allowed? | |
753 FONT_COLOR_DISABLED ; NO - switch to disabled color | |
754 btfss cave_mode ; cave mode switched on? | |
755 bra dyn_turndive_toggle_1 ; NO - print turn dive label | |
756 btfss dive_turned ; YES - dive turned? | |
757 bra dyn_turndive_toggle_1 ; NO - print turn dive label | |
758 STRCAT_TEXT tDivemenu_ContDive ; YES - print continue dive label | |
759 return ; - done | |
760 dyn_turndive_toggle_1: | |
761 STRCAT_TEXT tDivemenu_TurnDive ; print turn dive label | |
762 return ; done | |
763 | |
764 | |
765 ;------------------------------------------------------------------- | |
766 ; dynamic Title - navigate one Waypoint outwards | |
767 ; | |
768 dyn_waypoint_out: | |
769 call cavemode_waypoint_out_check ; check if command is allowed to execute | |
770 tstfsz WREG ; command allowed? | |
771 FONT_COLOR_DISABLED ; NO - switch to disabled color | |
772 STRCAT_TEXT tDivemenu_wp_out ; print label | |
773 return ; done | |
774 | |
775 | |
776 ;------------------------------------------------------------------- | |
777 ; dynamic Title - navigate one Waypoint inwards | |
778 ; | |
779 dyn_waypoint_in: | |
780 call cavemode_waypoint_in_check ; check if command is allowed to execute | |
781 tstfsz WREG ; command allowed? | |
782 FONT_COLOR_DISABLED ; NO - switch to disabled color | |
783 STRCAT_TEXT tDivemenu_wp_in ; print label | |
784 return ; done | |
785 | |
786 | |
787 ;------------------------------------------------------------------- | |
788 ; Call Function - set a Waypoint | |
789 ; | |
631 | 790 do_waypoint_set: |
791 bsf request_waypoint_set ; set request flag | |
792 bra do_return_main_cavemenu ; back to menu | |
793 | |
634 | 794 |
795 ;------------------------------------------------------------------- | |
796 ; Call Function - turn the dive | |
797 ; | |
631 | 798 do_turndive_toggle: |
799 bsf request_turn_toggle ; set request flag | |
800 bra do_return_main_cavemenu ; back to menu | |
801 | |
634 | 802 |
803 ;------------------------------------------------------------------- | |
804 ; Call Function - turn Cave Mode on/off | |
805 ; | |
631 | 806 do_cavemode_toggle: |
807 bsf request_cave_toggle ; set request flag | |
808 bra do_return_main_cavemenu ; back to menu | |
809 | |
634 | 810 |
811 ;------------------------------------------------------------------- | |
812 ; Call Function - navigate one Waypoint outwards | |
813 ; | |
631 | 814 do_waypoint_out: |
815 bsf request_waypoint_out ; set request flag | |
816 bra do_return_main_cavemenu ; back to menu | |
817 | |
634 | 818 |
819 ;------------------------------------------------------------------- | |
820 ; Call Function - navigate one Waypoint inwards | |
821 ; | |
631 | 822 do_waypoint_in: |
823 bsf request_waypoint_in ; set request flag | |
824 bra do_return_main_cavemenu ; back to menu | |
825 | |
826 ENDIF ; _cave_mode | |
827 | |
634 | 828 |
829 ;----------------------------------------------------------------------------- | |
830 ; Call Function - leave the Menu | |
831 ; | |
832 do_exit_divemode_menu: | |
833 bcf block_option_value ; resume displaying of option values | |
834 goto diveloop_menu_exit ; back to the dive loop | |
835 | |
836 ;----------------------------------------------------------------------------- | |
623 | 837 |
838 END |