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