comparison src/divemenu_tree.asm @ 604:ca4556fb60b9

bump to 2.99beta, work on 3.00 stable
author heinrichsweikamp
date Thu, 22 Nov 2018 19:47:26 +0100
parents 6636cbe64c6d
children c40025d8e750
comparison
equal deleted inserted replaced
603:00b24fb4324d 604:ca4556fb60b9
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File divemenu_tree.asm REFACTORED VERSION V2.98 3 ; File divemenu_tree.asm REFACTORED VERSION V2.99e
4 ; 4 ;
5 ; OSTC dive mode menu 5 ; OSTC dive mode menu
6 ; 6 ;
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
8 ;============================================================================= 8 ;=============================================================================
16 #include "customview.inc" 16 #include "customview.inc"
17 #include "strings.inc" 17 #include "strings.inc"
18 #include "calibrate.inc" 18 #include "calibrate.inc"
19 19
20 extern timeout_divemode_menu2 20 extern timeout_divemode_menu2
21 extern restart_deco_engine_wo_ceiling
21 extern diveloop_loop4 22 extern diveloop_loop4
22 23
23 24
24 divegui CODE 25 dmenu_tree CODE
25 26
26 ;============================================================================= 27 ;=============================================================================
27 ; Main Menu 28 ; Main Menu
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
33 movwf menupos1 ; position cursor where we came from
34 bra do_main_divemenu_common
35
28 global do_main_divemenu 36 global do_main_divemenu
29 do_main_divemenu: 37 do_main_divemenu:
30 call menu_processor_reset ; restart from first icon 38 call menu_processor_reset ; restart from first icon
31 movlw .1 39 movlw .1
32 movwf menupos1 ; set to first option in divemode menu 40 movwf menupos1 ; set to first option in divemode menu
41
42 do_main_divemenu_common:
33 btfsc FLAG_ccr_mode 43 btfsc FLAG_ccr_mode
34 bra main_divemenu_loop ; goto CCR / pSCR Menu menu 44 bra main_divemenu_loop ; goto CCR / pSCR Menu menu
35 btfsc FLAG_pscr_mode 45 btfsc FLAG_pscr_mode
36 bra main_divemenu_loop ; goto CCR / pSCR Menu menu 46 bra main_divemenu_loop ; goto CCR / pSCR Menu menu
37 47
38 main_divemenu_OC: 48 main_divemenu_OC:
39 bcf ccr_diluent_setup 49 bcf FLAG_diluent_setup ; set to operations on OC gases
40 bcf is_bailout_menu 50 bcf is_bailout_menu
41 51
52 IFDEF _cave_mode
53 btfss FLAG_cave_mode ; in cave mode?
54 bra main_divemenu_OC_no_cave ; NO - do OC menu without turn option
55
56 MENU_BEGIN tMainMenu, .6
57 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist
58 MENU_CALL tDivemenu_ResetAvg, do_reset_average
59 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf
60 MENU_CALL tDivemenu_Marker, do_set_marker
61 MENU_DYNAMIC do_turn_dive_label, do_turn_dive
62 MENU_CALL tExit, do_exit_divemode_menu
63 MENU_END
64 ENDIF
65
66 main_divemenu_OC_no_cave:
42 MENU_BEGIN tMainMenu, .5 67 MENU_BEGIN tMainMenu, .5
43 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist 68 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist
44 MENU_CALL tDivemenu_ResetAvg, do_reset_average 69 MENU_CALL tDivemenu_ResetAvg, do_reset_average
45 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf 70 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf
46 MENU_CALL tDivemenu_Marker, do_set_marker 71 MENU_CALL tDivemenu_Marker, do_set_marker
47 MENU_CALL tExit, do_exit_divemode_menu 72 MENU_CALL tExit, do_exit_divemode_menu
48 MENU_END 73 MENU_END
74
49 75
50 main_divemenu_loop: 76 main_divemenu_loop:
51 bsf ccr_diluent_setup ; default to operations on diluents 77 bsf FLAG_diluent_setup ; set to operations on diluents
52 bcf is_bailout_menu ; default to none-bailout menu 78 bcf is_bailout_menu ; flag as none-bailout menu
53 btfsc FLAG_pscr_mode 79 btfsc FLAG_pscr_mode
54 bra main_divemenu_pscr ; PSCR Menu 80 bra main_divemenu_pscr ; pSCR menu
55 81
56 MENU_BEGIN tMainMenu, .6 82 MENU_BEGIN tMainMenu, .6
57 MENU_CALL tDiveBailout, do_divemode_gaslist_bail 83 MENU_CALL tDiveBailout, do_divemode_gaslist_bail
58 MENU_CALL tDivemenu_Setpoint, do_divemode_splist 84 MENU_CALL tDivemenu_Setpoint, do_divemode_splist
59 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist 85 MENU_CALL tDivemenu_Diluent, do_divemode_gaslist
60 MENU_CALL tDivemenu_ResetAvg, do_reset_average 86 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr
61 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf 87 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf
62 MENU_CALL tExit, do_exit_divemode_menu 88 MENU_CALL tExit, do_exit_divemode_menu
63 MENU_END 89 MENU_END
64 90
65 main_divemenu_pscr: 91 main_divemenu_pscr:
66 btfsc analog_o2_input ; do we have an analog input? 92 btfsc analog_o2_input ; do we have an analog input (OSTC cR)?
67 bra main_divemenu_pscr_sensors ; YES 93 bra main_divemenu_pscr_sensors ; YES
68 btfsc s8_digital ; do we have a digital input? 94 btfsc optical_input ; do we have an optical input (OSTC 3)?
69 bra main_divemenu_pscr_sensors ; YES 95 bra main_divemenu_pscr_sensors ; YES
70 btfsc optical_input ; do we have an optical input?
71 bra main_divemenu_pscr_sensors ; YES
72 96
73 main_divemenu_pscr_no_sensors: 97 main_divemenu_pscr_no_sensors:
74 MENU_BEGIN tMainMenu, .6 98 MENU_BEGIN tMainMenu, .6
75 MENU_CALL tDiveBailout, do_divemode_gaslist_bail 99 MENU_CALL tDiveBailout, do_divemode_gaslist_bail
76 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist 100 MENU_CALL tDivemenu_Premix, do_divemode_gaslist
77 MENU_CALL tDivemenu_ResetAvg, do_reset_average 101 MENU_CALL tBackToLoop, do_switch_sp_calc
78 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf 102 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr
79 MENU_CALL tDivemenu_Marker, do_set_marker 103 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf
80 MENU_CALL tExit, do_exit_divemode_menu 104 MENU_CALL tExit, do_exit_divemode_menu
81 MENU_END 105 MENU_END
82 106
83 main_divemenu_pscr_sensors: 107 main_divemenu_pscr_sensors:
84 MENU_BEGIN tMainMenu, .6 108 MENU_BEGIN tMainMenu, .6
85 MENU_CALL tDiveBailout, do_divemode_gaslist_bail 109 MENU_CALL tDiveBailout, do_divemode_gaslist_bail
86 MENU_CALL tCCRSensor, do_divemode_setpoint_pscr 110 MENU_CALL tCCRSensor, do_divemode_setpoint_pscr
87 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist 111 MENU_CALL tDivemenu_Premix, do_divemode_gaslist
88 MENU_CALL tDivemenu_ResetAvg, do_reset_average 112 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr
89 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf 113 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf
90 MENU_CALL tExit, do_exit_divemode_menu 114 MENU_CALL tExit, do_exit_divemode_menu
91 MENU_END 115 MENU_END
92 116
93 117
94 do_toggle_gf: 118 do_toggle_gf:
95 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF 119 TSTOSS char_I_deco_model ; toggle GF only in GF modes - in GF mode? (0 = ZH-L16, 1 = ZH-L16-GF)
96 decfsz WREG,W ; Toggle GF only in GF modes - in GF mode? 120 bra do_main_divemenu_common ; NO - do nothing and return
97 bra do_main_divemenu ; No, do nothing and return
98 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater 121 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater
99 bra do_main_divemenu ; No, do nothing and return 122 bra do_main_divemenu_common ; NO - do nothing and return
100 movlw .4 ; Set customview to 5 (GF informations) 123 movlw index_gf_factors-1 ; custom view number one below GF factors
101 movwf menupos3 ; Customview to come-1 124 movwf menupos3 ; set custom view number
102 bsf toggle_customview ; Set flag, the customview will be toggled very soon now... 125 bsf toggle_customview ; initiate toggle to desired custom view -> GF factors
103 movlw .1 126 movlw .1
104 movwf menupos1 ; Set to first option in divemode menu 127 movwf menupos1 ; set to first option in dive mode menu
105 128
106 MENU_BEGIN tDivemenu_ToggleGF, .2 129 MENU_BEGIN tDivemenu_ToggleGF, .2
107 MENU_CALL tDivemenu_ToggleGF, do_togglegf 130 MENU_CALL tDivemenu_ToggleGF, do_togglegf
108 MENU_CALL tBack, do_main_divemenu 131 MENU_CALL tBack, do_return_main_divemenu
109 MENU_END 132 MENU_END
110 133
111 do_togglegf: 134 do_togglegf:
112 ;TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater ; check is now done before entering menu 135 bsf toggle_gf ; set command flag...
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 136 bra do_exit_divemode_menu ; continue with exiting menu code
116 137
138
139 do_reset_avg_set_mkr:
140 movlw .1
141 movwf menupos1 ; set to first option in dive mode menu
142
143 IFDEF _cave_mode
144 btfss FLAG_cave_mode ; in cave mode?
145 bra do_reset_average_no_cave ; NO - do menu without turn option
146
147 MENU_BEGIN tDivemenu_Avg_Mkr, .4
148 MENU_CALL tDivemenu_ResetAvg, do_reset_average
149 MENU_CALL tDivemenu_Marker, do_set_marker
150 MENU_DYNAMIC do_turn_dive_label, do_turn_dive
151 MENU_CALL tBack, do_return_main_divemenu
152 MENU_END
153 ENDIF
154
155 do_reset_average_no_cave:
156 MENU_BEGIN tDivemenu_Avg_Mkr, .3
157 MENU_CALL tDivemenu_ResetAvg, do_reset_average
158 MENU_CALL tDivemenu_Marker, do_set_marker
159 MENU_CALL tBack, do_return_main_divemenu
160 MENU_END
161
162
163 do_reset_average:
164 bsf reset_average_depth ; set flag...
165 bra do_exit_divemode_menu ; ... and exit
117 166
118 do_set_marker: 167 do_set_marker:
119 bsf FLAG_set_marker ; set flag... 168 bsf FLAG_set_marker ; set flag...
120 bra do_exit_divemode_menu ; ... and exit 169 bra do_exit_divemode_menu ; ... and exit
121 170
122 171 IFDEF _cave_mode
123 do_reset_average: 172 do_turn_dive:
124 bsf reset_average_depth ; Set Flag 173 bsf toggle_turn_dive ; set flag...
125 bra do_exit_divemode_menu ; continue with exiting menu code 174 bra do_exit_divemode_menu ; ... and exit
175 ENDIF
126 176
127 177
128 do_switch_sensor: ; entry point when coming from switch to sensor 178 do_switch_sensor: ; entry point when coming from switch to sensor
129 movlw .1 ; Switch to Sensor 179 movlw .1 ; switch to sensor
130 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP 180 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP
131 ; enable all sensors 181 ; enable all sensors
132 bsf use_O2_sensor1 182 bsf use_O2_sensor1
133 bsf use_O2_sensor2 183 bsf use_O2_sensor2
134 bsf use_O2_sensor3 184 bsf use_O2_sensor3
139 lfsr FSR1,char_I_setpoint_cbar 189 lfsr FSR1,char_I_setpoint_cbar
140 movff PLUSW1,char_I_const_ppO2 ; setup fixed setpoint 190 movff PLUSW1,char_I_const_ppO2 ; setup fixed setpoint
141 movff char_I_const_ppO2,WREG 191 movff char_I_const_ppO2,WREG
142 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics 192 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics
143 bcf setpoint_fallback ; clear fallback condition (stops fallback warning) 193 bcf setpoint_fallback ; clear fallback condition (stops fallback warning)
144 clrf WREG ; Switch to fixed SP 194 clrf WREG ; switch to fixed SP
145 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP 195 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP
146 bra do_switch_sp_com 196 bra do_switch_sp_com
147 197
148 do_switch_sp_calc: ; entry point when coming from switch to calculated ppO2 (pSCR) 198 do_switch_sp_calc: ; entry point when coming from switch to calculated ppO2 (pSCR)
149 bcf setpoint_fallback ; clear fallback condition (stops fallback warning) 199 bcf setpoint_fallback ; clear fallback condition (stops fallback warning)
154 do_switch_sp_com: ; merge point to common part 204 do_switch_sp_com: ; merge point to common part
155 bsf event_occured ; set global event byte 205 bsf event_occured ; set global event byte
156 bsf setpoint_changed ; set flag (for profile) 206 bsf setpoint_changed ; set flag (for profile)
157 207
158 ; Clear some flags in case we were in bailout before... 208 ; Clear some flags in case we were in bailout before...
159 bcf is_bailout ; end bailout mode 209 bcf FLAG_bailout_mode ; end bailout mode
160 ;bcf is_bailout_menu ; not needed 210 ;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 211 bcf better_gas_available ; =1: a better gas is available and a gas change is advised in dive mode
212 bcf better_dil_available ; =1: a better diluent is available and a gas change is advised in dive mode
162 bcf blinking_better_gas ; clear blinking flag 213 bcf blinking_better_gas ; clear blinking flag
163 call customview_mask ; update customview mask to (eventually) rewrite ppO2(Dil): to ppO2: 214 bcf blinking_better_dil ; clear blinking flag
215 bsf redraw_custview_mask ; request update of custom view mask to (eventually) rewrite "ppO2(Dil)" to "ppO2" or SAC label
164 216
165 bsf FLAG_back_to_loop ; indicate that it is a switchback from OC bailout to CCR/pSCR loop 217 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 218 bsf divemode_gaschange ; initiate reconfiguration to loop mode on last diluent
167 219
168 bra do_exit_divemode_menu ; continue with exiting menu code 220 bra do_exit_divemode_menu ; continue with exiting menu code
169 221
170 222
171 do_divemode_gaslist_bail: ; entry point from CCR/pSCR to bailout to OC gases 223 do_divemode_gaslist_bail: ; entry point from CCR/pSCR to bailout to OC gases
172 bcf ccr_diluent_setup ; switch to OC gases 224 bcf FLAG_diluent_setup ; switch to OC gases
173 bsf is_bailout_menu ; flag it is a bailout action 225 bsf is_bailout_menu ; flag it is a bailout action
174 do_divemode_gaslist: ; entry point for switching: OC -> gases, loop -> diluents 226 do_divemode_gaslist: ; entry point for switching: OC -> gases, loop -> diluents
175 btfsc is_bailout ; in bailout mode? 227 btfsc FLAG_bailout_mode ; in bailout mode?
176 bcf ccr_diluent_setup ; yes - for safety reasons, redirect to OC (bailout) gases 228 bcf FLAG_diluent_setup ; yes - for safety reasons, redirect to OC (bailout) gases
177 do_divemode_gaslist_com: 229 bsf short_gas_decriptions ; do not show "Gas x" etc.
178 bsf short_gas_decriptions 230 bsf better_gas_hint ; mark the gas which is the best gas/diluent
179 movlw .1 231 movf best_gas_number,W ; load number of best gas (1-5)into WREG
180 movwf menupos1 ; Set to first option in divemode menu 232 btfsc FLAG_diluent_setup ; in diluent selection?
233 movf best_dil_number,W ; YES - overwrite with best diluent (1-5)
234 bnz do_divemode_gaslist_1 ; best gas/dil number = 0 (none available) ?
235 movlw .1 ; YES - default to first gas/dil
236 btfsc WREG,7 ; best gas/dil number >= 128 (not computed yet) ?
237 movlw .1 ; YES - default to first gas/dil
238 do_divemode_gaslist_1:
239 movwf menupos1 ; position cursor to best gas/dil (or first option if none avail)
181 MENU_BEGIN tGaslist, .6 240 MENU_BEGIN tGaslist, .6
182 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas 241 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas
183 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas 242 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas
184 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas 243 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas
185 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas 244 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas
186 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas 245 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas
187 MENU_CALL tMore, do_divemode_gaslist_more 246 MENU_CALL tMore, do_divemode_gaslist_more
188 MENU_END 247 MENU_END
189 248
190 249
191 do_divemode_gaslist_more: 250 do_divemode_gaslist_more:
192 movlw .1 251 movlw .1
193 movwf menupos1 ; Set to first option in divemode menu 252 movwf menupos1 ; set to first option in dive mode menu
194 253
195 movff char_I_O2_ratio,gas6_O2_ratio ; initialize gas6 with currently breathed gas - O2 ratio 254 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 255 movff char_I_He_ratio,gas6_He_ratio ; initialize gas6 with currently breathed gas - He ratio
197 256
198 do_divemode_gaslist_more_common: 257 do_divemode_gaslist_more_common:
206 MENU_END 265 MENU_END
207 266
208 267
209 do_lost_gas: 268 do_lost_gas:
210 movlw .1 269 movlw .1
211 movwf menupos1 ; Set to first option in divemode menu 270 movwf menupos1 ; set to first option in dive mode menu
212 do_lost_gas_common: 271 do_lost_gas_common:
213 bsf short_gas_decriptions 272 bsf short_gas_decriptions ; do not show "Gas x" etc.
273 bcf better_gas_hint ; do not mark the best gas/diluent
214 MENU_BEGIN tDivemenu_LostGas, .6 274 MENU_BEGIN tDivemenu_LostGas, .6
215 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active 275 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active
216 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active 276 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active
217 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active 277 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active
218 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active 278 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active
219 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active 279 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active
220 MENU_CALL tExit, do_exit_divemode_menu 280 MENU_CALL tExit, do_exit_divemode_menu
221 MENU_END 281 MENU_END
222 282
223 283
224 do_switch_gas6: 284 do_switch_gas6:
225 movlw .6 ; gas 6 285 movlw .6 ; gas 6
226 movwf menupos1 ; transfer register for selected gas towards gas_switched_common: 286 movwf menupos1 ; transfer register for selected gas towards gas_switched_common
227 bsf gas6_changed ; set flag for profile recording 287 bsf gas6_changed ; set flag for profile recording
228 ;bra do_switch_gas ; continue with common gas-switched code 288 ;bra do_switch_gas ; continue with common gas-switched code
229 289
230 do_switch_gas: 290 do_switch_gas:
231 bsf divemode_gaschange ; Set flag, will also trigger restart of deco_engine 291 bsf divemode_gaschange ; set flag, will also trigger restart of deco_engine
232 btfsc is_bailout_menu ; Bailout confirmed? 292 btfss is_bailout_menu ; doing a bailout?
233 bsf is_bailout ; begin bailout mode 293 bra do_switch_gas_1 ; NO
234 call customview_mask ; update custom view mask to (eventually) rewrite ppO2(Dil): to ppO2: 294 bsf FLAG_bailout_mode ; YES - begin bailout mode
295 IFDEF _cave_mode
296 btfsc FLAG_cave_mode ; - in cave mode?
297 bsf FLAG_dive_turned ; YES - set dive as turned
298 ENDIF
299 do_switch_gas_1:
300 bcf setpoint_fallback ; eventually terminate fallback mode and get rid of its warning
301 bsf redraw_custview_mask ; request update of custom view mask to (eventually) rewrite "ppO2(Dil)" to "ppO2" or SAC label
235 ;bra do_exit_divemode_menu ; continue with exiting menu code 302 ;bra do_exit_divemode_menu ; continue with exiting menu code
236 303
237 do_exit_divemode_menu: 304 do_exit_divemode_menu:
238 call timeout_divemode_menu2 305 call timeout_divemode_menu2
239 clrf STKPTR 306 clrf STKPTR
240 goto diveloop_loop4 307 goto diveloop_loop4
241 308
242 309
243 do_toggle_active: 310 do_toggle_active:
244 extern restart_deco_engine_wo_ceiling
245 call restart_deco_engine_wo_ceiling
246 movlw .5 311 movlw .5
247 btfsc ccr_diluent_setup ; diluents? 312 btfsc FLAG_diluent_setup ; operating on diluents?
248 addwf menupos1,F ; yes 1-5 -> 6-10 313 addwf menupos1,F ; YES - add offset of 5 to shift 1-5 -> 6-10
249 decf menupos1,W ; -> 0-4 for gases / 5-9 for diluents 314 decf menupos1,W ; 1-10 -> 0-4 for gases / 5-9 for diluents
250 lfsr FSR1,opt_gas_type+0 315 lfsr FSR1,opt_gas_type ; load base address of gas types
251 movff PLUSW1,lo 316 movff PLUSW1,lo ; get gas/dil type
252 tstfsz lo ; Already disabled? 317 tstfsz lo ; already disabled?
253 bra do_toggle_active2 ; No, disable now! 318 bra do_toggle_active_disable ; NO - disable now
254 lfsr FSR1,opt_gas_type_backup+0 ; copy opt_gas_type_backup+W back to opt_gas_type+W 319 do_toggle_active_enable ; YES - re-enable now
255 movff PLUSW1,lo 320 lfsr FSR1,opt_gas_type_backup ; load base address of backed-up gas types
256 lfsr FSR1,opt_gas_type+0 321 movff PLUSW1,lo ; get backed-up gas/dil type
257 movff lo,PLUSW1 322 lfsr FSR1,opt_gas_type ; load base address of gas types
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 323 movff lo,PLUSW1 ; restore gas type
259 movff PLUSW1,lo 324 bra do_toggle_active_common
260 lfsr FSR1,opt_OC_bail_gas_change+0 325 do_toggle_active_disable: ; disable gas / diluent
261 movff lo,PLUSW1 326 ;lfsr FSR1,opt_gas_type ; (still set)
262 bra do_toggle_active3 327 clrf PLUSW1 ; set type to disabled (0=disabled, 1=first, 2=travel/normal, 3=deco/-)
263 do_toggle_active2: 328 do_toggle_active_common:
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
267 do_toggle_active3:
268 movlw .5 329 movlw .5
269 btfsc ccr_diluent_setup ; use OC gases? 330 btfsc FLAG_diluent_setup ; operating on diluents?
270 subwf menupos1,F ; back to 1-5 331 subwf menupos1,F ; NO - back to 0-4 for gases 1-5
271 bra do_lost_gas ; return to list and show updated result 332 bcf blinking_better_gas ; clear blinking flag for gases to avoid "leftovers"
272 333 bcf blinking_better_dil ; clear blinking flag for diluents to avoid "leftovers"
334 call restart_deco_engine_wo_ceiling ; invalidate deco data (but not the ceiling) and restart deco engine
335 bra do_lost_gas_common
273 336
274 do_dive_pO2: 337 do_dive_pO2:
275 banksel gas6_O2_ratio 338 banksel gas6_O2_ratio
276 incf gas6_O2_ratio,F ; O2++ 339 incf gas6_O2_ratio,F ; O2++
277 movf gas6_He_ratio,W 340 movf gas6_He_ratio,W
301 movf gas6_He_ratio,W 364 movf gas6_He_ratio,W
302 addwf gas6_O2_ratio,W 365 addwf gas6_O2_ratio,W
303 movwf lo 366 movwf lo
304 movlw .101 367 movlw .101
305 cpfslt lo ; O2 + He < 101 ? 368 cpfslt lo ; O2 + He < 101 ?
306 decf gas6_He_ratio,F ; Yes, He-- (Unchanged) 369 decf gas6_He_ratio,F ; Yes, He-- (unchanged)
307 banksel common 370 banksel common
308 bra do_divemode_gaslist_more_common 371 bra do_divemode_gaslist_more_common
309 372
310 do_dive_mHe: 373 do_dive_mHe:
311 banksel gas6_O2_ratio 374 banksel gas6_O2_ratio
318 381
319 382
320 do_divemode_splist: 383 do_divemode_splist:
321 bsf short_gas_decriptions 384 bsf short_gas_decriptions
322 movlw .1 385 movlw .1
323 movwf menupos1 ; set to first option in divemode menu 386 movwf menupos1 ; set to first option in dive mode menu
324 387
325 do_divemode_splist_common: 388 do_divemode_splist_common:
326 btfsc analog_o2_input ; do we have an analog input? 389 btfsc analog_o2_input ; do we have an analog input (OSTC cR)?
327 bra do_divemode_splist_sensor ; YES 390 bra do_divemode_splist_sensor ; YES
328 btfsc s8_digital ; do we have a digital input? 391 ; btfsc s8_digital ; do we have a digital input?
329 bra do_divemode_splist_sensor ; YES 392 ; bra do_divemode_splist_sensor ; YES
330 btfsc optical_input ; do we have an optical input? 393 btfsc optical_input ; do we have an optical input (OSTC 3)?
331 bra do_divemode_splist_sensor ; YES 394 bra do_divemode_splist_sensor ; YES
332 395
333 do_divemode_splist_no_sensor: 396 do_divemode_splist_no_sensor:
334 MENU_BEGIN tGaslist, .5 397 MENU_BEGIN tGaslist, .5
335 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp 398 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp
349 MENU_CALL tCCRSensor, do_divemode_sensor 412 MENU_CALL tCCRSensor, do_divemode_sensor
350 MENU_END 413 MENU_END
351 414
352 415
353 do_divemode_sensor: 416 do_divemode_sensor:
354 clrf menupos3 ; show customview 1 (HUD Data) 417 movlw index_ppo2_sensors-1 ; custom view number one below ppO2 sensors
355 bsf toggle_customview 418 movwf menupos3 ; set custom view number
356 movlw .1 419 bsf toggle_customview ; initiate toggle to desired custom view -> ppO2 sensors
357 movwf menupos1 ; Set to 1st option: use sensors 420 movlw .1
421 movwf menupos1 ; set to 1st option: use sensors
358 422
359 do_return_divemode_sensor: 423 do_return_divemode_sensor:
360 MENU_BEGIN tGaslist, .6 424 MENU_BEGIN tGaslist, .6
361 MENU_CALL tDivemenu_UseSensor, do_switch_sensor 425 MENU_CALL tDivemenu_UseSensor, do_switch_sensor
362 MENU_CALL tBack, do_divemode_splist 426 MENU_CALL tBack, do_divemode_splist
366 MENU_CALL tDiveHudMask3, do_toggle_sensor 430 MENU_CALL tDiveHudMask3, do_toggle_sensor
367 MENU_END 431 MENU_END
368 432
369 do_divemode_setpoint_pscr: 433 do_divemode_setpoint_pscr:
370 movlw .1 434 movlw .1
371 movwf menupos1 ; Set to 1st option: use calculated ppO2 435 movwf menupos1 ; set to 1st option: use calculated ppO2
372 MENU_BEGIN tGaslist, .6 436 MENU_BEGIN tGaslist, .6
373 MENU_CALL tCalculated, do_switch_sp_calc 437 MENU_CALL tCalculated, do_switch_sp_calc
374 MENU_CALL tDivemenu_UseSensor, do_switch_sensor 438 MENU_CALL tDivemenu_UseSensor, do_switch_sensor
375 MENU_CALL tExit, do_exit_divemode_menu 439 MENU_CALL tExit, do_exit_divemode_menu
376 MENU_CALL tDiveHudMask1, do_toggle_sensor 440 MENU_CALL tDiveHudMask1, do_toggle_sensor