Mercurial > public > hwos_code
annotate src/divemenu_tree.asm @ 623:c40025d8e750
3.03 beta released
author | heinrichsweikamp |
---|---|
date | Mon, 03 Jun 2019 14:01:48 +0200 |
parents | ca4556fb60b9 |
children | 185ba2f91f59 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
623 | 3 ; File divemenu_tree.asm combined next generation V3.03.4 |
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 ;============================================================================= |
28 ; Main Menu | |
604 | 29 |
30 do_return_main_divemenu: | |
31 call menu_processor_double_pop ; drop exit line and back to last line | |
32 incf selected_item,W ; item numbers start with 0, menu positions with 1 | |
623 | 33 movwf menu_pos_cur ; position cursor where we came from |
604 | 34 bra do_main_divemenu_common |
35 | |
582 | 36 global do_main_divemenu |
0 | 37 do_main_divemenu: |
582 | 38 call menu_processor_reset ; restart from first icon |
39 movlw .1 | |
623 | 40 movwf menu_pos_cur ; set to first option in dive mode menu |
604 | 41 |
42 do_main_divemenu_common: | |
623 | 43 IFDEF _ccr_pscr |
560 | 44 btfsc FLAG_ccr_mode |
45 bra main_divemenu_loop ; goto CCR / pSCR Menu menu | |
46 btfsc FLAG_pscr_mode | |
47 bra main_divemenu_loop ; goto CCR / pSCR Menu menu | |
623 | 48 ENDIF |
560 | 49 |
582 | 50 main_divemenu_OC: |
623 | 51 IFDEF _ccr_pscr |
52 bcf is_diluent_menu ; selecting OC gases ... | |
53 bcf is_bailout_menu ; ... not for bailout reason | |
54 ENDIF | |
582 | 55 |
604 | 56 IFDEF _cave_mode |
623 | 57 btfss cave_mode ; in cave mode? |
604 | 58 bra main_divemenu_OC_no_cave ; NO - do OC menu without turn option |
59 | |
60 MENU_BEGIN tMainMenu, .6 | |
61 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | |
62 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
63 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf | |
64 MENU_CALL tDivemenu_Marker, do_set_marker | |
65 MENU_DYNAMIC do_turn_dive_label, do_turn_dive | |
66 MENU_CALL tExit, do_exit_divemode_menu | |
67 MENU_END | |
68 ENDIF | |
69 | |
70 main_divemenu_OC_no_cave: | |
582 | 71 MENU_BEGIN tMainMenu, .5 |
604 | 72 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist |
73 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
74 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf | |
75 MENU_CALL tDivemenu_Marker, do_set_marker | |
76 MENU_CALL tExit, do_exit_divemode_menu | |
560 | 77 MENU_END |
0 | 78 |
623 | 79 ;============================================================================= |
80 | |
81 IFDEF _ccr_pscr | |
604 | 82 |
560 | 83 main_divemenu_loop: |
623 | 84 bsf is_diluent_menu ; selecting diluents ... |
85 bcf is_bailout_menu ; ... (definitely) not for bailout reason | |
582 | 86 btfsc FLAG_pscr_mode |
604 | 87 bra main_divemenu_pscr ; pSCR menu |
582 | 88 |
89 MENU_BEGIN tMainMenu, .6 | |
604 | 90 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
91 MENU_CALL tDivemenu_Setpoint, do_divemode_splist | |
92 MENU_CALL tDivemenu_Diluent, do_divemode_gaslist | |
93 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr | |
94 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf | |
95 MENU_CALL tExit, do_exit_divemode_menu | |
582 | 96 MENU_END |
97 | |
623 | 98 |
485 | 99 main_divemenu_pscr: |
623 | 100 |
101 IFDEF _external_sensor | |
604 | 102 btfsc analog_o2_input ; do we have an analog input (OSTC cR)? |
103 bra main_divemenu_pscr_sensors ; YES | |
104 btfsc optical_input ; do we have an optical input (OSTC 3)? | |
105 bra main_divemenu_pscr_sensors ; YES | |
623 | 106 ENDIF |
560 | 107 |
108 main_divemenu_pscr_no_sensors: | |
582 | 109 MENU_BEGIN tMainMenu, .6 |
604 | 110 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
111 MENU_CALL tDivemenu_Premix, do_divemode_gaslist | |
112 MENU_CALL tBackToLoop, do_switch_sp_calc | |
113 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr | |
114 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf | |
115 MENU_CALL tExit, do_exit_divemode_menu | |
582 | 116 MENU_END |
117 | |
623 | 118 |
119 IFDEF _external_sensor | |
582 | 120 main_divemenu_pscr_sensors: |
121 MENU_BEGIN tMainMenu, .6 | |
604 | 122 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
123 MENU_CALL tCCRSensor, do_divemode_setpoint_pscr | |
124 MENU_CALL tDivemenu_Premix, do_divemode_gaslist | |
125 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr | |
126 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf | |
127 MENU_CALL tExit, do_exit_divemode_menu | |
582 | 128 MENU_END |
623 | 129 ENDIF ; _external_sensor |
582 | 130 |
623 | 131 ENDIF ; _ccr_pscr |
132 | |
133 ;============================================================================= | |
0 | 134 |
560 | 135 do_toggle_gf: |
604 | 136 TSTOSS char_I_deco_model ; toggle GF only in GF modes - in GF mode? (0 = ZH-L16, 1 = ZH-L16-GF) |
137 bra do_main_divemenu_common ; NO - do nothing and return | |
582 | 138 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater |
604 | 139 bra do_main_divemenu_common ; NO - do nothing and return |
140 movlw index_gf_factors-1 ; custom view number one below GF factors | |
623 | 141 movwf active_customview ; set custom view number |
142 bsf request_next_custview ; initiate toggle to desired custom view -> GF factors | |
560 | 143 movlw .1 |
623 | 144 movwf menu_pos_cur ; set to first option in dive mode menu |
582 | 145 |
146 MENU_BEGIN tDivemenu_ToggleGF, .2 | |
604 | 147 MENU_CALL tDivemenu_ToggleGF, do_togglegf |
148 MENU_CALL tBack, do_return_main_divemenu | |
582 | 149 MENU_END |
0 | 150 |
560 | 151 do_togglegf: |
623 | 152 bsf request_toggle_GF ; set request flag |
560 | 153 bra do_exit_divemode_menu ; continue with exiting menu code |
582 | 154 |
155 | |
604 | 156 do_reset_avg_set_mkr: |
157 movlw .1 | |
623 | 158 movwf menu_pos_cur ; set to first option in dive mode menu |
604 | 159 |
160 IFDEF _cave_mode | |
623 | 161 btfss cave_mode ; in cave mode? |
604 | 162 bra do_reset_average_no_cave ; NO - do menu without turn option |
163 | |
164 MENU_BEGIN tDivemenu_Avg_Mkr, .4 | |
165 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
166 MENU_CALL tDivemenu_Marker, do_set_marker | |
167 MENU_DYNAMIC do_turn_dive_label, do_turn_dive | |
168 MENU_CALL tBack, do_return_main_divemenu | |
169 MENU_END | |
170 ENDIF | |
171 | |
172 do_reset_average_no_cave: | |
173 MENU_BEGIN tDivemenu_Avg_Mkr, .3 | |
174 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
175 MENU_CALL tDivemenu_Marker, do_set_marker | |
176 MENU_CALL tBack, do_return_main_divemenu | |
177 MENU_END | |
178 | |
179 | |
180 do_reset_average: | |
623 | 181 bsf request_reset_avg ; request reset of resettable average depth and dive time |
182 IFDEF _min_depth_option | |
183 bsf reset_trip_pressure ; request ISR to reset the min and max trip-wise pressures | |
184 ENDIF | |
185 bra do_exit_divemode_menu ; exit | |
186 | |
604 | 187 |
560 | 188 do_set_marker: |
623 | 189 bsf request_set_marker ; set request flag |
190 bra do_exit_divemode_menu ; exit | |
191 | |
582 | 192 |
604 | 193 IFDEF _cave_mode |
194 do_turn_dive: | |
623 | 195 bsf request_turn_dive ; set request flag |
196 bra do_exit_divemode_menu ; exit | |
604 | 197 ENDIF |
0 | 198 |
582 | 199 |
623 | 200 IFDEF _external_sensor |
560 | 201 do_switch_sensor: ; entry point when coming from switch to sensor |
604 | 202 movlw .1 ; switch to sensor |
623 | 203 movff WREG,opt_ccr_mode ; =0: fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP |
582 | 204 bra do_switch_sp_com ; continue with common part |
623 | 205 ENDIF |
206 | |
207 ;============================================================================= | |
208 | |
209 IFDEF _ccr_pscr | |
582 | 210 |
560 | 211 do_switch_sp: ; entry point when coming from manual setpoint selection (CCR) |
623 | 212 decf menu_pos_cur,W ; 1-5 -> 0-4 |
213 lfsr FSR1,opt_setpoint_cbar | |
582 | 214 movff PLUSW1,char_I_const_ppO2 ; setup fixed setpoint |
623 | 215 IFDEF _external_sensor |
582 | 216 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics |
623 | 217 ENDIF |
218 bcf sp_fallback ; clear fallback condition (stops fallback warning) | |
604 | 219 clrf WREG ; switch to fixed SP |
560 | 220 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP |
221 bra do_switch_sp_com | |
0 | 222 |
623 | 223 |
560 | 224 do_switch_sp_calc: ; entry point when coming from switch to calculated ppO2 (pSCR) |
623 | 225 bcf sp_fallback ; clear fallback condition (stops fallback warning) |
226 clrf WREG ; switch to fixed SP | |
582 | 227 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP |
560 | 228 movff WREG,char_I_const_ppO2 ; set setpoint to 0, this forces deco engine to take the computed ppO2 |
623 | 229 ;bra do_switch_sp_com |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
230 |
623 | 231 |
232 do_switch_sp_com: ; common part | |
233 bsf event_occured ; set global event byte | |
234 bsf event_SP_change ; set setpoint event flag | |
582 | 235 |
236 ; Clear some flags in case we were in bailout before... | |
623 | 237 bcf bailout_mode ; end bailout mode |
604 | 238 bcf better_gas_available ; =1: a better gas is available and a gas change is advised in dive mode |
239 bcf better_dil_available ; =1: a better diluent is available and a gas change is advised in dive mode | |
623 | 240 bcf better_gas_blinking ; clear blinking flag |
241 bcf better_dil_blinking ; clear blinking flag | |
242 call dive_customview_mask ; redraw custom view mask to (eventually) rewrite "ppO2(Dil)" to "ppO2" or SAC label | |
0 | 243 |
623 | 244 bsf request_back_to_loop ; indicate that it is a switchback from OC bailout to CCR/pSCR loop |
245 bsf request_gaschange ; initiate reconfiguration to loop mode on last diluent | |
582 | 246 |
247 bra do_exit_divemode_menu ; continue with exiting menu code | |
248 | |
0 | 249 |
560 | 250 do_divemode_gaslist_bail: ; entry point from CCR/pSCR to bailout to OC gases |
623 | 251 bcf is_diluent_menu ; select OC gases |
582 | 252 bsf is_bailout_menu ; flag it is a bailout action |
623 | 253 ;bra do_divemode_gaslist |
254 | |
255 ENDIF ; _ccr_pscr | |
256 | |
257 ;============================================================================= | |
258 | |
560 | 259 do_divemode_gaslist: ; entry point for switching: OC -> gases, loop -> diluents |
623 | 260 IFDEF _ccr_pscr |
261 btfsc bailout_mode ; in bailout mode? | |
262 bcf is_diluent_menu ; YES - for safety reasons, redirect to selecting OC (bailout) gases | |
263 ENDIF | |
264 bsf short_gas_descriptions ; do not show "Gas x" etc. | |
604 | 265 bsf better_gas_hint ; mark the gas which is the best gas/diluent |
266 movf best_gas_number,W ; load number of best gas (1-5)into WREG | |
623 | 267 IFDEF _ccr_pscr |
268 btfsc is_diluent_menu ; in diluent selection? | |
604 | 269 movf best_dil_number,W ; YES - overwrite with best diluent (1-5) |
623 | 270 ENDIF |
604 | 271 bnz do_divemode_gaslist_1 ; best gas/dil number = 0 (none available) ? |
272 movlw .1 ; YES - default to first gas/dil | |
273 btfsc WREG,7 ; best gas/dil number >= 128 (not computed yet) ? | |
274 movlw .1 ; YES - default to first gas/dil | |
275 do_divemode_gaslist_1: | |
623 | 276 movwf menu_pos_cur ; position cursor to best gas/dil (or first option if none avail) |
582 | 277 MENU_BEGIN tGaslist, .6 |
604 | 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 | |
281 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas | |
282 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas | |
582 | 283 MENU_CALL tMore, do_divemode_gaslist_more |
284 MENU_END | |
285 | |
0 | 286 |
287 do_divemode_gaslist_more: | |
560 | 288 movlw .1 |
623 | 289 movwf menu_pos_cur ; set to first option in dive mode menu |
582 | 290 |
560 | 291 movff char_I_O2_ratio,gas6_O2_ratio ; initialize gas6 with currently breathed gas - O2 ratio |
623 | 292 IFDEF _helium |
560 | 293 movff char_I_He_ratio,gas6_He_ratio ; initialize gas6 with currently breathed gas - He ratio |
623 | 294 ENDIF |
582 | 295 |
296 do_divemode_gaslist_more_common: | |
623 | 297 IFDEF _helium |
582 | 298 MENU_BEGIN tGaslist, .6 |
299 MENU_CALL tO2Plus, do_dive_pO2 | |
300 MENU_CALL tO2Minus, do_dive_mO2 | |
301 MENU_CALL tHePlus, do_dive_pHe | |
302 MENU_CALL tHeMinus, do_dive_mHe | |
303 MENU_DYNAMIC gaslist_strcat_gas6, do_switch_gas6 | |
304 MENU_CALL tDivemenu_LostGas, do_lost_gas | |
305 MENU_END | |
623 | 306 ELSE |
307 MENU_BEGIN tGaslist, .4 | |
308 MENU_CALL tO2Plus, do_dive_pO2 | |
309 MENU_CALL tO2Minus, do_dive_mO2 | |
310 MENU_DYNAMIC gaslist_strcat_gas6, do_switch_gas6 | |
311 MENU_CALL tDivemenu_LostGas, do_lost_gas | |
312 MENU_CALL tExit, do_exit_divemode_menu | |
313 MENU_END | |
314 ENDIF | |
582 | 315 |
403
6e60012bb3fc
NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents:
401
diff
changeset
|
316 |
6e60012bb3fc
NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents:
401
diff
changeset
|
317 do_lost_gas: |
560 | 318 movlw .1 |
623 | 319 movwf menu_pos_cur ; set to first option in dive mode menu |
582 | 320 do_lost_gas_common: |
623 | 321 bsf short_gas_descriptions ; do not show "Gas x" etc. |
604 | 322 bcf better_gas_hint ; do not mark the best gas/diluent |
582 | 323 MENU_BEGIN tDivemenu_LostGas, .6 |
604 | 324 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active |
325 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active | |
326 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active | |
327 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active | |
328 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active | |
582 | 329 MENU_CALL tExit, do_exit_divemode_menu |
330 MENU_END | |
0 | 331 |
560 | 332 |
333 do_switch_gas6: | |
582 | 334 movlw .6 ; gas 6 |
623 | 335 movwf menu_pos_cur ; transfer register for selected gas towards gas_switched_common |
336 bsf event_gas_change_gas6 ; set flag for profile recording | |
560 | 337 ;bra do_switch_gas ; continue with common gas-switched code |
338 | |
623 | 339 |
560 | 340 do_switch_gas: |
623 | 341 bsf request_gaschange ; initiate gas change, will also trigger restart of deco_engine |
604 | 342 btfss is_bailout_menu ; doing a bailout? |
343 bra do_switch_gas_1 ; NO | |
623 | 344 bsf bailout_mode ; YES - begin bailout mode |
604 | 345 IFDEF _cave_mode |
623 | 346 btfsc cave_mode ; - in cave mode? |
347 bsf dive_turned ; YES - set dive as turned | |
604 | 348 ENDIF |
349 do_switch_gas_1: | |
623 | 350 bcf sp_fallback ; eventually terminate fallback mode and get rid of its warning |
351 call dive_customview_mask ; redraw custom view mask to (eventually) rewrite "ppO2(Dil)" to "ppO2" or SAC label | |
560 | 352 ;bra do_exit_divemode_menu ; continue with exiting menu code |
582 | 353 |
623 | 354 |
560 | 355 do_exit_divemode_menu: |
356 call timeout_divemode_menu2 | |
357 clrf STKPTR | |
623 | 358 goto diveloop_menu_exit |
560 | 359 |
360 | |
403
6e60012bb3fc
NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents:
401
diff
changeset
|
361 do_toggle_active: |
582 | 362 movlw .5 |
623 | 363 IFDEF _ccr_pscr |
364 btfsc is_diluent_menu ; operating on diluents? | |
365 addwf menu_pos_cur,F ; YES - add offset of 5 to shift 1-5 -> 6-10 | |
366 ENDIF | |
367 decf menu_pos_cur,W ; 1-10 -> 0-4 for gases / 5-9 for diluents | |
604 | 368 lfsr FSR1,opt_gas_type ; load base address of gas types |
369 movff PLUSW1,lo ; get gas/dil type | |
370 tstfsz lo ; already disabled? | |
371 bra do_toggle_active_disable ; NO - disable now | |
372 do_toggle_active_enable ; YES - re-enable now | |
373 lfsr FSR1,opt_gas_type_backup ; load base address of backed-up gas types | |
374 movff PLUSW1,lo ; get backed-up gas/dil type | |
375 lfsr FSR1,opt_gas_type ; load base address of gas types | |
376 movff lo,PLUSW1 ; restore gas type | |
377 bra do_toggle_active_common | |
378 do_toggle_active_disable: ; disable gas / diluent | |
379 ;lfsr FSR1,opt_gas_type ; (still set) | |
380 clrf PLUSW1 ; set type to disabled (0=disabled, 1=first, 2=travel/normal, 3=deco/-) | |
381 do_toggle_active_common: | |
582 | 382 movlw .5 |
623 | 383 IFDEF _ccr_pscr |
384 btfsc is_diluent_menu ; operating on diluents? | |
385 subwf menu_pos_cur,F ; YES - back to 1-5 | |
386 bcf better_dil_blinking ; clear blinking flag for diluents to avoid "leftovers" | |
387 ENDIF | |
388 bcf better_gas_blinking ; clear blinking flag for gases to avoid "leftovers" | |
604 | 389 call restart_deco_engine_wo_ceiling ; invalidate deco data (but not the ceiling) and restart deco engine |
390 bra do_lost_gas_common | |
0 | 391 |
623 | 392 |
0 | 393 do_dive_pO2: |
560 | 394 incf gas6_O2_ratio,F ; O2++ |
623 | 395 IFDEF _helium |
560 | 396 movf gas6_He_ratio,W |
397 addwf gas6_O2_ratio,W | |
623 | 398 ELSE |
399 movf gas6_O2_ratio,W | |
400 ENDIF | |
401 movwf lo | |
560 | 402 movlw .101 |
623 | 403 cpfslt lo ; O2 + He < 101 ? |
582 | 404 decf gas6_O2_ratio,F ; O2-- (unchanged) |
405 bra do_divemode_gaslist_more_common | |
406 | |
623 | 407 |
0 | 408 do_dive_mO2: |
582 | 409 decf gas6_O2_ratio,F ; O2-- |
410 movlw gaslist_min_o2 | |
623 | 411 cpfslt gas6_O2_ratio ; O2 < minimum allowed %O2 ? |
582 | 412 bra do_dive_mO2_done ; NO |
413 movlw gaslist_min_o2 ; YES - restore minimum | |
414 movwf gas6_O2_ratio | |
560 | 415 do_dive_mO2_done: |
582 | 416 bra do_divemode_gaslist_more_common |
0 | 417 |
623 | 418 ;============================================================================= |
419 | |
420 IFDEF _helium | |
421 | |
0 | 422 do_dive_pHe: |
582 | 423 incf gas6_He_ratio,F ; He++ |
424 movf gas6_He_ratio,W | |
425 addwf gas6_O2_ratio,W | |
426 movwf lo | |
427 movlw .101 | |
428 cpfslt lo ; O2 + He < 101 ? | |
623 | 429 decf gas6_He_ratio,F ; YES - He-- (unchanged) |
582 | 430 bra do_divemode_gaslist_more_common |
0 | 431 |
432 do_dive_mHe: | |
582 | 433 decf gas6_He_ratio,F ; He-- |
623 | 434 bnn do_dive_mHe_done ; H2 < 0 ? |
582 | 435 clrf gas6_He_ratio ; YES - reset to 0 |
560 | 436 do_dive_mHe_done: |
582 | 437 bra do_divemode_gaslist_more_common |
438 | |
623 | 439 ENDIF |
440 | |
441 ;============================================================================= | |
442 | |
443 IFDEF _ccr_pscr | |
0 | 444 |
445 do_divemode_splist: | |
623 | 446 bsf short_gas_descriptions ; do not show "SP" etc. |
447 movlw .1 ; default to first menu item | |
448 movff opt_ccr_mode,lo ; get CCR mode (0: Fixed SP, 1: Sensor, 2: Auto SP) | |
449 dcfsnz lo,F ; mode = sensor ? | |
450 movlw .6 ; YES - load menu item number for 'sensor' | |
451 btfsc sp_fallback ; in fallback condition? | |
452 movlw .1 ; YES - revert to first menu item | |
453 movwf menu_pos_cur ; set cursor position | |
560 | 454 |
582 | 455 do_divemode_splist_common: |
623 | 456 |
457 IFDEF _external_sensor | |
458 btfsc analog_o2_input ; do we have an analog or S8 digital input (OSTC cR)? | |
582 | 459 bra do_divemode_splist_sensor ; YES |
604 | 460 btfsc optical_input ; do we have an optical input (OSTC 3)? |
582 | 461 bra do_divemode_splist_sensor ; YES |
623 | 462 ENDIF |
0 | 463 |
560 | 464 do_divemode_splist_no_sensor: |
582 | 465 MENU_BEGIN tGaslist, .5 |
466 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
467 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
468 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
469 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
470 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
471 MENU_END | |
472 | |
623 | 473 |
474 IFDEF _external_sensor | |
475 | |
582 | 476 do_divemode_splist_sensor: |
477 MENU_BEGIN tGaslist, .6 | |
478 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
479 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
480 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
481 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
482 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
483 MENU_CALL tCCRSensor, do_divemode_sensor | |
484 MENU_END | |
249 | 485 |
486 | |
0 | 487 do_divemode_sensor: |
604 | 488 movlw index_ppo2_sensors-1 ; custom view number one below ppO2 sensors |
623 | 489 movwf active_customview ; set custom view number |
490 bsf request_next_custview ; initiate toggle to desired custom view -> ppO2 sensors | |
582 | 491 movlw .1 |
623 | 492 movwf menu_pos_cur ; set to 1st option: use sensors |
582 | 493 |
494 do_return_divemode_sensor: | |
495 MENU_BEGIN tGaslist, .6 | |
496 MENU_CALL tDivemenu_UseSensor, do_switch_sensor | |
560 | 497 MENU_CALL tBack, do_divemode_splist |
582 | 498 MENU_CALL tExit, do_exit_divemode_menu |
560 | 499 MENU_CALL tDiveHudMask1, do_toggle_sensor |
500 MENU_CALL tDiveHudMask2, do_toggle_sensor | |
501 MENU_CALL tDiveHudMask3, do_toggle_sensor | |
582 | 502 MENU_END |
0 | 503 |
623 | 504 |
560 | 505 do_divemode_setpoint_pscr: |
582 | 506 movlw .1 |
623 | 507 movwf menu_pos_cur ; set to 1st option: use calculated ppO2 |
582 | 508 MENU_BEGIN tGaslist, .6 |
560 | 509 MENU_CALL tCalculated, do_switch_sp_calc |
582 | 510 MENU_CALL tDivemenu_UseSensor, do_switch_sensor |
511 MENU_CALL tExit, do_exit_divemode_menu | |
560 | 512 MENU_CALL tDiveHudMask1, do_toggle_sensor |
513 MENU_CALL tDiveHudMask2, do_toggle_sensor | |
514 MENU_CALL tDiveHudMask3, do_toggle_sensor | |
582 | 515 MENU_END |
516 | |
0 | 517 |
560 | 518 do_toggle_sensor: |
623 | 519 movff menu_pos_cur,lo ; backup position |
520 decf menu_pos_cur,f ; 4, 5, 6 -> 3, 4, 5 | |
521 decf menu_pos_cur,f ; 3, 4, 5 -> 2, 3, 4 | |
522 decf menu_pos_cur,f ; 2, 3, 4 -> 1, 2, 3 | |
523 dcfsnz menu_pos_cur ; 1, 2, 3 -> 0, 1, 2 | |
582 | 524 btg use_O2_sensor1 ; = |
623 | 525 dcfsnz menu_pos_cur ; 0, 1, 2 -> -1, 0, 1 |
582 | 526 btg use_O2_sensor2 ; = |
623 | 527 dcfsnz menu_pos_cur ; -1,0, 1 -> -2,-1, 0 |
582 | 528 btg use_O2_sensor3 ; = |
623 | 529 movff lo,menu_pos_cur ; restore position |
582 | 530 bra do_return_divemode_sensor |
560 | 531 |
623 | 532 ENDIF ; _external_sensor |
533 ENDIF ; _ccr_pscr | |
534 | |
535 ;============================================================================= | |
536 | |
537 END |