comparison src/divemenu_tree.asm @ 631:185ba2f91f59

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