comparison src/menu_tree.asm @ 634:4050675965ea

3.10 stable release
author heinrichsweikamp
date Tue, 28 Apr 2020 17:34:31 +0200
parents 185ba2f91f59
children 9a64914a8fca
comparison
equal deleted inserted replaced
633:690c48db7b5b 634:4050675965ea
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File menu_tree.asm next combined generation V3.08.8 3 ; File menu_tree.asm * combined next generation V3.09.5
4 ; 4 ;
5 ; OSTC Surface Menus 5 ; OSTC Surface Menus
6 ; 6 ;
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
8 ;============================================================================= 8 ;=============================================================================
9 ; HISTORY 9 ; HISTORY
10 ; 2011-07-11 : [jDG] Creation. 10 ; 2011-07-11 : [jDG] Creation.
11 11
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
12 #include "hwos.inc" ; mandatory header 22 #include "hwos.inc" ; mandatory header
23 #include "shared_definitions.h" ; mailbox from/to p2_deco.c
13 #include "gaslist.inc" 24 #include "gaslist.inc"
14 #include "menu_processor.inc" 25 #include "menu_processor.inc"
15 #include "start.inc" 26 #include "start.inc"
16 #include "comm.inc" 27 #include "comm.inc"
17 #include "logbook.inc"
18 #include "tft.inc" 28 #include "tft.inc"
19 #include "eeprom_rs232.inc" 29 #include "eeprom_rs232.inc"
20 #include "external_flash.inc" 30 #include "external_flash.inc"
21 #include "shared_definitions.h" ; mailbox from/to p2_deco.c
22 #include "ghostwriter.inc"
23 #include "adc_lightsensor.inc" 31 #include "adc_lightsensor.inc"
24 #include "wait.inc" 32 #include "wait.inc"
25 #include "i2c.inc" 33 #include "i2c.inc"
26 #include "calibrate.inc" 34 #include "calibrate.inc"
27 #include "math.inc" 35 #include "math.inc"
28 #include "rtc.inc" 36 #include "rtc.inc"
29 37 #include "strings.inc"
30 38 #include "tft_outputs.inc"
31 extern do_demo_divemode 39 #include "convert.inc"
32 extern restart 40 #include "colorschemes.inc"
41
42
43 extern surfloop
44 extern logbook
45 extern demo_divemode
46 extern demo_planner
47 extern piezo_config
48 extern comm_firmware_update_exec
49
33 extern option_check_and_store_all 50 extern option_check_and_store_all
34 extern option_reset 51 extern option_reset
35 extern do_demo_planner
36 extern comm_mode_ble ; will also set CPU speed to normal
37 extern piezo_config
38 extern option_reset_all 52 extern option_reset_all
39 extern surfloop 53 extern option_adjust_group_member
40 extern oColorSetDive 54 extern option_inc
55 extern option_dec
56 extern option_draw
57
58 extern get_cpu_version
41 extern eeprom_deco_data_write 59 extern eeprom_deco_data_write
60
42 61
43 IFDEF _ccr_pscr 62 IFDEF _ccr_pscr
44 extern option_cleanup_oCCRMode 63 extern option_cleanup_oCCRMode
45 ENDIF 64 ENDIF
46 65
47 IFDEF _compass 66 IFDEF _compass
48 extern compass_calibration_loop 67 extern compass_calibration
49 ENDIF 68 ENDIF
50 69
51 70 IFDEF _rx_functions
52 menu_tree CODE 71 extern get_transmitter_id_by_slot
53 72 ENDIF
54 ;-----------------------------------------------------------------------------
55 73
56 74
57 ;============================================================================= 75 ;=============================================================================
58 ; Main Menu 76 surf_menu CODE 0x01000 ; needs to be at 0x0xxxx
59 77 ;=============================================================================
78
79
80 ;-----------------------------------------------------------------------------
81 ; Returning from a Menu Item
82 ;
60 do_return_main_menu: 83 do_return_main_menu:
61 call menu_processor_double_pop ; drop exit line and back to last line 84 call menu_processor_double_pop ; drop exit line and back to last line
62 bra do_main_menu_common 85 bra main_menu_common ; continue with menu
63 86
64 global do_main_menu 87
65 do_main_menu: 88 ;-----------------------------------------------------------------------------
89 ; Entry Point for Main Menu
90 ;
91 global main_menu
92 main_menu:
66 movff active_customview,customview_surfmode ; save last custom view 93 movff active_customview,customview_surfmode ; save last custom view
67 clrf MS_flags_imprint ; clear all flags for data imprinting 94 clrf MS_flags_imprint ; clear all flags for data imprinting
68
69 global do_main_menu2
70 do_main_menu2: ; entry point used by logbook.asm
71 call TFT_boot ; initialize display 95 call TFT_boot ; initialize display
72 call menu_processor_reset ; reset menu stack 96 call menu_processor_reset ; reset menu stack
73 97
74 do_main_menu_common: 98 main_menu_common:
75 IFDEF _ccr_pscr 99 IFDEF _ccr_pscr
76 MENU_BEGIN tMainMenu, .7 100 MENU_BEGIN tMainMenu, .7
77 MENU_CALL tLogbook, logbook 101 MENU_CALL tLogbook, do_logbook
78 MENU_CALL tGasSetup, do_gas_menu 102 MENU_CALL tGasSetup, do_menu_gas
79 MENU_CALL tCCRSetup, do_ccr_menu 103 MENU_CALL tCCRSetup, do_menu_ccr
80 MENU_CALL tDiveModeMenu, do_divemode_menu 104 MENU_CALL tDiveModeMenu, do_menu_dive
81 MENU_CALL tSimulator, do_simulator_menu 105 MENU_CALL tSimulator, do_menu_simulator
82 MENU_CALL tSystSets, do_settings_menu 106 MENU_CALL tSystSets, do_menu_settings
83 MENU_CALL tExit, do_restart 107 MENU_CALL tExit, do_restart
84 MENU_END 108 MENU_END
85 ELSE 109 ELSE
86 MENU_BEGIN tMainMenu, .6 110 MENU_BEGIN tMainMenu, .6
87 MENU_CALL tLogbook, logbook 111 MENU_CALL tLogbook, do_logbook
88 MENU_CALL tGasSetup, do_gas_menu 112 MENU_CALL tGasSetup, do_menu_gas
89 MENU_CALL tDiveModeMenu, do_divemode_menu 113 MENU_CALL tDiveModeMenu, do_menu_dive
90 MENU_CALL tSimulator, do_simulator_menu 114 MENU_CALL tSimulator, do_menu_simulator
91 MENU_CALL tSystSets, do_settings_menu 115 MENU_CALL tSystSets, do_menu_settings
92 MENU_CALL tExit, do_restart 116 MENU_CALL tExit, do_restart
93 MENU_END 117 MENU_END
94 ENDIF 118 ENDIF ; _ccr_pscr
95 119
96 120
121 ;-----------------------------------------------------------------------------
122 ; Call Function - start Logbook
123 ;
124 do_logbook:
125 goto logbook ; code is hosted in logbook.asm
126
127
128 ;-----------------------------------------------------------------------------
129 ; Call Function - exit Menu
130 ;
97 do_restart: 131 do_restart:
98 bsf restart_fast ; skip logos and waits an restart 132 bsf restart_fast ; skip logos and waits an restart
99 goto restart ; restart into surface mode 133 goto restart ; restart into surface mode
100 134
101 ;=============================================================================
102 ; CCR Setup
103 135
104 IFDEF _ccr_pscr 136 IFDEF _ccr_pscr
105 137
106 do_return_ccr_menu: 138 ;-----------------------------------------------------------------------------
139 ; returning to CCR / pSCR Setup
140 ;
141 do_return_menu_ccr:
107 call menu_processor_double_pop ; drop exit line and back to last line 142 call menu_processor_double_pop ; drop exit line and back to last line
108 143 ;bra do_menu_ccr
109 do_ccr_menu: 144
145
146 ;-----------------------------------------------------------------------------
147 ; CCR / pSCR Setup - 1st Level
148 ;
149 do_menu_ccr:
110 call option_cleanup_oCCRMode ; in pSCR mode, revert AutoSP (2) to calculated SP (0) 150 call option_cleanup_oCCRMode ; in pSCR mode, revert AutoSP (2) to calculated SP (0)
111 151
112 IFDEF _external_sensor 152 IFDEF _external_sensor
153
113 bcf imprint_sensor_mv ; stop imprinting of live O2 sensor mV data 154 bcf imprint_sensor_mv ; stop imprinting of live O2 sensor mV data
114 btfsc analog_o2_input 155 btfss ext_input_s8_ana ; S8/analog sensor input available?
115 bra do_ccr_menu_cR 156 bra do_menu_ccr_2 ; NO - do OSTC 2 menu
116 ENDIF 157 ;bra do_menu_ccr_cR ; YES - do OSTC cR menu
117 158
118 MENU_BEGIN tCCRSetup, .5 ; OSTC3 menu (and currently also the OSTC2 menu) 159 do_menu_ccr_cR: ; OSTC cR menu
119 MENU_OPTION tCCRMode, oCCRMode, 0 160 MENU_BEGIN tCCRSetup, .6
120 MENU_CALL tDiluentSetup, do_diluent_setup 161 MENU_OPT_INC tCCRMode, oCCRMode
121 MENU_CALL tFixedSetpoints, do_fixed_setpoints 162 MENU_CALL tCalibrateMenu, do_menu_calibrate
122 MENU_CALL tMore, do_ccr_menu_more 163 MENU_CALL tDiluentSetup, do_menu_diluent
164 MENU_CALL tFixedSetpoints, do_menu_setpoints
165 MENU_CALL tMore, do_menu_ccr_more
123 MENU_CALL tBack, do_return_main_menu 166 MENU_CALL tBack, do_return_main_menu
124 MENU_END 167 MENU_END
125 168
126 169 ENDIF ; _external_sensor
170
171 do_menu_ccr_2:
172 MENU_BEGIN tCCRSetup, .5 ; OSTC 2 menu
173 MENU_OPT_INC tCCRMode, oCCRMode
174 MENU_CALL tDiluentSetup, do_menu_diluent
175 MENU_CALL tFixedSetpoints, do_menu_setpoints
176 MENU_CALL tMore, do_menu_ccr_more
177 MENU_CALL tBack, do_return_main_menu
178 MENU_END
179
180
181 ;-----------------------------------------------------------------------------
182 ; CCR / pSCR Setup - 2nd Level
183 ;
184 do_menu_ccr_more:
127 IFDEF _external_sensor 185 IFDEF _external_sensor
128 186 MENU_BEGIN tCCRSetup, .7 ; CCR/pSCR more menu
129 do_ccr_menu_cR: ; cR menu 187 MENU_OPT_INC tS8Mode, oS8Mode
130 MENU_BEGIN tCCRSetup, .6 188 MENU_OPT_INC tCCmaxFracO2, oCCmaxFracO2
131 MENU_OPTION tCCRMode, oCCRMode, 0 189 MENU_OPT_INC tDilppO2Check, oDilppO2Check
132 MENU_CALL tCalibrateMenu, do_calibrate_menu 190 MENU_OPT_INC tGasDensityCheck, oGasDensityCheck
133 MENU_CALL tDiluentSetup, do_diluent_setup 191 MENU_OPT_INC tPSCR_O2_drop, oPSCR_drop
134 MENU_CALL tFixedSetpoints, do_fixed_setpoints 192 MENU_OPT_INC tPSCR_lungratio, oPSCR_lungratio
135 MENU_CALL tMore, do_ccr_menu_more 193 MENU_CALL tBack, do_return_menu_ccr
136 MENU_CALL tBack, do_return_main_menu 194 MENU_END
137 MENU_END 195 ELSE
138 196 MENU_BEGIN tCCRSetup, .6 ; CCR/pSCR more menu
139 197 MENU_OPT_INC tCCmaxFracO2, oCCmaxFracO2
140 do_calibrate_menu: 198 MENU_OPT_INC tDilppO2Check, oDilppO2Check
141 call enable_ir_s8 ; enable IR/S8-Port 199 MENU_OPT_INC tGasDensityCheck, oGasDensityCheck
200 MENU_OPT_INC tPSCR_O2_drop, oPSCR_drop
201 MENU_OPT_INC tPSCR_lungratio, oPSCR_lungratio
202 MENU_CALL tBack, do_return_menu_ccr
203 MENU_END
204 ENDIF ; _external_sensor
205
206 ENDIF ; _ccr_pscr
207
208
209 IFDEF _external_sensor
210
211 ;-----------------------------------------------------------------------------
212 ; Calibration Menu
213 ;
214 do_menu_calibrate:
215 call enable_ir_s8_analog ; enable IR/S8/analog interface
142 bsf imprint_sensor_mv ; start imprinting of live O2 sensor mV data 216 bsf imprint_sensor_mv ; start imprinting of live O2 sensor mV data
143 217
144 do_calibrate_menu2:
145 MENU_BEGIN tCalibrateMenu, .6 218 MENU_BEGIN tCalibrateMenu, .6
146 MENU_CALL tDiveHudMask1, 0 219 MENU_CALL tDiveHudMask1, 0 ; data will be superimposed by housekeeping
147 MENU_CALL tDiveHudMask2, 0 220 MENU_CALL tDiveHudMask2, 0 ; ...
148 MENU_CALL tDiveHudMask3, 0 221 MENU_CALL tDiveHudMask3, 0 ; ...
149 MENU_OPTION tCalibrationGas, oCalGasO2, 0 222 MENU_OPT_INC tCalibrationGas, oCalGasO2
150 MENU_CALL tCalibrate, do_calibrate_mix 223 MENU_CALL tCalibrate, do_calibrate
151 MENU_CALL tBack, do_return_ccr_menu 224 MENU_CALL tBack, do_return_menu_ccr
152 MENU_END 225 MENU_END
153 226
154 227
155 do_calibrate_mix: 228 ;-----------------------------------------------------------------------------
229 ; Call Function - start Calibration, returns to Surface Mode
230 ;
231 do_calibrate:
156 call calibrate_mix ; calibrate with opt_calibration_O2_ratio, also calibrate S8 HUD if connected 232 call calibrate_mix ; calibrate with opt_calibration_O2_ratio, also calibrate S8 HUD if connected
157 WAITMS d'250' ; wait for HUD v3 233 WAITMS d'250' ; wait for HUD v3
158 movlw .9 234 movlw .9 ; load index of sensor mV custom view
159 movff WREG,customview_surfmode ; show sensor mV custom view after restart 235 movff WREG,customview_surfmode ; show this custom view when back in surface mode
160 bsf restart_fast ; skip logos and waits an restart 236 bra do_restart ; exit menu
161 goto restart ; restart into surface mode
162 237
163 ENDIF ; _external_sensor 238 ENDIF ; _external_sensor
164 239
165 240
166 do_diluent_setup: 241 IFDEF _ccr_pscr
242
243 ;-----------------------------------------------------------------------------
244 ; Diluent Setup
245 ;
246 do_menu_diluent:
167 bsf is_diluent_menu ; setting up diluents 247 bsf is_diluent_menu ; setting up diluents
168 bcf short_gas_descriptions ; do not use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint 248 bcf short_gas_descriptions ; use long gas description format
169 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) 249 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only)
170 call gaslist_cleanup_list ; take care that only one gas can be first 250 call gaslist_cleanup_list ; make sure there is only one gas being first
171 251
172 MENU_BEGIN tDiluentSetup, .6 252 MENU_BEGIN tDiluentSetup, .6
173 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu 253 MENU_DYNAMIC dyn_strcat_gas_PRODL, do_menu_edit_gas
174 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu 254 MENU_DYNAMIC dyn_strcat_gas_PRODL, do_menu_edit_gas
175 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu 255 MENU_DYNAMIC dyn_strcat_gas_PRODL, do_menu_edit_gas
176 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu 256 MENU_DYNAMIC dyn_strcat_gas_PRODL, do_menu_edit_gas
177 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu 257 MENU_DYNAMIC dyn_strcat_gas_PRODL, do_menu_edit_gas
178 MENU_CALL tBack, do_return_ccr_menu 258 MENU_CALL tBack, do_return_menu_ccr
179 MENU_END 259 MENU_END
180 260
181 261
182 do_return_fixed_setpoints: 262 ;-----------------------------------------------------------------------------
263 ; dynamic Title - show full Gas Description (just for info, active code is in other place)
264 ;
265 ;dyn_strcat_gas_PRODL:
266 ; goto gaslist_strcat_gas_PRODL ; code is hosted in gaslist.asm
267
268
269 ;-----------------------------------------------------------------------------
270 ; returning to Setpoint Setup
271 ;
272 do_return_menu_setpoints:
183 call menu_processor_double_pop ; drop exit line and back to last line 273 call menu_processor_double_pop ; drop exit line and back to last line
184 274 bcf block_option_value ; resume displaying of option values
185 do_fixed_setpoints: 275 ;bra do_menu_setpoints ; continue
186 bcf short_gas_descriptions ; =1: use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint 276
277
278 ;-----------------------------------------------------------------------------
279 ; Setpoint Setup - 1st Level
280 ;
281 do_menu_setpoints:
282 bcf short_gas_descriptions ; use long gas description format
187 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) 283 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only)
188 284
189 MENU_BEGIN tFixedSetpoints, .6 285 MENU_BEGIN tFixedSetpoints, .6
190 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu 286 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_menu_edit_sp
191 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu 287 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_menu_edit_sp
192 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu 288 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_menu_edit_sp
193 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu 289 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_menu_edit_sp
194 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu 290 MENU_DYNAMIC dyn_strcat_setpoint_prodl, do_menu_edit_sp
195 MENU_CALL tBack, do_return_ccr_menu 291 MENU_CALL tBack, do_return_menu_ccr
196 MENU_END 292 MENU_END
197 293
198 294
199 do_edit_sp_menu: 295 ;-----------------------------------------------------------------------------
296 ; dynamic Title - show Setpoint Data
297 ;
298 dyn_strcat_setpoint_prodl:
299 goto gaslist_strcat_setpoint_PRODL ; function is hosted in gaslist.asm
300
301
302 ;-----------------------------------------------------------------------------
303 ; Setpoint Setup - 2nd Level
304 ;
305 do_menu_edit_sp:
200 movff PRODL,gaslist_gas ; get menu item we came from (0-4) 306 movff PRODL,gaslist_gas ; get menu item we came from (0-4)
307 bsf block_option_value ; suspend displaying of option values
201 308
202 MENU_BEGIN tFixedSetpoints, .5 309 MENU_BEGIN tFixedSetpoints, .5
203 MENU_DYNAMIC gaslist_strcat_setpoint_0, 0 310 MENU_DYNAMIC dyn_strcat_setpoint, 0
204 MENU_CALL tSPPlus, gaslist_spplus 311 MENU_GRP_INC tSPPlus, oSP1ppO2
205 MENU_CALL tDepthPlus, gaslist_spdepthplus 312 MENU_GRP_INCS tDepthPlus, oSP1Depth
206 MENU_CALL tDepthMinus, gaslist_spdepthminus 313 MENU_GRP_DECS tDepthMinus, oSP1Depth
207 MENU_CALL tBack, do_return_fixed_setpoints 314 MENU_CALL tBack, do_return_menu_setpoints
208 MENU_END 315 MENU_END
209 316
210 317
211 do_ccr_menu_more: 318 ;-----------------------------------------------------------------------------
212 IFDEF _external_sensor 319 ; dynamic Title - show Setpoint Data
213 MENU_BEGIN tCCRSetup, .6 ; CCR/pSCR more menu 320 ;
214 MENU_OPTION tS8Mode, oS8Mode, 0 321 dyn_strcat_setpoint:
215 MENU_OPTION tCCmaxFracO2, oCCmaxFracO2, 0 322 goto gaslist_strcat_setpoint ; function is hosted in gaslist.asm
216 MENU_OPTION tDilppO2Check, oDilppO2Check, 0
217 MENU_OPTION tPSCR_O2_drop, oPSCR_drop, 0
218 MENU_OPTION tPSCR_lungratio, oPSCR_lungratio, 0
219 MENU_CALL tBack, do_return_ccr_menu
220 MENU_END
221 ELSE
222 MENU_BEGIN tCCRSetup, .5 ; CCR/pSCR more menu
223 MENU_OPTION tCCmaxFracO2, oCCmaxFracO2, 0
224 MENU_OPTION tDilppO2Check, oDilppO2Check, 0
225 MENU_OPTION tPSCR_O2_drop, oPSCR_drop, 0
226 MENU_OPTION tPSCR_lungratio, oPSCR_lungratio, 0
227 MENU_CALL tBack, do_return_ccr_menu
228 MENU_END
229 ENDIF ; _external_sensor
230 323
231 ENDIF ; _ccr_pscr 324 ENDIF ; _ccr_pscr
232 325
233 ;============================================================================= 326
234 ; OC Gas Setup 327 ;-----------------------------------------------------------------------------
235 328 ; returning from Gas / Diluent Setup
236 do_return_gas_menu: 329 ;
330 do_return_menu_gas:
237 call menu_processor_double_pop ; drop exit line and back to last line 331 call menu_processor_double_pop ; drop exit line and back to last line
238 332
239 IFDEF _ccr_pscr 333 IFDEF _ccr_pscr
240 btfsc is_diluent_menu ; return from setting up diluents? 334 btfsc is_diluent_menu ; return from setting up diluents?
241 bra do_diluent_setup ; YES 335 bra do_menu_diluent ; YES - continue with diluent menu
336 ;bra do_menu_gas ; NO - continue with OC gas menu
242 ENDIF 337 ENDIF
243 338
244 do_gas_menu: 339
340 ;-----------------------------------------------------------------------------
341 ; OC Gas Setup - 1st Level
342 ;
343 do_menu_gas:
245 bcf is_diluent_menu ; setting up OC gases 344 bcf is_diluent_menu ; setting up OC gases
246 bcf short_gas_descriptions ; do not use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint 345 bcf short_gas_descriptions ; use long gas description format
247 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) 346 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only)
248 call gaslist_cleanup_list ; takes care that only one gas can be first 347 call gaslist_cleanup_list ; make sure there is only one gas being first
249 348
250 MENU_BEGIN tGaslist, .6 349 MENU_BEGIN tGaslist, .6
251 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu 350 MENU_DYNAMIC dyn_strcat_gas_PRODL, do_menu_edit_gas
252 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu 351 MENU_DYNAMIC dyn_strcat_gas_PRODL, do_menu_edit_gas
253 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu 352 MENU_DYNAMIC dyn_strcat_gas_PRODL, do_menu_edit_gas
254 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu 353 MENU_DYNAMIC dyn_strcat_gas_PRODL, do_menu_edit_gas
255 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu 354 MENU_DYNAMIC dyn_strcat_gas_PRODL, do_menu_edit_gas
256 MENU_CALL tBack, do_return_main_menu 355 MENU_CALL tBack, do_return_main_menu
257 MENU_END 356 MENU_END
258 357
259 358
260 do_return_edit_gas_menu: 359 ;-----------------------------------------------------------------------------
360 ; dynamic Title - show full Gas Description
361 ;
362 dyn_strcat_gas_PRODL:
363 goto gaslist_strcat_gas_PRODL ; code is hosted in gaslist.asm
364
365
366 ;-----------------------------------------------------------------------------
367 ; return to OC Gas Setup from Sub-Menu
368 ;
369 do_return_menu_edit_gas:
261 IFDEF _rx_functions 370 IFDEF _rx_functions
262 bcf imprint_xmitter_pres ; stop imprinting of transmitter pressure data 371 bcf imprint_xmitter_pres ; stop imprinting of transmitter pressure data
263 bcf imprint_xmitter_ID ; not in transmitter selection menu any more (back to normal timeout) 372 bcf imprint_xmitter_ID ; not in transmitter selection menu any more (back to normal timeout)
264 ENDIF 373 ENDIF
265 call menu_processor_double_pop ; drop exit line and back to last line 374 call menu_processor_double_pop ; drop exit line and back to last line
266 bra do_edit_gas_menu_common 375 bcf block_option_value ; resume displaying of option values
267 376 bra do_menu_edit_gas_common ; continue with common part
268 do_edit_gas_menu: 377
378
379 ;-----------------------------------------------------------------------------
380 ; OC Gas Setup - 2nd Level
381 ;
382 do_menu_edit_gas:
269 movff PRODL,gaslist_gas ; get menu item we came from (0-4) 383 movff PRODL,gaslist_gas ; get menu item we came from (0-4)
270 movlw .5 ; offset between gases and diluents 384 movlw .5 ; offset between gases and diluents
271 btfsc is_diluent_menu ; setting up diluents? 385 btfsc is_diluent_menu ; setting up diluents?
272 addwf gaslist_gas,F ; YES - add the offset 386 addwf gaslist_gas,F ; YES - add the offset
273 387
274 do_edit_gas_menu_common: 388 do_menu_edit_gas_common:
275 MENU_BEGIN tGasEdit, .7 389 MENU_BEGIN tGasEdit, .7
276 MENU_DYNAMIC gaslist_gastitle, 0 390 MENU_DYNAMIC dyn_gastitle, 0
277 MENU_DYNAMIC gaslist_MOD_END, 0 391 MENU_DYNAMIC dyn_MOD_END, 0
278 MENU_DYNAMIC gaslist_show_type, gaslist_toggle_type 392 MENU_GRP_INC tType, oGas1
279 MENU_CALL tSetup_GasMix, do_setup_mix_menu 393 MENU_CALL tSetup_GasMix, do_menu_gas_mix
280 MENU_DYNAMIC gaslist_GasDepth, do_setup_depth_menu 394 MENU_DYNAMIC dyn_show_depth, do_menu_gas_depth
281 MENU_CALL tSetup_Tank, do_setup_tank_menu 395 MENU_CALL tSetup_Tank, do_menu_gas_tank
282 MENU_CALL tBack, do_return_gas_menu 396 MENU_CALL tBack, do_return_menu_gas
283 MENU_END 397 MENU_END
284 398
285 399
286 do_setup_mix_menu: 400 ;-----------------------------------------------------------------------------
401 ; dynamic Title - show full Gas Description
402 ;
403 dyn_gastitle:
404 goto gaslist_strcat_gas ; code is hosted in gaslist.asm
405
406
407 ;-----------------------------------------------------------------------------
408 ; dynamic Title - show MOD and END
409 ;
410 dyn_MOD_END:
411 goto gaslist_MOD_END ; code is hosted in gaslist.asm
412
413
414 ;-----------------------------------------------------------------------------
415 ; dynamic Title - show Change Depth
416 ;
417 dyn_show_depth:
418 movf gaslist_gas,W ; load gas/dil index into WREG (0-9)
419 lfsr FSR1,opt_gas_change ; load base address of change depths
420 tstfsz PLUSW1 ; change depth = 0 ?
421 bra dyn_show_depth_1 ; NO - print in normal color
422 lfsr FSR1,opt_gas_type ; YES - load base address of opt_gas_type
423 tstfsz PLUSW1 ; - type = disabled ?
424 FONT_COLOR_ATTENTION ; NO - print in attention color (yellow)
425 dyn_show_depth_1:
426 STRCAT_TEXT tSetup_GasDepth ; print text
427 return ; done
428
429
430 ;-----------------------------------------------------------------------------
431 ; OC Gas Setup - 3rd Level - Mix
432 ;
433 do_menu_gas_mix:
434 bsf block_option_value ; suspend displaying of option values
435
287 IFDEF _helium 436 IFDEF _helium
288 MENU_BEGIN tGasEdit, .7 437 MENU_BEGIN tGasEdit, .7
289 MENU_DYNAMIC gaslist_gastitle, 0 438 MENU_DYNAMIC dyn_gastitle, 0
290 MENU_DYNAMIC gaslist_MOD_END, 0 439 MENU_DYNAMIC dyn_MOD_END, 0
291 MENU_CALL tO2Plus, gaslist_pO2 440 MENU_GRP_INCS tO2Plus, oGas1O2
292 MENU_CALL tO2Minus, gaslist_mO2 441 MENU_GRP_DECS tO2Minus, oGas1O2
293 MENU_CALL tHePlus, gaslist_pHe 442 MENU_GRP_INCS tHePlus, oGas1He
294 MENU_CALL tHeMinus, gaslist_mHe 443 MENU_GRP_DECS tHeMinus, oGas1He
295 MENU_CALL tBack, do_return_edit_gas_menu 444 MENU_CALL tBack, do_return_menu_edit_gas
296 MENU_END 445 MENU_END
297 ELSE 446 ELSE
298 MENU_BEGIN tGasEdit, .5 447 MENU_BEGIN tGasEdit, .5
299 MENU_DYNAMIC gaslist_gastitle, 0 448 MENU_DYNAMIC dyn_gastitle, 0
300 MENU_DYNAMIC gaslist_MOD_END, 0 449 MENU_DYNAMIC dyn_MOD_END, 0
301 MENU_CALL tO2Plus, gaslist_pO2 450 MENU_GRP_INCS tO2Plus, oGas1O2
302 MENU_CALL tO2Minus, gaslist_mO2 451 MENU_GRP_DECS tO2Minus, oGas1O2
303 MENU_CALL tBack, do_return_edit_gas_menu 452 MENU_CALL tBack, do_return_menu_edit_gas
304 MENU_END 453 MENU_END
305 ENDIF 454 ENDIF
306 455
307 456
308 do_setup_tank_menu: 457 ;-----------------------------------------------------------------------------
458 ; OC Gas Setup - 3rd Level - Change Depth
459 ;
460 do_menu_gas_depth:
461 bsf block_option_value ; suspend displaying of option values
462
463 MENU_BEGIN tGasEdit, .7
464 MENU_DYNAMIC dyn_gastitle, 0
465 MENU_DYNAMIC dyn_MOD_END, 0
466 MENU_DYNAMIC dyn_ppo2, 0
467 MENU_GRP_INCS tDepthPlus, oGas1Depth
468 MENU_GRP_DECS tDepthMinus, oGas1Depth
469 MENU_DYNAMIC dyn_reset_mod_title, do_gas_depth_reset
470 MENU_CALL tBack, do_return_menu_edit_gas
471 MENU_END
472
473
474 ;-----------------------------------------------------------------------------
475 ; dynamic Title - show Gas Description
476 ;
477 ;dyn_gastitle:
478 ; goto gaslist_strcat_gas ; code is hosted in gaslist.asm
479
480
481 ;-----------------------------------------------------------------------------
482 ; dynamic Title - show MOD and END
483 ;
484 ;dyn_MOD_END:
485 ; goto gaslist_MOD_END ; code is hosted in gaslist.asm
486
487
488 ;-----------------------------------------------------------------------------
489 ; dynamic Title - show ppO2 and Change Depth
490 ;
491 dyn_ppo2:
492 goto gaslist_ppo2 ; code is hosted in gaslist.asm
493
494
495 ;-----------------------------------------------------------------------------
496 ; dynamic Title - show 'Rest to MOD' Dialog
497 ;
498 dyn_reset_mod_title:
499 goto gaslist_reset_mod_title ; code is hosted in gaslist.asm
500
501
502 ;-----------------------------------------------------------------------------
503 ; Call Function - reset Change Depth to MOD
504 ;
505 do_gas_depth_reset:
506 call gaslist_calc_mod ; compute MOD, result in WREG
507 movwf lo ; copy result to lo
508 lfsr FSR1,opt_gas_change ; load base address of opt_gas_change
509 movf gaslist_gas,W ; load index
510 movff lo,PLUSW1 ; update change depth
511 bsf option_changed ; flag that EEPROM needs to be updated
512 return ; done
513
514
515 ;-----------------------------------------------------------------------------
516 ; OC Gas Setup - 3rd Level - Tank Setup
517 ;
518 do_menu_gas_tank:
309 IFDEF _rx_functions 519 IFDEF _rx_functions
310 TSTOSC opt_TR_mode ; TR functions switched on? 520 TSTOSC opt_TR_mode ; TR functions switched on?
311 bra do_setup_tank_menu_rx ; YES 521 bra do_menu_gas_tank_rx ; YES
312 ENDIF 522 ENDIF
313 523
314 IFDEF _ccr_pscr 524 IFDEF _ccr_pscr
315 MENU_BEGIN tSetup_Tank, .6 525 MENU_BEGIN tSetup_Tank, .5
316 MENU_DYNAMIC gaslist_gastitle, 0 526 MENU_DYNAMIC dyn_gastitle, 0
317 MENU_DYNAMIC gaslist_tank_size_pres, 0 527 MENU_GRP_INC tTankSize, oTankSizeOC1
318 MENU_CALL tTankSize, gaslist_tank_size 528 MENU_GRP_INC tTankUsablePress, oTankPresOC1
319 MENU_CALL tTankUsablePress, gaslist_tank_pres 529 MENU_CALL tCopyDilToOC, do_copy_dil_to_oc
320 MENU_CALL tCopyDilToOC, gaslist_copy_dil_to_oc 530 MENU_CALL tBack, do_return_menu_edit_gas
321 MENU_CALL tBack, do_return_edit_gas_menu
322 MENU_END 531 MENU_END
323 ELSE 532 ELSE
324 MENU_BEGIN tSetup_Tank, .5 533 MENU_BEGIN tSetup_Tank, .4
325 MENU_DYNAMIC gaslist_gastitle, 0 534 MENU_DYNAMIC dyn_gastitle, 0
326 MENU_DYNAMIC gaslist_tank_size_pres, 0 535 MENU_GRP_INC tTankSize, oTankSizeOC1
327 MENU_CALL tTankSize, gaslist_tank_size 536 MENU_GRP_INC tTankUsablePress, oTankPresOC1
328 MENU_CALL tTankUsablePress, gaslist_tank_pres 537 MENU_CALL tBack, do_return_menu_edit_gas
329 MENU_CALL tBack, do_return_edit_gas_menu 538 MENU_END
330 MENU_END 539 ENDIF ; _ccr_pscr
331 ENDIF
332 540
333 541
334 IFDEF _rx_functions 542 IFDEF _rx_functions
335 do_setup_tank_menu_rx: 543 do_menu_gas_tank_rx:
336 setf pairing_slot ; prime slot number with 255 aka -1, used in pairing function 544 setf pairing_slot ; prime slot number with 255 aka -1, used in pairing function
337 bsf imprint_xmitter_ID ; in transmitter selection menu (longer timeout) 545 bsf imprint_xmitter_ID ; in transmitter selection menu (longer timeout)
338 546
547 IFDEF _ccr_pscr
339 MENU_BEGIN tSetup_Tank, .7 548 MENU_BEGIN tSetup_Tank, .7
340 MENU_DYNAMIC gaslist_gastitle, 0 549 MENU_DYNAMIC dyn_gastitle, 0
341 MENU_DYNAMIC gaslist_tank_id_pres, 0 ; when changing position, adopt TFT_menu_tank_pres! 550 MENU_DYNAMIC dyn_tank_id_pres, 0 ; pressure will be superimposed by housekeeping
342 MENU_DYNAMIC gaslist_tank_size_pres, 0 551 MENU_CALL tTankPairing, do_tank_pairing
343 MENU_CALL tTankPairing, gaslist_tank_pairing 552 MENU_GRP_INC tTankSize, oTankSizeOC1
344 MENU_CALL tTankSize, gaslist_tank_size 553 MENU_GRP_INC tTankUsablePress, oTankPresOC1
345 MENU_CALL tTankUsablePress, gaslist_tank_pres 554 MENU_CALL tCopyDilToOC, do_copy_dil_to_oc
346 MENU_CALL tBack, do_return_edit_gas_menu 555 MENU_CALL tBack, do_return_menu_edit_gas
347 MENU_END 556 MENU_END
348 ENDIF 557 ELSE
349 558 MENU_BEGIN tSetup_Tank, .6
350 559 MENU_DYNAMIC dyn_gastitle, 0
351 do_setup_depth_menu: 560 MENU_DYNAMIC dyn_tank_id_pres, 0 ; pressure will be superimposed by housekeeping
352 561 MENU_CALL tTankPairing, do_tank_pairing
353 MENU_BEGIN tGasEdit, .7 562 MENU_GRP_INC tTankSize, oTankSizeOC1
354 MENU_DYNAMIC gaslist_gastitle, 0 563 MENU_GRP_INC tTankUsablePress, oTankPresOC1
355 MENU_DYNAMIC gaslist_MOD_END, 0 564 MENU_CALL tBack, do_return_menu_edit_gas
356 MENU_DYNAMIC gaslist_ppo2, 0 ; ppO2 at change depth 565 MENU_END
357 MENU_CALL tDepthPlus, gaslist_pDepth 566 ENDIF ; _ccr_pscr
358 MENU_CALL tDepthMinus, gaslist_mDepth 567
359 MENU_DYNAMIC gaslist_reset_mod_title, gaslist_reset_mod 568
360 MENU_CALL tBack, do_return_edit_gas_menu 569 ;-----------------------------------------------------------------------------
361 MENU_END 570 ; dynamic Title - show Transmitter ID
362 571 ;
363 572 dyn_tank_id_pres:
364 ;============================================================================= 573 STRCAT " ID: " ; print header
365 ; Simulator Menus 574 ; get ID
366 575 lfsr FSR1,opt_transmitter_id_1 ; load base address of opt_transmitter_id
367 do_return_planner_menu: 576 movf gaslist_gas,W ; load index (0-9)
577 rlncf WREG,W ; multiply by 2 because IDs are 2 byte in size
578 movff PLUSW1,lo ; copy opt_transmitter_id+0[gaslist_gas] to lo
579 incf WREG,W ; increment index
580 movff PLUSW1,hi ; copy opt_transmitter_id+1[gaslist_gas] to hi
581 ; check if a transmitter is paired to this tank
582 tstfsz hi ; high byte of ID <> 0 ?
583 bra dyn_tank_id_pres_1 ; YES - a transmitter is paired to the tank
584 tstfsz lo ; low byte of ID <> 0 ?
585 bra dyn_tank_id_pres_1 ; YES - a transmitter is paired to the tank
586 STRCAT "----" ; NO - no transmitter paired
587 bcf imprint_xmitter_pres ; - stop imprinting of transmitter pressure data
588 return ; - done
589 dyn_tank_id_pres_1: ; show ID
590 movf hi,W ; copy high byte of ID to WREG
591 output_hex ; print it
592 movf lo,W ; copy low byte of ID to WREG
593 output_hex ; print it
594 bsf imprint_xmitter_pres ; start imprinting of transmitter pressure data
595 return ; done
596
597
598 ;-----------------------------------------------------------------------------
599 ; Call Function - pair a Transmitter to a Tank
600 ;
601 do_tank_pairing:
602 incf pairing_slot,F ; goto next RX data slot
603 btfsc pairing_slot,3 ; slot = 8?
604 bra do_tank_pairing_none ; YES - offer unpairing
605 movf pairing_slot,W ; NO - copy slot to WREG
606 call get_transmitter_id_by_slot ; WREG = slot (0-7) -> hi:lo = transmitter ID
607 tstfsz hi ; transmitter found (probe on high byte)?
608 bra do_tank_pairing_common ; YES - select this transmitter
609 tstfsz hi ; transmitter found (probe on low byte)?
610 bra do_tank_pairing_common ; YES - select this transmitter
611 bra do_tank_pairing ; NO - try next slot
612 do_tank_pairing_common:
613 lfsr FSR1,opt_transmitter_id_1 ; load base address of opt_transmitter_id
614 movf gaslist_gas,W ; load index into WREG (0-9)
615 rlncf WREG,W ; multiply by 2 because IDs are 2 byte in size
616 movff lo,PLUSW1 ; copy lo to opt_transmitter_id+0[gaslist_gas]
617 incf WREG,W ; increment index
618 movff hi,PLUSW1 ; copy hi to opt_transmitter_id+1[gaslist_gas]
619 bsf option_changed ; flag that EEPROM needs to be updated
620 return ; done
621 do_tank_pairing_none:
622 setf pairing_slot ; prime slot number with 255 aka -1
623 clrf hi ; adjust "no transmitter" ID
624 clrf lo ; adjust "no transmitter" ID
625 bra do_tank_pairing_common ; continue with common part
626
627 ENDIF ; _rx_functions
628
629
630 IFDEF _ccr_pscr
631
632 ;-----------------------------------------------------------------------------
633 ; Call Function - copy Diluent Setup to OC Gases
634 ;
635 do_copy_dil_to_oc:
636 bcf copying_dil ; default to copying a gas
637 movf gaslist_gas,W ; copy current gas or diluent number to WREG
638 btfss is_diluent_menu ; setting up diluents?
639 bra do_copy_dil_to_oc_1 ; NO - gaslist_gas is already pointing to an OC gas
640 addlw -.5 ; YES - subtract offset between diluents and gases
641 movwf gaslist_gas ; - let gaslist_gas point to the corresponding OC gas
642 bsf copying_dil ; - we are copying a diluent
643 bcf is_diluent_menu ; - pretend we are setting up OC gases
644 do_copy_dil_to_oc_1:
645 lfsr FSR0,opt_dil_O2_ratio ; load base address of diluents settings, ASM variables
646 lfsr FSR1,opt_gas_O2_ratio ; load base address of gas settings, ASM variables
647 movff PLUSW0,PLUSW1 ; copy O2 ratio
648 addlw .10 ; add offset from O2 ratios to He ratios
649 movff PLUSW0,PLUSW1 ; copy He ratio
650 addlw .10 ; add offset from He ratios to types
651 movff PLUSW0,PLUSW1 ; copy type
652 addlw .10 ; add offset from type to change depth
653 movff PLUSW0,PLUSW1 ; copy change depth
654 addlw -.30 ; wind back to initial gas number
655 lfsr FSR0,char_I_gas_avail_size+5; load base address of diluents settings, shared variables
656 lfsr FSR1,char_I_gas_avail_size+0; load base address of gas settings, shared variables
657 movff PLUSW0,PLUSW1 ; copy tank size
658 addlw .10 ; add offset from tank sizes to pressure budget
659 movff PLUSW0,PLUSW1 ; copy pressure budget
660 call gaslist_cleanup_list ; make sure there is only one gas being first
661 bsf option_changed ; flag that EEPROM needs to be updated
662 btfss copying_dil ; are we copying a diluent?
663 return ; NO - done
664 bsf is_diluent_menu ; YES - restore to be setting up diluents
665 movlw .5 ; - offset between OC gases and diluents
666 addwf gaslist_gas,F ; - let gaslist_gas point to the diluent again
667 WIN_BOX_BLACK .30,.239,.0,.159 ; - create some visual effect to show activity
668 WAITMS .200 ; - pause for 200 ms
669 return ; - done
670
671 ENDIF ; _ccr_pscr
672
673
674 ;-----------------------------------------------------------------------------
675 ; return to Simulator (Deco Calculator) Menu from Sub-Menu
676 ;
677 do_return_menu_simulator:
368 call menu_processor_double_pop ; drop exit line and back to last line 678 call menu_processor_double_pop ; drop exit line and back to last line
369 bra do_planner_common_1 679 bra do_menu_simulator_common_2 ; continue
370 680
371 global do_return_demo_planner 681
372 do_return_demo_planner: 682 ;-----------------------------------------------------------------------------
683 ; return to Simulator (Deco Calculator) Menu from Deco Calculator
684 ;
685 global do_return_menu_simulator_planner
686 do_return_menu_simulator_planner:
373 call menu_processor_pop ; back to last line 687 call menu_processor_pop ; back to last line
374 bra do_planner_common 688 bra do_menu_simulator_common_1 ; continue
375 689
376 do_simulator_menu: 690
691 ;-----------------------------------------------------------------------------
692 ; Simulator (Deco Calculator) Menu
693 ;
694 do_menu_simulator:
377 ; reset planning parameters to default values 695 ; reset planning parameters to default values
378 lfsr FSR0,odiveInterval 696 lfsr FSR0,odiveInterval ; surface interval
379 call option_reset 697 call option_reset ; reset to default
380 lfsr FSR0,obottomTime 698 lfsr FSR0,obottomTime ; bottom time
381 call option_reset 699 call option_reset ; reset to default
382 lfsr FSR0,obottomDepth 700 lfsr FSR0,obottomDepth ; bottom depth
383 call option_reset 701 call option_reset ; reset to default
384 lfsr FSR0,oSimAGF 702 lfsr FSR0,oSimAGF ; GF/aGF
385 call option_reset 703 call option_reset ; reset to default
386 704
387 IFDEF _gas_contingency 705 IFDEF _gas_contingency
388 ; switch off gas contingency mode by default when entering the simulator menu 706 lfsr FSR0,oGasContingencySim ; gas contingency
389 clrf WREG 707 call option_reset ; reset to default (volatile option)
390 movff WREG,opt_gas_contingency_sim 708 ENDIF ; _gas_contingency
391 ENDIF 709
392 710 do_menu_simulator_common_1:
393 do_planner_common:
394 call restart_set_modes_and_flags ; initialize dive mode settings 711 call restart_set_modes_and_flags ; initialize dive mode settings
395 do_planner_common_1: 712
713 do_menu_simulator_common_2:
714
715 IFDEF _ccr_pscr
716
396 movff opt_dive_mode,WREG ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR 717 movff opt_dive_mode,WREG ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
397 dcfsnz WREG,W ; subtract one, became zero? 718 decfsz WREG,W ; subtract one, became zero?
398 bra do_planner_common_ccr ; YES - use CCR version 719 bra do_menu_simulator_common_oc ; NO - use OC version
399 720 ;bra do_menu_simulator_common_ccr; YES - use CCR version
721
722 do_menu_simulator_common_ccr:
400 MENU_BEGIN tSimulator, .7 723 MENU_BEGIN tSimulator, .7
401 MENU_OPTION tIntvl, odiveInterval, 0 724 MENU_OPT_INC tIntvl, odiveInterval
402 MENU_OPTION tBtDep, obottomDepth, 0 725 MENU_OPT_INC tBtDep, obottomDepth
403 MENU_CALL tInter, do_demo_divemode 726 MENU_CALL tInter, do_demo_divemode
404 MENU_OPTION tBtTm, obottomTime, 0 727 MENU_OPT_INC tBtTm, obottomTime
405 MENU_OPTION tuseAGF, oSimAGF, 0 728 MENU_CALL tCalculatorSetup, do_menu_simulator_more
406 MENU_CALL tDeco, do_demo_planner 729 MENU_CALL tDeco, do_demo_planner
407 MENU_CALL tBack, do_return_main_menu 730 MENU_CALL tBack, do_return_main_menu
408 MENU_END 731 MENU_END
409 732
410 do_planner_common_ccr: 733 ENDIF ; _ccr_pscr
734
735 do_menu_simulator_common_oc:
411 MENU_BEGIN tSimulator, .7 736 MENU_BEGIN tSimulator, .7
412 MENU_OPTION tIntvl, odiveInterval, 0 737 MENU_OPT_INC tIntvl, odiveInterval
413 MENU_OPTION tBtDep, obottomDepth, 0 738 MENU_OPT_INC tBtDep, obottomDepth
414 MENU_CALL tInter, do_demo_divemode 739 MENU_CALL tInter, do_demo_divemode
415 MENU_OPTION tBtTm, obottomTime, 0 740 MENU_OPT_INC tBtTm, obottomTime
416 MENU_CALL tCalculatorSetup, do_planner_config 741 MENU_OPT_INC tuseAGF, oSimAGF
417 MENU_CALL tDeco, do_demo_planner 742 MENU_CALL tDeco, do_demo_planner
418 MENU_CALL tBack, do_return_main_menu 743 MENU_CALL tBack, do_return_main_menu
419 MENU_END 744 MENU_END
420 745
421 do_planner_config: 746
747 ;-----------------------------------------------------------------------------
748 ; Call Function - start Simulator Mode
749 ;
750 do_demo_divemode:
751 goto demo_divemode ; code is hosted in divemode.asm
752
753
754 ;-----------------------------------------------------------------------------
755 ; Call Function - start Deco Calculator
756 ;
757 do_demo_planner:
758 goto demo_planner ; code is hosted in simulator.asm
759
760
761 ;-----------------------------------------------------------------------------
762 ; Simulator (Deco Calculator) Menu - 2nd Layer
763 ;
764 do_menu_simulator_more:
422 IFDEF _gas_contingency 765 IFDEF _gas_contingency
423 MENU_BEGIN tSimulator, .4 766 MENU_BEGIN tSimulator, .4
424 MENU_OPTION tSelectSetpoint, oSimSetpoint, 0 767 MENU_OPT_INC tSelectSetpoint, oSimSetpoint
425 MENU_OPTION tuseAGF, oSimAGF, 0 768 MENU_OPT_INC tuseAGF, oSimAGF
426 MENU_OPTION tGasContingencySim, oGasContingencySim, 0 769 MENU_OPT_INC tGasContingencySim, oGasContingencySim
427 MENU_CALL tBack, do_return_planner_menu 770 MENU_CALL tBack, do_return_menu_simulator
428 MENU_END 771 MENU_END
429 ELSE 772 ELSE
430 MENU_BEGIN tSimulator, .3 773 MENU_BEGIN tSimulator, .3
431 MENU_OPTION tSelectSetpoint, oSimSetpoint, 0 774 MENU_OPT_INC tSelectSetpoint, oSimSetpoint
432 MENU_OPTION tuseAGF, oSimAGF, 0 775 MENU_OPT_INC tuseAGF, oSimAGF
433 MENU_CALL tBack, do_return_planner_menu 776 MENU_CALL tBack, do_return_menu_simulator
434 MENU_END 777 MENU_END
435 ENDIF 778 ENDIF ; _gas_contingency
436 779
437 780
438 ;============================================================================= 781 ;-----------------------------------------------------------------------------
439 ; Divemode Menu 782 ; return to Dive Settings Menu from Sub-Menu
440 783 ;
441 do_return_divemode_menu: 784 do_return_menu_dive:
442 call menu_processor_double_pop ; drop exit line and back to last line 785 call menu_processor_double_pop ; drop exit line and back to last line
443 786 ;bra do_menu_dive ; continue
444 do_divemode_menu: 787
788 ;-----------------------------------------------------------------------------
789 ; Dive Settings Menu - 1st Layer
790 ;
791 do_menu_dive:
445 MENU_BEGIN tDiveModeMenu, .6 792 MENU_BEGIN tDiveModeMenu, .6
446 MENU_CALL tDiveSetup, do_dive_menu ; dive setup 793 MENU_CALL tDiveSetup, do_menu_dive_dive ; dive setup
447 MENU_CALL tDecoSetup, do_deco_menu ; deco setup 794 MENU_CALL tDecoSetup, do_menu_dive_deco ; deco setup
448 MENU_CALL tSACSetup, do_SAC_menu ; SAC setup 795 MENU_CALL tSACSetup, do_menu_dive_SAC ; SAC setup
449 MENU_CALL tppO2Setup, do_ppo2_menu ; ppO2 limits 796 MENU_CALL tppO2Setup, do_menu_dive_ppO2 ; ppO2 limits
450 MENU_CALL tStopsSetup, do_stops_menu ; stops setup 797 MENU_CALL tStopsSetup, do_menu_dive_stops ; stops setup
451 MENU_CALL tBack, do_return_main_menu 798 MENU_CALL tBack, do_return_main_menu
452 MENU_END 799 MENU_END
453 800
454 801 ;-----------------------------------------------------------------------------
455 do_dive_menu: 802 ; Dive Settings Menu - 2nd Layer - Dive Mode
803 ;
804 do_menu_dive_dive:
456 IFDEF _cave_mode 805 IFDEF _cave_mode
457 MENU_BEGIN tDiveModeMenu, .6 806 MENU_BEGIN tDiveModeMenu, .6
458 MENU_OPTION tDvMode, oDiveMode, 0 ; dive mode 807 MENU_OPT_INC tDvMode, oDiveMode ; dive mode
459 MENU_OPTION tCvMode, oCaveMode, 0 ; cave mode 808 MENU_OPT_INC tCvMode, oCaveMode ; cave mode
460 MENU_OPTION tFTTSMenu, oExtraTime, 0 ; fTTS/delay 809 MENU_OPT_INC tFTTSMenu, oExtraTime ; fTTS/delay
461 MENU_OPTION tTimeoutDive, oDiveTimeout, 0 ; dive timeout 810 MENU_OPT_INC tTimeoutDive, oDiveTimeout ; dive timeout
462 MENU_OPTION tStoreApnoeDive, oStoreApnoe, 0 ; store apnoe 811 MENU_OPT_INC tStoreApnoeDive, oStoreApnoe ; store apnoe
463 MENU_CALL tBack, do_return_divemode_menu 812 MENU_CALL tBack, do_return_menu_dive
464 MENU_END 813 MENU_END
465 ELSE 814 ELSE
466 MENU_BEGIN tDiveModeMenu, .5 815 MENU_BEGIN tDiveModeMenu, .5
467 MENU_OPTION tDvMode, oDiveMode, 0 ; dive mode 816 MENU_OPT_INC tDvMode, oDiveMode ; dive mode
468 MENU_OPTION tFTTSMenu, oExtraTime, 0 ; fTTS/delay 817 MENU_OPT_INC tFTTSMenu, oExtraTime ; fTTS/delay
469 MENU_OPTION tTimeoutDive, oDiveTimeout, 0 ; dive timeout 818 MENU_OPT_INC tTimeoutDive, oDiveTimeout ; dive timeout
470 MENU_OPTION tStoreApnoeDive, oStoreApnoe, 0 ; store apnoe 819 MENU_OPT_INC tStoreApnoeDive, oStoreApnoe ; store apnoe
471 MENU_CALL tBack, do_return_divemode_menu 820 MENU_CALL tBack, do_return_menu_dive
472 MENU_END 821 MENU_END
473 ENDIF 822 ENDIF
474 823
475 824
476 do_return_deco_menu: 825 ;-----------------------------------------------------------------------------
826 ; return to Dive Settings Menu from Sub-Menu
827 ;
828 do_return_menu_dive_deco:
477 call menu_processor_double_pop ; drop exit line and back to last line 829 call menu_processor_double_pop ; drop exit line and back to last line
478 830 ;bra do_menu_dive_deco ; continue
479 do_deco_menu: 831
832
833 ;-----------------------------------------------------------------------------
834 ; Dive Settings Menu - 2nd Layer - Deco Mode
835 ;
836 do_menu_dive_deco:
480 MENU_BEGIN tDecoSetup, .6 837 MENU_BEGIN tDecoSetup, .6
481 MENU_OPTION tDkMode, oDecoMode, 0 ; ZH-L16 /GF 838 MENU_OPT_INC tDkMode, oDecoMode ; ZH-L16 /GF
482 MENU_OPTION tSaturationMult, osatmultgf, 0 ; saturation 839 MENU_OPT_INC tSaturationMult, osatmultgf ; saturation
483 MENU_OPTION tDesaturationMult, odesatmultgf, 0 ; desaturation 840 MENU_OPT_INC tDesaturationMult, odesatmultgf ; desaturation
484 MENU_OPTION tAltMode, oAltMode, 0 ; altitude mode 841 MENU_OPT_INC tAltMode, oAltMode ; altitude mode
485 MENU_CALL tGFMenu, do_GF_menu ; GF settings 842 MENU_CALL tGFMenu, do_menu_dive_deco_GF ; GF settings
486 MENU_CALL tBack, do_return_divemode_menu 843 MENU_CALL tBack, do_return_menu_dive
487 MENU_END 844 MENU_END
488 845
489 846
490 do_SAC_menu: 847 ;-----------------------------------------------------------------------------
848 ; Dive Settings Menu - 3nd Layer - Deco Mode - GF Settings
849 ;
850 do_menu_dive_deco_GF:
851 MENU_BEGIN tGFMenu, .6
852 MENU_OPT_INC tGF_low, oGF_low ; GF low
853 MENU_OPT_INC tGF_high, oGF_high ; GF high
854 MENU_OPT_INC taGFenable, oEnable_aGF ; aGF selectable
855 MENU_OPT_INC taGF_low, oaGF_low ; aGF low
856 MENU_OPT_INC taGF_high, oaGF_high ; aGF high
857 MENU_CALL tBack, do_return_menu_dive_deco
858 MENU_END
859
860
861 ;-----------------------------------------------------------------------------
862 ; Dive Settings Menu - 2nd Layer - SAC Setup
863 ;
864 do_menu_dive_SAC:
491 IFDEF _gas_contingency 865 IFDEF _gas_contingency
492 MENU_BEGIN tSACSetup, .6 866 MENU_BEGIN tSACSetup, .6
493 MENU_OPTION tCalcGasNeeds, oCalcAscGas, 0 ; calc.gas 867 MENU_OPT_INC tCalcGasNeeds, oCalcAscGas ; calc.gas
494 MENU_OPTION tGasContingencyDive, oGasContingencyDive, 0 ; switch tank if used up 868 MENU_OPT_INC tGasContingencyDive, oGasContingencyDive ; switch tank if used up
495 MENU_OPTION tGasChangeTime, oGasChangeTime, 0 ; gas change time 869 MENU_OPT_INC tGasChangeTime, oGasChangeTime ; gas change time
496 MENU_OPTION tSetWorkSAC, oWork_SAC, 0 ; work SAC 870 MENU_OPT_INC tSetWorkSAC, oWork_SAC ; work SAC
497 MENU_OPTION tSetDecoSAC, oDeco_SAC, 0 ; deco SAC 871 MENU_OPT_INC tSetDecoSAC, oDeco_SAC ; deco SAC
498 MENU_CALL tBack, do_return_divemode_menu 872 MENU_CALL tBack, do_return_menu_dive
499 MENU_END 873 MENU_END
500 ELSE 874 ELSE
501 MENU_BEGIN tSACSetup, .5 875 MENU_BEGIN tSACSetup, .5
502 MENU_OPTION tCalcGasNeeds, oCalcAscGas, 0 ; calc.gas 876 MENU_OPT_INC tCalcGasNeeds, oCalcAscGas ; calc.gas
503 MENU_OPTION tGasChangeTime, oGasChangeTime, 0 ; gas change time 877 MENU_OPT_INC tGasChangeTime, oGasChangeTime ; gas change time
504 MENU_OPTION tSetWorkSAC, oWork_SAC, 0 ; work SAC 878 MENU_OPT_INC tSetWorkSAC, oWork_SAC ; work SAC
505 MENU_OPTION tSetDecoSAC, oDeco_SAC, 0 ; deco SAC 879 MENU_OPT_INC tSetDecoSAC, oDeco_SAC ; deco SAC
506 MENU_CALL tBack, do_return_divemode_menu 880 MENU_CALL tBack, do_return_menu_dive
507 MENU_END 881 MENU_END
508 ENDIF 882 ENDIF
509 883
510 884
511 do_ppo2_menu: 885 ;-----------------------------------------------------------------------------
886 ; Dive Settings Menu - 2nd Layer - ppO2 Setup
887 ;
888 do_menu_dive_ppO2:
512 IFDEF _ccr_pscr 889 IFDEF _ccr_pscr
513 IFDEF _helium 890 IFDEF _helium
514 MENU_BEGIN tppO2Setup, .6 891 MENU_BEGIN tppO2Setup, .6
515 MENU_DYNAMIC divesets_ppo2_max, do_toggle_ppo2_max_work ; max work 892 MENU_DYNAMIC dyn_ppo2_max, do_toggle_ppO2_max_work ; max work
516 MENU_DYNAMIC divesets_ppo2_max_deco, do_toggle_ppo2_max_deco ; max deco 893 MENU_DYNAMIC dyn_ppo2_max_deco, do_toggle_ppO2_max_deco ; max deco
517 MENU_DYNAMIC divesets_ppo2_min, do_toggle_ppo2_min ; min OC 894 MENU_DYNAMIC dyn_ppo2_min, do_toggle_ppO2_min ; min OC
518 MENU_DYNAMIC divesets_ppo2_min_cc, do_toggle_ppo2_min_cc ; min loop 895 MENU_DYNAMIC dyn_ppo2_min_cc, do_toggle_ppO2_min_cc ; min loop
519 MENU_OPTION tIBCDwarning, oEnable_IBCD, 0 ; IBCD warning 896 MENU_OPT_INC tIBCDwarning, oEnable_IBCD ; IBCD warning
520 MENU_CALL tBack, do_return_divemode_menu 897 MENU_CALL tBack, do_return_menu_dive
521 MENU_END 898 MENU_END
522 ELSE 899 ELSE
523 MENU_BEGIN tppO2Setup, .5 900 MENU_BEGIN tppO2Setup, .5
524 MENU_DYNAMIC divesets_ppo2_max, do_toggle_ppo2_max_work ; max work 901 MENU_DYNAMIC dyn_ppo2_max, do_toggle_ppO2_max_work ; max work
525 MENU_DYNAMIC divesets_ppo2_max_deco, do_toggle_ppo2_max_deco ; max deco 902 MENU_DYNAMIC dyn_ppo2_max_deco, do_toggle_ppO2_max_deco ; max deco
526 MENU_DYNAMIC divesets_ppo2_min, do_toggle_ppo2_min ; min OC 903 MENU_DYNAMIC dyn_ppo2_min, do_toggle_ppO2_min ; min OC
527 MENU_DYNAMIC divesets_ppo2_min_cc, do_toggle_ppo2_min_cc ; min loop 904 MENU_DYNAMIC dyn_ppo2_min_cc, do_toggle_ppO2_min_cc ; min loop
528 MENU_CALL tBack, do_return_divemode_menu 905 MENU_CALL tBack, do_return_menu_dive
529 MENU_END 906 MENU_END
530 ENDIF ; _helium 907 ENDIF ; _helium
531 ELSE 908 ELSE
532 IFDEF _helium 909 IFDEF _helium
533 MENU_BEGIN tppO2Setup, .5 910 MENU_BEGIN tppO2Setup, .5
534 MENU_DYNAMIC divesets_ppo2_max, do_toggle_ppo2_max_work ; max work 911 MENU_DYNAMIC dyn_ppo2_max, do_toggle_ppO2_max_work ; max work
535 MENU_DYNAMIC divesets_ppo2_max_deco, do_toggle_ppo2_max_deco ; max deco 912 MENU_DYNAMIC dyn_ppo2_max_deco, do_toggle_ppO2_max_deco ; max deco
536 MENU_DYNAMIC divesets_ppo2_min, do_toggle_ppo2_min ; min OC 913 MENU_DYNAMIC dyn_ppo2_min, do_toggle_ppO2_min ; min OC
537 MENU_OPTION tIBCDwarning, oEnable_IBCD, 0 ; IBCD warning 914 MENU_OPT_INC tIBCDwarning, oEnable_IBCD ; IBCD warning
538 MENU_CALL tBack, do_return_divemode_menu 915 MENU_CALL tBack, do_return_menu_dive
539 ELSE 916 ELSE
540 MENU_BEGIN tppO2Setup, .4 917 MENU_BEGIN tppO2Setup, .4
541 MENU_DYNAMIC divesets_ppo2_max, do_toggle_ppo2_max_work ; max work 918 MENU_DYNAMIC dyn_ppo2_max, do_toggle_ppO2_max_work ; max work
542 MENU_DYNAMIC divesets_ppo2_max_deco, do_toggle_ppo2_max_deco ; max deco 919 MENU_DYNAMIC dyn_ppo2_max_deco, do_toggle_ppO2_max_deco ; max deco
543 MENU_DYNAMIC divesets_ppo2_min, do_toggle_ppo2_min ; min OC 920 MENU_DYNAMIC dyn_ppo2_min, do_toggle_ppO2_min ; min OC
544 MENU_CALL tBack, do_return_divemode_menu 921 MENU_CALL tBack, do_return_menu_dive
545 MENU_END 922 MENU_END
546 ENDIF ; _helium 923 ENDIF ; _helium
547 ENDIF ; _ccr_pscr 924 ENDIF ; _ccr_pscr
548 925
549 926
550 do_stops_menu: 927 ;-----------------------------------------------------------------------------
928 ; dynamic Title - show maximum ppO2 - Work
929 ;
930 dyn_ppo2_max:
931 STRCAT_TEXT tPPO2Max ; print text
932 movff char_I_ppO2_max_work,lo ; get value
933 movlw ppo2_warning_high_default ; load default
934 bra dyn_ppo2_common ; continue with common part
935
936
937 ;-----------------------------------------------------------------------------
938 ; dynamic Title - show maximum ppO2 - Deco
939 ;
940 dyn_ppo2_max_deco:
941 STRCAT_TEXT tPPO2DECO ; print text
942 movff char_I_ppO2_max_deco,lo ; get value
943 movlw ppo2_warning_deco_default ; load default
944 bra dyn_ppo2_common ; continue with common part
945
946
947 ;-----------------------------------------------------------------------------
948 ; dynamic Title - show minimum ppO2
949 ;
950 dyn_ppo2_min:
951 STRCAT_TEXT tPPO2MIN ; print text
952 movff char_I_ppO2_min,lo ; get value
953 movlw ppo2_warning_low_default ; load default
954 bra dyn_ppo2_common ; continue with common part
955
956
957 IFDEF _ccr_pscr
958
959 ;-----------------------------------------------------------------------------
960 ; dynamic Title - show minimum ppO2 - Loop Modes
961 ;
962 dyn_ppo2_min_cc:
963 STRCAT_TEXT tPPO2MINCC ; print text
964 movff char_I_ppO2_min_loop,lo ; get value
965 movlw ppo2_warning_loop_default ; load default
966 ;bra dyn_ppo2_common ; continue with common part
967
968 ENDIF
969
970
971 ;-----------------------------------------------------------------------------
972 ; Helper Function to all show ppO2 dynamic Titles
973 ;
974 dyn_ppo2_common:
975 movwf up ; copy default to up
976 clrf hi ; clear hi
977 bsf leftbind ; print left-aligned
978 bsf decimal_digit2 ; place a decimal point in front of digit 2
979 output_256 ; print ppO2 as x.xx
980 STRCAT_TEXT tbar ; append unit
981 movf up,W ; get default value into WREG
982 cpfseq lo ; current value = default value ?
983 bra divesets_ppo2_common2 ; NO - add an "*"
984 return ; YES - done
985 divesets_ppo2_common2:
986 PUTC "*" ; append a star
987 return ; done
988
989
990 ;-----------------------------------------------------------------------------
991 ; Call Function - increment maximum ppO2 - Work
992 ;
993 do_toggle_ppO2_max_work: ; add 0.1 bar
994 movff char_I_ppO2_max_work,lo ; bank-safe copy
995 movlw .10
996 addwf lo,F
997 movlw ppo2_warning_high_highest
998 cpfsgt lo
999 bra do_toggle_ppo2_max2
1000 movlw ppo2_warning_high_lowest
1001 movwf lo
1002 do_toggle_ppo2_max2:
1003 movff lo,char_I_ppO2_max_work
1004 return
1005
1006
1007 ;-----------------------------------------------------------------------------
1008 ; Call Function - increment maximum ppO2 - Deco
1009 ;
1010 do_toggle_ppO2_max_deco: ; add 0.1 bar
1011 movff char_I_ppO2_max_deco,lo ; bank-safe copy
1012 movlw .10
1013 addwf lo,F
1014 movlw ppo2_warning_deco_highest
1015 cpfsgt lo
1016 bra do_toggle_ppO2_max_deco2
1017 movlw ppo2_warning_deco_lowest
1018 movwf lo
1019 do_toggle_ppO2_max_deco2:
1020 movff lo,char_I_ppO2_max_deco
1021 return
1022
1023
1024 ;-----------------------------------------------------------------------------
1025 ; Call Function - increment minimum ppO2
1026 ;
1027 do_toggle_ppO2_min: ; sub 0.1 bar
1028 movff char_I_ppO2_min,lo ; bank-safe copy
1029 incf lo,F
1030 movlw ppo2_warning_low_highest
1031 cpfsgt lo
1032 bra do_toggle_ppO2_min2
1033 movlw ppo2_warning_low_lowest
1034 movwf lo
1035 do_toggle_ppO2_min2:
1036 movff lo,char_I_ppO2_min
1037 return
1038
1039
1040 ;-----------------------------------------------------------------------------
1041 ; Call Function - increment minimum ppO2 - Loop Modes
1042 ;
1043 do_toggle_ppO2_min_cc: ; sub 0.1 bar
1044 movff char_I_ppO2_min_loop,lo ; bank-safe copy
1045 incf lo,F
1046 movlw ppo2_warning_loop_highest
1047 cpfsgt lo
1048 bra do_toggle_ppO2_min_cc2
1049 movlw ppo2_warning_loop_lowest
1050 movwf lo
1051 do_toggle_ppO2_min_cc2:
1052 movff lo,char_I_ppO2_min_loop
1053 return
1054
1055
1056 ;-----------------------------------------------------------------------------
1057 ; Dive Settings Menu - 2nd Layer - Stops & Depth
1058 ;
1059 do_menu_dive_stops:
551 MENU_BEGIN tStopsSetup, .6 1060 MENU_BEGIN tStopsSetup, .6
552 MENU_OPTION tSafetyStop, oSafetyStop, 0 ; safety stop 1061 MENU_OPT_INC tSafetyStop, oSafetyStop ; safety stop
553 MENU_OPTION tExtendedStops, oExtendedStops, 0 ; extended stops 1062 MENU_OPT_INC tExtendedStops, oExtendedStops ; extended stops
554 MENU_OPTION tLastDecostop, oLastDeco, 0 ; last deco stop 1063 MENU_OPT_INC tLastDecostop, oLastDeco ; last deco stop
555 MENU_OPTION tDvSalinity, oDiveSalinity, 0 ; salinity 1064 MENU_OPT_INC tDvSalinity, oDiveSalinity ; salinity
556 MENU_OPTION tDepthWarn, oMaxDepth, 0 ; depth limit 1065 MENU_OPT_INC tDepthWarn, oMaxDepth ; depth limit
557 MENU_CALL tBack, do_return_divemode_menu 1066 MENU_CALL tBack, do_return_menu_dive
558 MENU_END 1067 MENU_END
559 1068
560 1069
561 do_GF_menu: 1070 ;-----------------------------------------------------------------------------
562 MENU_BEGIN tGFMenu, .6 1071 ; return to Settings Menu from Sub-Sub-Menu
563 MENU_OPTION tGF_low, oGF_low, 0 ; GF low 1072 ;
564 MENU_OPTION tGF_high, oGF_high, 0 ; GF high 1073 do_return_menu_settings_deeper: ; entry point for return from info menu 2
565 MENU_OPTION taGFenable, oEnable_aGF, 0 ; aGF selectable
566 MENU_OPTION taGF_low, oaGF_low, 0 ; aGF low
567 MENU_OPTION taGF_high, oaGF_high, 0 ; aGF high
568 MENU_CALL tBack, do_return_deco_menu
569 MENU_END
570
571
572 ;=============================================================================
573 ; Setup Menu
574 do_return_settings_deeper: ; entry point for return from info menu 2
575 call menu_processor_pop ; drop one more stack entry 1074 call menu_processor_pop ; drop one more stack entry
576 1075 ;bra do_return_menu_settings ; continue
577 do_return_settings: 1076
1077
1078 ;-----------------------------------------------------------------------------
1079 ; return to Settings Menu from Sub-Menu
1080 ;
1081 do_return_menu_settings:
578 bcf imprint_time_date ; stop imprinting of current time & date 1082 bcf imprint_time_date ; stop imprinting of current time & date
579 call menu_processor_double_pop ; drop exit line and back to last line 1083 call menu_processor_double_pop ; drop exit line and back to last line
580 1084
581 IFDEF _rx_mode 1085 IFDEF _rx_mode
582 bcf tr_functions_activated ; set TR functions as deactivated by default 1086 bcf tr_functions_activated ; set TR functions as deactivated by default
583 btfss ostc_rx_present ; TR model / TR module up & running? 1087 btfss ostc_rx_present ; TR model / TR module up & running?
584 bra do_settings_menu ; NO - use version w/o TR 1088 bra do_menu_settings ; NO - keep deactivated
585 movff opt_TR_mode,WREG ; YES - get TR mode 1089 movff opt_TR_mode,WREG ; YES - get TR mode
586 tstfsz WREG ; - TR mode <> off ? 1090 tstfsz WREG ; - TR mode <> off ?
587 bsf tr_functions_activated ; YES - set TR functions as activated 1091 bsf tr_functions_activated ; YES - set TR functions as activated
588 ENDIF 1092 ENDIF
589 1093
590 do_settings_menu: 1094
1095 ;-----------------------------------------------------------------------------
1096 ; Settings Menu - 1st Layer
1097 ;
1098 do_menu_settings:
591 IFDEF _hwos_sport 1099 IFDEF _hwos_sport
592 bsf ble_available ; for very old OSTC sport 1100 bsf ble_available ; required for very old OSTC sport
593 ENDIF 1101 ENDIF
594 btfsc ble_available ; BLE available? 1102 btfsc ble_available ; BT available?
595 bra do_settings_menu_ble ; YES 1103 bra do_menu_settings_bt ; YES - do BT menu
596 1104
597 MENU_BEGIN tSystSets, .5 1105 MENU_BEGIN tSystSets, .5
598 MENU_CALL tInfoMenu, do_info_menu 1106 MENU_CALL tInfoMenu, do_menu_info
599 MENU_CALL tSetTimeDate, do_date_time_menu 1107 MENU_CALL tSetTimeDate, do_menu_date_time
600 MENU_CALL tDispSets, do_dispsets_menu 1108 MENU_CALL tDispSets, do_menu_dispsets
601 MENU_CALL tSysSets, do_syssets_menu 1109 MENU_CALL tSysSets, do_menu_syssets
602 MENU_CALL tBack, do_return_main_menu 1110 MENU_CALL tBack, do_return_main_menu
603 MENU_END 1111 MENU_END
604 1112
605 1113 do_menu_settings_bt:
606 do_settings_menu_ble:
607 IFDEF _rx_functions 1114 IFDEF _rx_functions
608 btfss ostc_rx_present ; TR model and TR activated? 1115 btfss ostc_rx_present ; TR model and TR activated?
609 bra do_settings_menu_noRX ; NO 1116 bra do_menu_settings_noRX ; NO
610 1117
611 MENU_BEGIN tSystSets, .7 1118 MENU_BEGIN tSystSets, .7
612 MENU_CALL tInfoMenu, do_info_menu 1119 MENU_CALL tInfoMenu, do_menu_info
613 MENU_CALL tBleTitle, comm_mode_ble 1120 MENU_CALL tBleTitle, do_comm_mode_bt
614 MENU_CALL tTrSettings, do_settings_menu_TR 1121 MENU_CALL tTrSettings, do_menu_settings_TR
615 MENU_CALL tSetTimeDate, do_date_time_menu 1122 MENU_CALL tSetTimeDate, do_menu_date_time
616 MENU_CALL tDispSets, do_dispsets_menu 1123 MENU_CALL tDispSets, do_menu_dispsets
617 MENU_CALL tSysSets, do_syssets_menu 1124 MENU_CALL tSysSets, do_menu_syssets
618 MENU_CALL tBack, do_return_main_menu 1125 MENU_CALL tBack, do_return_main_menu
619 MENU_END 1126 MENU_END
620 ENDIF 1127 ENDIF
621 1128
622 do_settings_menu_noRX: 1129 do_menu_settings_noRX:
623 MENU_BEGIN tSystSets, .6 1130 MENU_BEGIN tSystSets, .6
624 MENU_CALL tInfoMenu, do_info_menu 1131 MENU_CALL tInfoMenu, do_menu_info
625 MENU_CALL tBleTitle, comm_mode_ble 1132 MENU_CALL tBleTitle, do_comm_mode_bt
626 MENU_CALL tSetTimeDate, do_date_time_menu 1133 MENU_CALL tSetTimeDate, do_menu_date_time
627 MENU_CALL tDispSets, do_dispsets_menu 1134 MENU_CALL tDispSets, do_menu_dispsets
628 MENU_CALL tSysSets, do_syssets_menu 1135 MENU_CALL tSysSets, do_menu_syssets
629 MENU_CALL tBack, do_return_main_menu 1136 MENU_CALL tBack, do_return_main_menu
630 MENU_END 1137 MENU_END
631 1138
632 1139
633 do_info_menu: 1140 ;-----------------------------------------------------------------------------
1141 ; Call Function - start Communication Mode (BT)
1142 ;
1143 do_comm_mode_bt:
1144 goto comm_mode_bt ; code hosted in comm.asm
1145
1146
1147 ;-----------------------------------------------------------------------------
1148 ; Settings Menu - 2nd Layer - System Infos - Page 1
1149 ;
1150 do_menu_info:
634 IFDEF _rx_functions 1151 IFDEF _rx_functions
635 btfss ostc_rx_present ; TR model? 1152 btfss ostc_rx_present ; TR model?
636 bra do_info_menu_noRX ; NO 1153 bra do_menu_info_noRX ; NO
637 1154
638 MENU_BEGIN tInfoMenu, .7 1155 MENU_BEGIN tInfoMenu, .7
639 MENU_DYNAMIC info_menu_uptime, 0 1156 MENU_DYNAMIC dyn_show_uptime, 0
640 MENU_DYNAMIC info_menu_serial, 0 1157 MENU_DYNAMIC dyn_show_serial, 0
641 MENU_DYNAMIC info_menu_firmware, 0 1158 MENU_DYNAMIC dyn_show_firmware_ostc, 0
642 MENU_DYNAMIC info_menu_fw_cration_date, 0 1159 MENU_DYNAMIC dyn_show_fw_creation_date, 0
643 MENU_DYNAMIC info_menu_firmware_rx, 0 1160 MENU_DYNAMIC dyn_show_firmware_rx, 0
644 MENU_DYNAMIC info_menu_total_dives, 0 1161 MENU_DYNAMIC dyn_show_total_dives, 0
645 MENU_CALL tMore, do_info_menu2 1162 MENU_CALL tMore, do_menu_info2
646 MENU_END 1163 MENU_END
647 ENDIF 1164 ENDIF
648 1165
649 do_info_menu_noRX: 1166 do_menu_info_noRX:
650 MENU_BEGIN tInfoMenu, .6 1167 MENU_BEGIN tInfoMenu, .6
651 MENU_DYNAMIC info_menu_uptime, 0 1168 MENU_DYNAMIC dyn_show_uptime, 0
652 MENU_DYNAMIC info_menu_serial, 0 1169 MENU_DYNAMIC dyn_show_serial, 0
653 MENU_DYNAMIC info_menu_firmware, 0 1170 MENU_DYNAMIC dyn_show_firmware_ostc, 0
654 MENU_DYNAMIC info_menu_fw_cration_date, 0 1171 MENU_DYNAMIC dyn_show_fw_creation_date, 0
655 MENU_DYNAMIC info_menu_total_dives, 0 1172 MENU_DYNAMIC dyn_show_total_dives, 0
656 MENU_CALL tMore, do_info_menu2 1173 MENU_CALL tMore, do_menu_info2
657 MENU_END 1174 MENU_END
658 1175
659 do_info_menu2: 1176
1177 ;-----------------------------------------------------------------------------
1178 ; dynamic Title - show Uptime
1179 ;
1180 dyn_show_uptime:
1181 STRCAT_TEXT tUptime ; print title
1182 SMOVQQ uptime,xC ; ISR-safe copy of uptime:4 to xC:4
1183 goto output_secs_as_days_hours ; print seconds as days and hours and return
1184
1185
1186 ;-----------------------------------------------------------------------------
1187 ; dynamic Title - show Uptime
1188 ;
1189 dyn_show_serial:
1190 STRCAT_TEXT tSerial ; print title
1191 goto TFT_cat_serial ; print serial number and return
1192
1193 ;-----------------------------------------------------------------------------
1194 ; dynamic Title - show Firmware Version
1195 ;
1196 dyn_show_firmware_ostc:
1197 STRCAT_TEXT tFirmware ; print title
1198 call TFT_cat_firmware ; print firmware version
1199 PUTC " " ; print a dot
1200 goto TFT_cat_beta_short ; print beta/release state and return
1201
1202
1203 ;-----------------------------------------------------------------------------
1204 ; dynamic Title - show Firmware creation Date
1205 ;
1206 dyn_show_fw_creation_date:
1207 STRCAT_TEXT tFirmwareDate ; print title
1208 movlw firmware_creation_year ; get firmware creation year
1209 movwf lo ; copy to lo
1210 movlw firmware_creation_month ; get firmware creation month
1211 movwf hi ; copy to hi
1212 movlw firmware_creation_day ; get firmware creation day
1213 movwf up ; copy to up
1214 goto output_date ; print date and return
1215
1216
1217 IFDEF _rx_functions
1218
1219 ;-----------------------------------------------------------------------------
1220 ; dynamic Title - show RX Firmware Version (also used by start.asm)
1221 ;
1222 global dyn_show_firmware_rx
1223 dyn_show_firmware_rx:
1224 STRCAT_TEXT tFirmware_rx ; print title
1225 movff rx_firmware_cur_major,lo ; get major version
1226 bsf leftbind ; print left-aligned
1227 output_99 ; print major (0-99)
1228 PUTC '.' ; print a dot
1229 movff rx_firmware_cur_minor,lo ; get minor
1230 output_99x ; print minor (00-99)
1231 return ; done
1232
1233 ENDIF ; _rx_functions
1234
1235
1236 ;-----------------------------------------------------------------------------
1237 ; dynamic Title - show total Number of Dives
1238 ;
1239 dyn_show_total_dives:
1240 STRCAT_TEXT tTotalDives ; print title
1241 call eeprom_total_dives_read ; read total number of dives
1242 bsf leftbind ; print left-aligned
1243 output_65535 ; print number of total dives (0-65535)
1244 return ; done
1245
1246
1247 ;-----------------------------------------------------------------------------
1248 ; Settings Menu - 2nd Layer - System Infos - Page 2
1249 ;
1250 do_menu_info2:
1251 IFNDEF _comm_debug
660 MENU_BEGIN tInfoMenu, .5 1252 MENU_BEGIN tInfoMenu, .5
661 MENU_DYNAMIC info_menu_battery_volts, 0 1253 MENU_DYNAMIC dyn_show_battery_volts, 0
662 MENU_DYNAMIC info_menu_config, 0 1254 MENU_DYNAMIC dyn_show_config, 0
663 MENU_DYNAMIC info_menu_sensor_calib, 0 1255 MENU_DYNAMIC dyn_show_sensor_calib, 0
664 MENU_DYNAMIC info_menu_sensor_offset, 0 1256 MENU_DYNAMIC dyn_show_sensor_offset, 0
665 MENU_CALL tBack, do_return_settings_deeper 1257 MENU_CALL tBack, do_return_menu_settings_deeper
666 MENU_END 1258 MENU_END
1259 ELSE
1260 MENU_BEGIN tInfoMenu, .6
1261 MENU_DYNAMIC dyn_show_battery_volts, 0
1262 MENU_DYNAMIC dyn_show_config, 0
1263 MENU_DYNAMIC dyn_show_sensor_calib, 0
1264 MENU_DYNAMIC dyn_show_sensor_offset, 0
1265 MENU_OPT_INC tCommTimeout, oCommTimeout
1266 MENU_CALL tBack, do_return_menu_settings_deeper
1267 MENU_END
1268 ENDIF
1269
1270
1271 ;-----------------------------------------------------------------------------
1272 ; dynamic Title - show Battery Volts and Type
1273 ;
1274 dyn_show_battery_volts:
1275 STRCAT_TEXT tBatteryV ; print text
1276 MOVII batt_voltage,mpr ; get battery voltage
1277 bsf decimal_digit3 ; place a decimal point in front of digit 3
1278 bsf omit_digit_1 ; do not print 1st digit
1279 output_9999 ; print as x.yy-
1280 STRCAT " V(T" ; append fix legend
1281 movff battery_type,lo ; =0:1.5V, =1:3.6V Saft, =2:LiIon 3.7V/0.8Ah, =3:LiIon 3.7V/3.1Ah, =4: LiIon 3.7V/2.3Ah
1282 output_9 ; print battery type code (0-9)
1283 PUTC ")" ; append fix legend
1284 return ; done
1285
1286
1287 ;-----------------------------------------------------------------------------
1288 ; dynamic Title - show Hardware / Software Configuration
1289 ;
1290 dyn_show_config:
1291 STRCAT_TEXT tHardware ; print text
1292 call I2C_init_compass ; start compass to get compass configuration
1293 movf HW_descriptor,W ; copy hardware descriptor to WREG
1294 output_hex ; print as hex
1295 movf HW_variants,W ; copy hardware variants to WREG
1296 output_hex ; print as hex
1297 PUTC "-" ; print a separator
1298 movlw FW_CONF ; get firmware configuration
1299 output_hex ; print as hex
1300 call get_cpu_version ; get CPU version
1301 output_hex ; print as hex
1302 return ; done
1303
1304
1305 ;-----------------------------------------------------------------------------
1306 ; dynamic Title - show Pressure Sensor Calibration Data C1 and C5
1307 ;
1308 dyn_show_sensor_calib:
1309 STRCAT_TEXT tSensorC ; print label
1310 movff C1+1,WREG ; get C1, high byte
1311 output_hex ; print C1, high byte
1312 movff C1+0,WREG ; get C1, low byte
1313 output_hex ; print C1, low byte
1314 PUTC "-" ; print a separator
1315 movff C5+1,WREG ; get C5, high byte
1316 output_hex ; print C5, high byte
1317 movff C5+0,WREG ; get C5, low byte
1318 output_hex ; print C5, low byte
1319 return ; done
1320
1321
1322 ;-----------------------------------------------------------------------------
1323 ; dynamic Title - show Pressure Sensor Offset Setting
1324 ;
1325 dyn_show_sensor_offset:
1326 STRCAT_TEXT tSensorD ; print label
1327 movff opt_pressure_adjust,lo ; get pressure sensor offset
1328 movf lo,F ; excite flags
1329 bz dyn_show_sensor_offset_zero ; sensor offset = 0
1330 bn dyn_show_sensor_offset_neg ; sensor offset < 0
1331 ;bnn dyn_show_sensor_offset_pos ; sensor offset > 0
1332 dyn_show_sensor_offset_pos:
1333 PUTC "+" ; print plus sign
1334 bra dyn_show_sensor_offset_com ; continue with common part
1335 dyn_show_sensor_offset_zero:
1336 PUTC " " ; print a space
1337 bra dyn_show_sensor_offset_com ; continue with common part
1338 dyn_show_sensor_offset_neg:
1339 PUTC "-" ; print a minus sign
1340 negf lo ; negate lo
1341 ;bra dyn_show_sensor_offset_com ; continue with common part
1342 dyn_show_sensor_offset_com:
1343 PUTC " " ; print a space
1344 bsf leftbind ; print left-aligned
1345 output_99 ; print value (0-99)
1346 PUTC " " ; print a space
1347 STRCAT_TEXT tMBAR ; print unit
1348 return ; done
667 1349
668 1350
669 IFDEF _rx_functions 1351 IFDEF _rx_functions
670 1352
671 do_settings_menu_TR: 1353 ;-----------------------------------------------------------------------------
1354 ; Settings Menu - 2nd Layer - TR Settings
1355 ;
1356 do_menu_settings_TR:
672 movff opt_dive_mode,WREG ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR 1357 movff opt_dive_mode,WREG ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
673 incf WREG,W ; add 1 1358 incf WREG,W ; add 1
674 dcfsnz WREG,W ; subtract one, became zero? 1359 dcfsnz WREG,W ; subtract one, became zero?
675 bra do_settings_menu_TR_MaxDelta; YES - OC 1360 bra do_menu_settings_TR_MaxDelta; YES - OC
676 dcfsnz WREG,W ; subtract one, became zero? 1361 dcfsnz WREG,W ; subtract one, became zero?
677 bra do_settings_menu_TR_BailPres; YES - CCR 1362 bra do_menu_settings_TR_BailPres; YES - CCR
678 dcfsnz WREG,W ; subtract one, became zero? 1363 dcfsnz WREG,W ; subtract one, became zero?
679 bra do_settings_menu_TR_MaxDelta; YES - Gauge 1364 bra do_menu_settings_TR_MaxDelta; YES - Gauge
680 dcfsnz WREG,W ; subtract one, became zero? 1365 dcfsnz WREG,W ; subtract one, became zero?
681 bra do_settings_menu_TR_abort ; YES - Apnea, abort 1366 bra do_menu_settings_TR_abort ; YES - Apnea, abort
682 dcfsnz WREG,W ; subtract one, became zero? 1367 dcfsnz WREG,W ; subtract one, became zero?
683 bra do_settings_menu_TR_both ; YES - pSCR 1368 bra do_menu_settings_TR_both ; YES - pSCR
684 do_settings_menu_TR_abort: 1369
685 call menu_processor_pop ; drop last menu selection 1370 do_menu_settings_TR_abort:
686 bra do_settings_menu ; back to last menu 1371 call menu_processor_pop ; drop button press
687 1372 bra do_menu_settings ; back to same menu
688 do_settings_menu_TR_MaxDelta: ; menu with oTrMaxDeltaPres 1373
1374
1375 ;-----------------------------------------------------------------------------
1376 ; Settings Menu - 3rd Layer - TR Settings - Sidemount Mode
1377 ;
1378 do_menu_settings_TR_MaxDelta: ; menu with oTrMaxDeltaPres
689 MENU_BEGIN tTrSettings, .5 1379 MENU_BEGIN tTrSettings, .5
690 MENU_OPTION tTrMode, oTrMode, 0 1380 MENU_OPT_INC tTrMode, oTrMode
691 MENU_OPTION tTr1stPres, oTr1stPres, 0 1381 MENU_OPT_INC tTr1stPres, oTr1stPres
692 MENU_OPTION tTr2ndPres, oTr2ndPres, 0 1382 MENU_OPT_INC tTr2ndPres, oTr2ndPres
693 MENU_DYNAMIC do_toggle_max_pres_diff_label,do_toggle_max_pres_diff 1383 MENU_DYNAMIC dyn_toggle_max_pres_diff, do_toggle_max_pres_diff
694 MENU_CALL tBack, do_return_settings 1384 MENU_CALL tBack, do_return_menu_settings
695 MENU_END 1385 MENU_END
696 1386
697 do_settings_menu_TR_BailPres: ; menu with oTrBailPres 1387
1388 ;-----------------------------------------------------------------------------
1389 ; Settings Menu - 3rd Layer - TR Settings - CCR Mode
1390 ;
1391 do_menu_settings_TR_BailPres: ; menu with oTrBailPres
698 MENU_BEGIN tTrSettings, .5 1392 MENU_BEGIN tTrSettings, .5
699 MENU_OPTION tTrMode, oTrMode, 0 1393 MENU_OPT_INC tTrMode, oTrMode
700 MENU_OPTION tTr1stPres, oTr1stPres, 0 1394 MENU_OPT_INC tTr1stPres, oTr1stPres
701 MENU_OPTION tTr2ndPres, oTr2ndPres, 0 1395 MENU_OPT_INC tTr2ndPres, oTr2ndPres
702 MENU_OPTION tTrBailPres, oTrBailPres, 0 1396 MENU_OPT_INC tTrBailPres, oTrBailPres
703 MENU_CALL tBack, do_return_settings 1397 MENU_CALL tBack, do_return_menu_settings
704 MENU_END 1398 MENU_END
705 1399
706 do_settings_menu_TR_both: ; menu with oTrBailPres and oTrMaxDeltaPres 1400
1401 ;-----------------------------------------------------------------------------
1402 ; Settings Menu - 3rd Layer - TR Settings - pSCR Mode
1403 ;
1404 do_menu_settings_TR_both: ; menu with oTrBailPres and oTrMaxDeltaPres
707 MENU_BEGIN tTrSettings, .6 1405 MENU_BEGIN tTrSettings, .6
708 MENU_OPTION tTrMode, oTrMode, 0 1406 MENU_OPT_INC tTrMode, oTrMode
709 MENU_OPTION tTr1stPres, oTr1stPres, 0 1407 MENU_OPT_INC tTr1stPres, oTr1stPres
710 MENU_OPTION tTr2ndPres, oTr2ndPres, 0 1408 MENU_OPT_INC tTr2ndPres, oTr2ndPres
711 MENU_OPTION tTrBailPres, oTrBailPres, 0 1409 MENU_OPT_INC tTrBailPres, oTrBailPres
712 MENU_DYNAMIC do_toggle_max_pres_diff_label,do_toggle_max_pres_diff 1410 MENU_DYNAMIC dyn_toggle_max_pres_diff, do_toggle_max_pres_diff
713 MENU_CALL tBack, do_return_settings 1411 MENU_CALL tBack, do_return_menu_settings
714 MENU_END 1412 MENU_END
715 1413
716 1414
1415 ;-----------------------------------------------------------------------------
1416 ; dynamic Title - max. Delta Pressure for Swap Tanks Advice
1417 ;
1418 dyn_toggle_max_pres_diff:
1419 movff opt_TR_mode,WREG ; get TR mode
1420 xorlw .2 ; compare with 2 (ind.double)
1421 tstfsz WREG ; equal?
1422 FONT_COLOR_DISABLED ; NO - print in disabled color
1423 STRCAT_TEXT tTrMaxDeltaP ; output label
1424 movff char_I_max_pres_diff,lo ; get configured deltaP
1425 output_99 ; print deltaP (0-99)
1426 STRCAT_TEXT tbar ; append " bar"
1427 return ; done
1428
1429
1430 ;-----------------------------------------------------------------------------
1431 ; Call Function - adjust max. Delta Pressure for Swap Tanks Advice
1432 ;
717 do_toggle_max_pres_diff: ; add 5 bar, with hard-coded max. 1433 do_toggle_max_pres_diff: ; add 5 bar, with hard-coded max.
718 movff char_I_max_pres_diff,lo ; get current value 1434 movff char_I_max_pres_diff,lo ; get current value
719 movlw .5 ; load increment 1435 movlw .5 ; load increment
720 addwf lo,F ; add increment 1436 addwf lo,F ; add increment
721 movlw max_pres_diff_max ; load maximum value 1437 movlw max_pres_diff_max ; load maximum value
728 return ; done 1444 return ; done
729 1445
730 ENDIF ; _rx_functions 1446 ENDIF ; _rx_functions
731 1447
732 1448
733 do_return_settings_more_deeper: ; entry point for returns from reset sub-menu 1449 ;-----------------------------------------------------------------------------
1450 ; return to Settings Menu from Sub-Menu
1451 ;
1452 do_return_menu_date_time:
1453 call menu_processor_double_pop ; drop exit line and back to last line
1454
1455
1456 ;-----------------------------------------------------------------------------
1457 ; Settings Menu - 2nd Layer - set Time & Date
1458 ;
1459 do_menu_date_time:
1460 bsf imprint_time_date ; start imprinting current time & date
1461 bcf block_option_value ; resume displaying of option values
1462
1463 MENU_BEGIN tSetTimeDate, .4
1464 MENU_CALL tSetTime, do_menu_set_time
1465 MENU_CALL tSetDate, do_menu_set_date
1466 MENU_OPT_INC tDateFormat, oDateFormat
1467 MENU_CALL tBack, do_return_menu_settings
1468 MENU_END
1469
1470
1471 ;-----------------------------------------------------------------------------
1472 ; Settings Menu - 3rd Layer - set Time & Date - set Time
1473 ;
1474 do_menu_set_time:
1475 bsf block_option_value ; suspend displaying of option values
1476
1477 MENU_BEGIN tSetTime, .4
1478 MENU_OPT_INC tSetHours, oSetHours
1479 MENU_OPT_INC tSetMinutes, oSetMinutes
1480 MENU_OPT_INC tSetSeconds, oClearSeconds
1481 MENU_CALL tBack, do_return_menu_date_time
1482 MENU_END
1483
1484
1485 ;-----------------------------------------------------------------------------
1486 ; Settings Menu - 3rd Layer - set Time & Date - set Date
1487 ;
1488 do_menu_set_date:
1489 bsf block_option_value ; suspend displaying of option values
1490
1491 MENU_BEGIN tSetDate, .4
1492 MENU_OPT_INC tSetDay, oSetDay
1493 MENU_OPT_INC tSetMonth, oSetMonth
1494 MENU_OPT_INC tSetYear, oSetYear
1495 MENU_CALL tBack, do_return_menu_date_time
1496 MENU_END
1497
1498
1499 ;-----------------------------------------------------------------------------
1500 ; return to Display Settings from Sub-Menu
1501 ;
1502 do_return_dispsets_menu:
1503 bcf imprint_color_schemes ; deactivate color schemes demonstration
1504 call menu_processor_double_pop ; drop exit line and back to last line
1505 ;bra do_menu_dispsets ; continue
1506
1507
1508 ;-----------------------------------------------------------------------------
1509 ; Settings Menu - 2nd Layer - Display Settings - Page 1
1510 ;
1511 do_menu_dispsets:
1512 IF _language_2!=none
1513 MENU_BEGIN tDispSets, .7
1514 MENU_OPT_INC tBright, oBrightness
1515 MENU_OPT_INC tLayout, oLayout
1516 MENU_OPT_INC tUnits, oUnits
1517 MENU_OPT_INC tLanguage, oLanguage
1518 MENU_OPT_INC tFlip, oFlipScreen
1519 MENU_CALL tColorScheme, do_menu_color_scheme
1520 MENU_CALL tMore, do_menu_dispsets_more
1521 MENU_END
1522 ELSE
1523 MENU_BEGIN tDispSets, .6
1524 MENU_OPT_INC tBright, oBrightness
1525 MENU_OPT_INC tLayout, oLayout
1526 MENU_OPT_INC tUnits, oUnits
1527 MENU_OPT_INC tFlip, oFlipScreen
1528 MENU_CALL tColorScheme, do_menu_color_scheme
1529 MENU_CALL tMore, do_menu_dispsets_more
1530 MENU_END
1531 ENDIF
1532
1533
1534 ;-----------------------------------------------------------------------------
1535 ; Settings Menu - 3rd Layer - Display Settings - Color Schemes
1536 ;
1537 do_menu_color_scheme:
1538 bsf imprint_color_schemes ; activate color schemes demonstration
1539
1540 ; menu with 4 leading empty menu lines to give space for the color scheme imprinting
1541 MENU_BEGIN_OFFSET tColorScheme, .2, .4
1542 MENU_OPT_INC tColorSetDive, oColorSetDive
1543 MENU_CALL tBack, do_return_dispsets_menu
1544 MENU_END
1545
1546
1547 ;-----------------------------------------------------------------------------
1548 ; Settings Menu - 2nd Layer - Display Settings - Page 2
1549 ;
1550 do_menu_dispsets_more:
1551 IFDEF _helium
1552 MENU_BEGIN tDispSets, .7
1553 MENU_OPT_INC tVSIgraph, oVSIgraph
1554 MENU_OPT_INC tVSItext2, oVSItext
1555 MENU_OPT_INC tShowppO2, oShowppO2
1556 MENU_OPT_INC tDepthWarning, oDepthWarn
1557 MENU_OPT_INC t2ndDepth, o2ndDepthDisp
1558 MENU_OPT_INC tTissueGraphics, oTissueGraphics
1559 MENU_CALL tBack, do_return_menu_settings_deeper
1560 MENU_END
1561 ELSE
1562 MENU_BEGIN tDispSets, .6
1563 MENU_OPT_INC tVSIgraph, oVSIgraph
1564 MENU_OPT_INC tVSItext2, oVSItext
1565 MENU_OPT_INC tShowppO2, oShowppO2
1566 MENU_OPT_INC tDepthWarning, oDepthWarn
1567 MENU_OPT_INC t2ndDepth, o2ndDepthDisp
1568 MENU_CALL tBack, do_return_menu_settings_deeper
1569 MENU_END
1570 ENDIF
1571
1572
1573 ;-----------------------------------------------------------------------------
1574 ; return to System Settings Menu from Sub-Sub-Menu
1575 ;
1576 do_return_menu_syssets_more_more: ; entry point for returns from reset sub-menu
734 call menu_processor_pop ; drop one more stack entry 1577 call menu_processor_pop ; drop one more stack entry
735 1578 ;bra do_return_menu_syssets_more ; continue
736 do_return_settings_more: 1579
1580
1581 ;-----------------------------------------------------------------------------
1582 ; return to System Settings Menu from Sub-Menu
1583 ;
1584 do_return_menu_syssets_more:
737 call menu_processor_double_pop ; drop exit line and back to last line 1585 call menu_processor_double_pop ; drop exit line and back to last line
738 1586 bra do_menu_syssets ; continue
739 do_syssets_menu: 1587
1588
1589 ;-----------------------------------------------------------------------------
1590 ; return to System Settings Menu from Piezo-Sub-Menu
1591 ;
1592 do_return_menu_syssets_piezo:
1593 call menu_processor_double_pop ; drop exit line and back to last line
1594 call TFT_ClearScreen ; clear the screen
1595 call piezo_config ; configure buttons
1596 ;bra do_menu_syssets ; continue
1597
1598
1599 ;-----------------------------------------------------------------------------
1600 ; Settings Menu - 2nd Layer - System Settings
1601 ;
1602 do_menu_syssets:
740 btfsc battery_gauge_available ; piezo buttons available? 1603 btfsc battery_gauge_available ; piezo buttons available?
741 bra do_syssets_menu_piezo ; YES 1604 bra do_menu_syssets_piezo ; YES
742 1605
743 IFDEF _compass 1606 IFDEF _compass
744 MENU_BEGIN tSystSets, .4 ; All MENU_CALLs in this menu 1607 MENU_BEGIN tSystSets, .4 ; All MENU_CALLs in this menu
745 MENU_CALL tCompassMenu, do_compass_menu ; need to stay together on this 1608 MENU_CALL tCompassMenu, do_menu_compass ; need to stay together on this
746 MENU_CALL tLogOffset, do_log_offset_menu ; menu level in order to not 1609 MENU_CALL tLogOffset, do_menu_log_offset ; menu level in order to not
747 MENU_CALL tResetMenu, do_reset_menu ; mess up the menu stack on doing 1610 MENU_CALL tResetMenu, do_menu_reset ; mess up the menu stack on doing
748 MENU_CALL tBack, do_return_settings ; the do_return_settings ! 1611 MENU_CALL tBack, do_return_menu_settings ; the do_return_menu_settings !
749 MENU_END 1612 MENU_END
750 ELSE 1613 ELSE
751 MENU_BEGIN tSystSets, .3 ; see above 1614 MENU_BEGIN tSystSets, .3 ; see above
752 MENU_CALL tLogOffset, do_log_offset_menu ; 1615 MENU_CALL tLogOffset, do_menu_log_offset ;
753 MENU_CALL tResetMenu, do_reset_menu ; 1616 MENU_CALL tResetMenu, do_menu_reset ;
754 MENU_CALL tBack, do_return_settings ; 1617 MENU_CALL tBack, do_return_menu_settings ;
755 MENU_END 1618 MENU_END
756 ENDIF ; _compass 1619 ENDIF ; _compass
757 1620
758 1621 do_menu_syssets_piezo:
759 do_return_syssets_menu_piezo:
760 call TFT_ClearScreen
761 call piezo_config ; configure buttons
762 call menu_processor_double_pop ; drop exit line and back to last line
763
764 do_syssets_menu_piezo:
765 IFDEF _compass 1622 IFDEF _compass
766 MENU_BEGIN tSystSets, .6 1623 MENU_BEGIN tSystSets, .5
767 MENU_CALL tCompassMenu, do_compass_menu ; see above 1624 MENU_CALL tCompassMenu, do_menu_compass ; see above
768 MENU_CALL tLogOffset, do_log_offset_menu ; 1625 MENU_CALL tLogOffset, do_menu_log_offset ;
769 MENU_DYNAMIC info_menu_total_dives, 0 1626 MENU_CALL tResetMenu, do_menu_reset ;
770 MENU_CALL tResetMenu, do_reset_menu ; 1627 MENU_CALL tPiezo, do_menu_piezo ;
771 MENU_CALL tPiezo, do_settings_piezo_menu ; 1628 MENU_CALL tBack, do_return_menu_settings ;
772 MENU_CALL tBack, do_return_settings ;
773 MENU_END 1629 MENU_END
774 ELSE 1630 ELSE
775 MENU_BEGIN tSystSets, .5 1631 MENU_BEGIN tSystSets, .4
776 MENU_CALL tLogOffset, do_log_offset_menu ; see above 1632 MENU_CALL tLogOffset, do_menu_log_offset ; see above
777 MENU_DYNAMIC info_menu_total_dives, 0 1633 MENU_CALL tResetMenu, do_menu_reset ;
778 MENU_CALL tResetMenu, do_reset_menu ; 1634 MENU_CALL tPiezo, do_menu_piezo ;
779 MENU_CALL tPiezo, do_settings_piezo_menu ; 1635 MENU_CALL tBack, do_return_menu_settings ;
780 MENU_CALL tBack, do_return_settings ;
781 MENU_END 1636 MENU_END
782 ENDIF 1637 ENDIF
783 1638
784 1639
785 do_settings_piezo_menu:
786 ; Menu with features only available in piezo button hardware
787 MENU_BEGIN tPiezo, .3
788 MENU_OPTION tButtonleft, ocR_button_left, 0 ; left button sensitivity
789 MENU_OPTION tButtonright, ocR_button_right, 0 ; right button sensitivity
790 MENU_CALL tBack, do_return_syssets_menu_piezo
791 MENU_END
792
793
794 IFDEF _compass 1640 IFDEF _compass
795 1641
796 do_compass_menu: 1642 ;-----------------------------------------------------------------------------
1643 ; Settings Menu - 3rd Layer - System Settings - Compass
1644 ;
1645 do_menu_compass:
797 MENU_BEGIN tCompassMenu, .5 1646 MENU_BEGIN tCompassMenu, .5
798 MENU_CALL tCompassMenu, compass_calibration_loop ; exits to surface loop 1647 MENU_CALL tCompassCalibration, do_compass_calibration
799 ; MENU_OPTION tCompassGain, oCompassGain, 0 1648 ; MENU_OPT_INC tCompassGain, oCompassGain
800 MENU_DYNAMIC menu_cal_x, 0 1649 MENU_DYNAMIC dyn_compass_cal_x, 0
801 MENU_DYNAMIC menu_cal_y, 0 1650 MENU_DYNAMIC dyn_compass_cal_y, 0
802 MENU_DYNAMIC menu_cal_z, 0 1651 MENU_DYNAMIC dyn_compass_cal_z, 0
803 MENU_CALL tBack, do_return_settings_more 1652 MENU_CALL tBack, do_return_menu_syssets_more
804 MENU_END 1653 MENU_END
1654
1655
1656 ;-----------------------------------------------------------------------------
1657 ; Call Function - start Compass Calibration
1658 ;
1659 do_compass_calibration:
1660 goto compass_calibration ; code hosted in compass_ops.asm
1661
1662
1663 ;-----------------------------------------------------------------------------
1664 ; dynamic Title - Calibration Value X
1665 ;
1666 dyn_compass_cal_x:
1667 STRCAT_TEXT tCalX ; print label
1668 lfsr FSR0,compass_CX_f ; address calibration value X
1669 bra dyn_compass_cal_common ; continue with common part
1670
1671
1672 ;-----------------------------------------------------------------------------
1673 ; dynamic Title - Calibration Value Y
1674 ;
1675 dyn_compass_cal_y:
1676 STRCAT_TEXT tCalY ; print label
1677 lfsr FSR0,compass_CY_f ; address calibration value Y
1678 bra dyn_compass_cal_common ; continue with common part
1679
1680
1681 ;-----------------------------------------------------------------------------
1682 ; dynamic Title - Calibration Value Z
1683 ;
1684 dyn_compass_cal_z:
1685 STRCAT_TEXT tCalZ ; print label
1686 lfsr FSR0,compass_CZ_f ; address calibration value Z
1687 ;bra dyn_compass_cal_common ; continue with common part
1688
1689
1690 ;-----------------------------------------------------------------------------
1691 ; Helper Function to dynamic Titles - Calibration Value
1692 ;
1693 dyn_compass_cal_common:
1694 movff POSTINC0,lo ; read calibration value, low byte
1695 movff POSTINC0,hi ; read calibration value, high byte
1696 PUTC ':' ; print ":"
1697 PUTC ' ' ; print a space
1698 call convert_signed_16bit ; convert lo:hi into signed-short and adds '-' to POSTINC2 if required
1699 btfsc neg_flag ; value negative?
1700 bra dyn_compass_cal_common_1 ; YES - print value
1701 PUTC '+' ; NO - add a plus sign
1702 dyn_compass_cal_common_1:
1703 output_65535 ; print value
1704 return ; done
805 1705
806 ENDIF ; _compass 1706 ENDIF ; _compass
807 1707
808 1708
809 ;============================================================================= 1709 ;-----------------------------------------------------------------------------
810 ; Reset and confirmation menu 1710 ; Settings Menu - 3rd Layer - System Settings - Logbook Offset
811 1711 ;
812 do_reset_menu: 1712 do_menu_log_offset:
813 MENU_BEGIN tResetMenu, .6
814 MENU_CALL tBack, do_return_settings_more
815 MENU_CALL tReboot, do_reset_menu_reboot ; confirm
816 MENU_CALL tResetDeco, do_reset_menu_deco ; confirm
817 MENU_CALL tResetSettings, do_reset_menu_settings ; confirm
818 MENU_CALL tResetLogbook, do_reset_menu_logbook ; confirm
819 MENU_CALL tResetBattery, do_new_battery_menu ; confirm
820 MENU_END
821
822 do_reset_menu_reboot:
823 MENU_BEGIN tResetMenu2, .2
824 MENU_CALL tAbort, do_return_settings_more_deeper
825 MENU_CALL tReboot, do_reboot ; reboot (cold start)
826 MENU_END
827
828 do_reset_menu_deco:
829 MENU_BEGIN tResetMenu2, .2
830 MENU_CALL tAbort, do_return_settings_more_deeper
831 MENU_CALL tResetDeco, do_reset_deco ; reset deco and return to main reset menu
832 MENU_END
833
834 do_reset_menu_settings:
835 MENU_BEGIN tResetMenu2, .2
836 MENU_CALL tAbort, do_return_settings_more_deeper
837 MENU_CALL tResetSettings, do_reset_settings ; reset all settings and go to surface mode
838 MENU_END
839
840 do_reset_menu_logbook:
841 MENU_BEGIN tResetMenu2, .2
842 MENU_CALL tAbort, do_return_settings_more_deeper
843 MENU_CALL tResetLogbook, do_reset_logbook ; reset logbook and return to main reset menu
844 MENU_END
845
846
847 do_reset_logbook:
848 call erase_complete_logbook ; erase complete logbook
849 bra do_return_settings_more_deeper
850
851 do_reset_deco:
852 call deco_clear_tissue ; set all tissues to absolute pressure * N2_ratio (C-code)
853 call deco_calc_dive_interval_1min ; update tissues by 1 minute to calculate current GF factor (C-code)
854 call deco_calc_desaturation_time ; calculate desaturation and no-fly/no-altitude time (C-code)
855 banksel common
856 call eeprom_deco_data_write ; store updated deco data into EEPROM
857 bra do_return_settings_more_deeper
858
859
860 do_reset_settings:
861 call TFT_ClearScreen ; clear screen to show start of activity
862 call option_reset_all ; reset all options to factory default
863 call do_logoffset_reset ; reset log offset
864 goto restart ; restart into surface mode
865
866 do_reboot:
867 call ext_flash_enable_protection ; set write protection on external flash
868 call eeprom_deco_data_write ; update deco data in EEPROM
869 call eeprom_battery_gauge_write ; update battery gauge in EEPROM
870 btfsc options_changed ; do the options need to be stored to EEPROM ?
871 call option_check_and_store_all ; YES - check and store all option values in EEPROM
872 reset ; cold-start the processor
873
874 do_return_date_time_menu:
875 call menu_processor_double_pop ; drop exit line and back to last line
876
877 do_date_time_menu:
878 bsf imprint_time_date ; start imprinting current time & date
879 bcf block_option_value ; allow display of option values again
880
881 MENU_BEGIN tSetTimeDate, .4
882 MENU_CALL tSetTime, do_time_menu
883 MENU_CALL tSetDate, do_date_menu
884 MENU_OPTION tDateFormat, oDateFormat, 0
885 MENU_CALL tBack, do_return_settings
886 MENU_END
887
888
889 do_date_menu:
890 bsf block_option_value ; suspend display of option values
891
892 MENU_BEGIN tSetDate, .4
893 MENU_OPTION tSetDay, oSetDay, 0
894 MENU_OPTION tSetMonth, oSetMonth, 0
895 MENU_OPTION tSetYear, oSetYear, 0
896 MENU_CALL tBack, do_return_date_time_menu
897 MENU_END
898
899
900 do_time_menu:
901 bsf block_option_value ; suspend display of option values
902
903 MENU_BEGIN tSetTime, .4
904 MENU_OPTION tSetHours, oSetHours, 0
905 MENU_OPTION tSetMinutes, oSetMinutes, 0
906 MENU_OPTION tSetSeconds, oClearSeconds, 0
907 MENU_CALL tBack, do_return_date_time_menu
908 MENU_END
909
910
911 do_toggle_ppo2_max_work: ; add 0.1 bar
912 movff char_I_ppO2_max_work,lo ; bank-safe copy
913 movlw .10
914 addwf lo,F
915 movlw ppo2_warning_high_highest
916 cpfsgt lo
917 bra do_toggle_ppo2_max2
918 movlw ppo2_warning_high_lowest
919 movwf lo
920 do_toggle_ppo2_max2:
921 movff lo,char_I_ppO2_max_work
922 return
923
924 do_toggle_ppo2_max_deco: ; add 0.1 bar
925 movff char_I_ppO2_max_deco,lo ; bank-safe copy
926 movlw .10
927 addwf lo,F
928 movlw ppo2_warning_deco_highest
929 cpfsgt lo
930 bra do_toggle_ppo2_max_deco2
931 movlw ppo2_warning_deco_lowest
932 movwf lo
933 do_toggle_ppo2_max_deco2:
934 movff lo,char_I_ppO2_max_deco
935 return
936
937 do_toggle_ppo2_min: ; sub 0.1 bar
938 movff char_I_ppO2_min,lo ; bank-safe copy
939 incf lo,F
940 movlw ppo2_warning_low_highest
941 cpfsgt lo
942 bra do_toggle_ppo2_min2
943 movlw ppo2_warning_low_lowest
944 movwf lo
945 do_toggle_ppo2_min2:
946 movff lo,char_I_ppO2_min
947 return
948
949 do_toggle_ppo2_min_cc: ; sub 0.1 bar
950 movff char_I_ppO2_min_loop,lo ; bank-safe copy
951 incf lo,F
952 movlw ppo2_warning_loop_highest
953 cpfsgt lo
954 bra do_toggle_ppo2_min_cc2
955 movlw ppo2_warning_loop_lowest
956 movwf lo
957 do_toggle_ppo2_min_cc2:
958 movff lo,char_I_ppO2_min_loop
959 return
960
961
962 ; Logbook offset sub-menu
963 do_log_offset_menu:
964 1713
965 clrf WREG ; select an initial step size of 1 1714 clrf WREG ; select an initial step size of 1
966 movff WREG,opt_logoffset_step ; bank-safe write to option variable 1715 movff WREG,opt_logoffset_step ; bank-safe write to option variable (volatile option)
967 1716
968 MENU_BEGIN tLogOffset, .5 1717 MENU_BEGIN tLogOffset, .5
969 MENU_DYNAMIC TFT_LogOffset, 0 1718 MENU_DYNAMIC dyn_logoffset_show_value, 0
970 MENU_OPTION tLogOffStepSize, oLogOffsetStep, 0 1719 MENU_OPT_INC tLogOffStepSize, oLogOffsetStep
971 MENU_CALL tLogOffsetplus, do_logoffset_plus 1720 MENU_CALL tLogOffsetplus, do_log_offset_plus
972 MENU_CALL tLogOffsetminus, do_logoffset_minus 1721 MENU_CALL tLogOffsetminus, do_log_offset_minus
973 MENU_CALL tBack, do_return_settings_more 1722 MENU_CALL tBack, do_return_menu_syssets_more
974 MENU_END 1723 MENU_END
975 1724
976 1725
1726 ;-----------------------------------------------------------------------------
1727 ; dynamic Title - show Logbook Offset
1728 ;
1729 dyn_logoffset_show_value:
1730 STRCPY_TEXT tLogOffsetValue ; print "Offset" in selected language
1731 call eeprom_log_offset_read ; read offset into lo:hi
1732 output_9999 ; print offset (0-9999)
1733 return ; no "_PRINT" here...
1734
1735
1736 ;-----------------------------------------------------------------------------
1737 ; Call Function - increment Logbook Offset
1738 ;
1739 do_log_offset_plus:
1740 rcall do_logoffset_common ; load current offset and step size
1741 ; add step size to current offset
1742 movf mpr+2,W ; get step size, low byte
1743 addwf mpr+0,F ; add to offset, low byte
1744 movf mpr+3,W ; get step size, high byte
1745 addwfc mpr+1,F ; add to offset, high byte, considering carry flag
1746 ; check if new offset is within limit
1747 MOVLI .9999,sub_a ; load max limit into sub_a
1748 MOVII mpr, sub_b ; copy new offset into sub_b
1749 call cmpU16 ; compute sub_a - sub_b, setting neg_flag if result becomes negative
1750 btfss neg_flag ; neg_flag set, i.e. new offset > 9999 ?
1751 bra do_logoffset_exit ; NO - store offset and return
1752 MOVLI .9999,mpr ; YES - limit offset to 9999
1753 bra do_logoffset_exit ; - store offset and return
1754
1755
1756 ;-----------------------------------------------------------------------------
1757 ; Call Function - decrement Logbook Offset
1758 ;
1759 do_log_offset_minus:
1760 rcall do_logoffset_common ; load current offset and step size
1761 ; subtract step size from current offset
1762 movf mpr+2,W ; get step size, low byte
1763 subwf mpr+0,F ; subtract from offset, low byte
1764 movf mpr+3,W ; get step size, high byte
1765 subwfb mpr+1,F ; subtract from offset, high byte, considering borrow flag
1766 ; check if new offset is within limit
1767 btfsc STATUS,C ; borrow to propagate (B == /CARRY) ?
1768 bra do_logoffset_exit ; NO - result >= 0, store and return
1769 ;bra do_logoffset_reset ; YES - revert offset to 0
1770
1771
1772 ;-----------------------------------------------------------------------------
1773 ; Helper Functions - Logbook Offset Reset & Write-Back
1774 ;
1775 do_logoffset_reset:
1776 CLRI mpr ; set offset to 0
1777 do_logoffset_exit:
1778 goto eeprom_log_offset_write ; store offset and return
1779
1780
1781 ;-----------------------------------------------------------------------------
1782 ; Helper Function - compute Step Size
1783 ;
977 do_logoffset_common: 1784 do_logoffset_common:
978 call eeprom_log_offset_read ; read current offset into mpr+1:mpr+0 1785 call eeprom_log_offset_read ; read current offset into mpr+1:mpr+0
979 movff opt_logoffset_step,ul ; get step size: 0=1, 1=10, 2=100, 3=1000 1786 movff opt_logoffset_step,ul ; get step size: 0=1, 1=10, 2=100, 3=1000
980 incf ul,F ; 0...3 -> 1...4 1787 incf ul,F ; 0...3 -> 1...4
981 clrf mpr+3 ; clear step size, high byte 1788 clrf mpr+3 ; clear step size, high byte
989 return ; YES - done 1796 return ; YES - done
990 movlw .100 ; NO - set a step size of 100 1797 movlw .100 ; NO - set a step size of 100
991 movwf mpr+2 ; - copy to step size, low byte 1798 movwf mpr+2 ; - copy to step size, low byte
992 dcfsnz ul,F ; ul--, did ul became 0, i.e. step size = 100 ? 1799 dcfsnz ul,F ; ul--, did ul became 0, i.e. step size = 100 ?
993 return ; YES - done 1800 return ; YES - done
994 movlw LOW .1000 ; NO - set a step size of 1000, low byte 1801 movlw LOW .1000 ; NO - set a step size of 1000, low byte
995 movwf mpr+2 ; - copy to step size, low byte 1802 movwf mpr+2 ; - copy to step size, low byte
996 movlw HIGH .1000 ; - set a step size of 1000, high byte 1803 movlw HIGH .1000 ; - set a step size of 1000, high byte
997 movwf mpr+3 ; - copy to step size, high byte 1804 movwf mpr+3 ; - copy to step size, high byte
998 return ; - done 1805 return ; - done
999 1806
1000 do_logoffset_plus: 1807
1001 rcall do_logoffset_common ; load current offset and step size 1808 ;-----------------------------------------------------------------------------
1002 ; add step size to current offset 1809 ; Settings Menu - 3rd Layer - System Settings - adjust Piezo Buttons
1003 movf mpr+2,W ; get step size, low byte 1810 ;
1004 addwf mpr+0,F ; add to offset, low byte 1811 do_menu_piezo:
1005 movf mpr+3,W ; get step size, high byte 1812 MENU_BEGIN tPiezo, .3
1006 addwfc mpr+1,F ; add to offset, high byte, considering carry flag 1813 MENU_OPT_INC tButtonleft, ocR_button_left ; left button sensitivity
1007 ; check if new offset is within limit 1814 MENU_OPT_INC tButtonright, ocR_button_right ; right button sensitivity
1008 MOVLI .9999,sub_a ; load max limit into sub_a 1815 MENU_CALL tBack, do_return_menu_syssets_piezo
1009 MOVII mpr, sub_b ; copy new offset into sub_b 1816 MENU_END
1010 call cmpU16 ; compute sub_a - sub_b, setting neg_flag if result becomes negative 1817
1011 btfss neg_flag ; neg_flag set, i.e. new offset > 9999 ? 1818
1012 bra do_logoffset_exit ; NO - store offset and return 1819 ;-----------------------------------------------------------------------------
1013 MOVLI .9999,mpr ; YES - limit offset to 9999 1820 ; Settings Menu - 3rd Layer - System Settings - Reset Menus
1014 bra do_logoffset_exit ; - store offset and return 1821 ;
1015 1822 do_menu_reset:
1016 do_logoffset_minus: 1823 MENU_BEGIN tResetMenu, .6
1017 rcall do_logoffset_common ; load current offset and step size 1824 MENU_CALL tBack, do_return_menu_syssets_more
1018 ; subtract step size from current offset 1825 MENU_CALL tReboot, do_menu_reset_reboot ; confirm
1019 movf mpr+2,W ; get step size, low byte 1826 MENU_CALL tResetDeco, do_menu_reset_deco ; confirm
1020 subwf mpr+0,F ; subtract from offset, low byte 1827 MENU_CALL tResetSettings, do_menu_reset_settings ; confirm
1021 movf mpr+3,W ; get step size, high byte 1828 MENU_CALL tResetLogbook, do_menu_reset_logbook ; confirm
1022 subwfb mpr+1,F ; subtract from offset, high byte, considering borrow flag 1829 MENU_CALL tResetBattery, do_menu_reset_battery ; confirm
1023 ; check if new offset is within limit 1830 MENU_END
1024 btfsc STATUS,C ; borrow to propagate (B == /CARRY) ? 1831
1025 bra do_logoffset_exit ; NO - result >= 0, store and return 1832
1026 do_logoffset_reset: 1833 ;-----------------------------------------------------------------------------
1027 CLRI mpr ; YES - revert offset to 0 1834 ; Settings Menu - 4th Layer - System Settings - Reset - Reboot / FW Recovery
1028 ;bra do_logoffset_exit ; - store offset and return 1835 ;
1029 1836 do_menu_reset_reboot:
1030 do_logoffset_exit: 1837 IFDEF _firmware_recovery
1031 goto eeprom_log_offset_write ; store offset and return 1838 MENU_BEGIN tResetMenu2, .4
1032 1839 MENU_CALL tAbort, do_return_menu_syssets_more_more
1033 1840 MENU_CALL tRebootCurFirmware, do_reboot ; reboot current firmware
1034 do_return_dispsets_menu: 1841 MENU_DYNAMIC dyn_menu_fw_backup, do_firmware_backup ; backup current firmware
1035 bcf imprint_color_schemes ; not in color schemes menu any more 1842 MENU_DYNAMIC dyn_menu_fw_restore, do_firmware_restore ; restore backup firmware
1036 call menu_processor_double_pop ; drop exit line and back to last line
1037
1038 do_dispsets_menu:
1039 IF _language_2!=none
1040 MENU_BEGIN tDispSets, .7
1041 MENU_OPTION tBright, oBrightness, 0
1042 MENU_OPTION tLayout, oLayout, 0
1043 MENU_OPTION tUnits, oUnits, 0
1044 MENU_OPTION tLanguage, oLanguage, 0
1045 MENU_OPTION tFlip, oFlipScreen, 0
1046 MENU_CALL tColorScheme, do_color_scheme
1047 MENU_CALL tMore, do_dispsets_menu_more
1048 MENU_END 1843 MENU_END
1049 ELSE 1844 ELSE
1050 MENU_BEGIN tDispSets, .6 1845 MENU_BEGIN tResetMenu2, .2
1051 MENU_OPTION tBright, oBrightness, 0 1846 MENU_CALL tAbort, do_return_menu_syssets_more_more
1052 MENU_OPTION tLayout, oLayout, 0 1847 MENU_CALL tReboot, do_reboot ; reboot (cold start)
1053 MENU_OPTION tUnits, oUnits, 0
1054 MENU_OPTION tFlip, oFlipScreen, 0
1055 MENU_CALL tColorScheme, do_color_scheme
1056 MENU_CALL tMore, do_dispsets_menu_more
1057 MENU_END 1848 MENU_END
1058 ENDIF 1849 ENDIF
1059 1850
1060 1851
1061 do_dispsets_menu_more: 1852 ;-----------------------------------------------------------------------------
1062 IFDEF _helium 1853 ; Call Function - Reboot
1063 MENU_BEGIN tDispSets, .7 1854 ;
1064 MENU_OPTION tVSIgraph, oVSIgraph, 0 1855 do_reboot:
1065 MENU_OPTION tVSItext2, oVSItext, 0 1856 call ext_flash_enable_protection ; set write protection on external flash
1066 MENU_OPTION tShowppO2, oShowppO2, 0 1857 call eeprom_deco_data_write ; update deco data in EEPROM
1067 MENU_OPTION tDepthWarning, oDepthWarn, 0 1858 call eeprom_battery_gauge_write ; update battery gauge in EEPROM
1068 MENU_OPTION t2ndDepth, o2ndDepthDisp, 0 1859 btfsc option_changed ; do the options need to be stored to EEPROM ?
1069 MENU_OPTION tTissueGraphics, oTissueGraphics, 0 1860 call option_check_and_store_all ; YES - check and store all option values in EEPROM
1070 MENU_CALL tBack, do_return_settings_deeper 1861 reset ; cold-start the processor
1071 MENU_END 1862
1072 ELSE 1863
1073 MENU_BEGIN tDispSets, .6 1864 IFDEF _firmware_recovery
1074 MENU_OPTION tVSIgraph, oVSIgraph, 0 1865
1075 MENU_OPTION tVSItext2, oVSItext, 0 1866 ;-----------------------------------------------------------------------------
1076 MENU_OPTION tShowppO2, oShowppO2, 0 1867 ; dynamic Title - Firmware Backup Option
1077 MENU_OPTION tDepthWarning, oDepthWarn, 0 1868 ;
1078 MENU_OPTION t2ndDepth, o2ndDepthDisp, 0 1869 dyn_menu_fw_backup:
1079 MENU_CALL tBack, do_return_settings_deeper 1870 EEPROM_CC_READ eeprom_fw_chksum_current+.5,WREG ; read stored FW ID
1080 MENU_END 1871 xorlw FW_ID ; XOR with current FW ID, equal?
1872 bnz dyn_menu_fw_backup_unable ; NO - unable to make a backup
1873 STRCPY_TEXT tBackupFirmware ; YES - print "Backup current Firmware"
1874 return ; - done
1875 dyn_menu_fw_backup_unable:
1876 STRCPY "-------" ; print dashes
1877 return ; done
1878
1879
1880 ;-----------------------------------------------------------------------------
1881 ; dynamic Title - Firmware Restore Option
1882 ;
1883 dyn_menu_fw_restore:
1884 STRCPY_TEXT tRecoverFirmware ; print "Recover"
1885 PUTC " " ; add a space
1886 PUTC "V" ; add a V for Version
1887 movlw 0x3C ; address firmware version in backup storage at 0x3C000A
1888 movwf ext_flash_address+2 ; ...
1889 clrf ext_flash_address+1 ; ...
1890 movlw 0x0A ; ...
1891 movwf ext_flash_address+0 ; ...
1892 FLASH_RR_READ mpr,.3 ; read backup firmware version (lo: major, hi: minor, up: beta)
1893 infsnz lo,W ; major = 0xFF ?
1894 bra dyn_menu_fw_restore_inop ; YES - no version to show
1895 bsf leftbind ; NO - print left-aligned
1896 output_99 ; - print major (0-99)
1897 PUTC '.' ; - add a dot
1898 movff hi,lo ; - get minor
1899 output_99x ; - print minor (00-99)
1900 PUTC ' ' ; - add a space
1901 movff up,lo ; - get beta/release
1902 tstfsz lo ; - release version?
1903 bra dyn_menu_fw_restore_beta ; - NO - beta
1904 STRCAT "Rel." ; - YES - append "Rel(ease)"
1905 return ; - done
1906 dyn_menu_fw_restore_beta:
1907 PUTC 'B' ; append "B(eta)"
1908 bsf leftbind ; print left-aligned
1909 output_256 ; print beta version (0-255)
1910 return ; done
1911 dyn_menu_fw_restore_inop:
1912 STRCAT "--.--" ; no recovery firmware available
1913 return ; done
1914
1915
1916 ;-----------------------------------------------------------------------------
1917 ; Call Function - backup Firmware
1918 ;
1919 do_firmware_backup:
1920 EEPROM_CC_READ eeprom_fw_chksum_current+.5,WREG ; read stored FW ID
1921 xorlw FW_ID ; XOR with current FW ID, equal?
1922 bnz do_firmware_abort ; NO - abort
1923 call TFT_ClearScreen ; YES - clear the screen
1924 WIN_SMALL .0, .100 ; - set position
1925 STRCPY_TEXT_PRINT tBackingUp ; - print "backing up..."
1926 call copy_fw_active_to_backup ; - copy 0x3Exxxx -> 0x3Cxxxx
1927 EEPROM_RR_READ eeprom_fw_chksum_current,buffer,.6 ; - retrieve checksum of current firmware
1928 EEPROM_RR_WRITE buffer,eeprom_fw_chksum_recovry,.6 ; - store as checksum of recovery firmware
1929 bra do_return_menu_syssets_more_more ; - done
1930
1931
1932 ;-----------------------------------------------------------------------------
1933 ; Call Function - restore Firmware
1934 ;
1935 do_firmware_restore:
1936 EXT_FLASH_ADDR 0x3C000A ; address firmware version in backup storage at 0x3C000A
1937 FLASH_CW_READ_0x40 ; read backup firmware major version into WREG
1938 infsnz WREG ; major = 0xFF ?
1939 bra do_firmware_abort ; YES - abort, no firmware available for restoration
1940 call TFT_ClearScreen ; NO - clear the screen
1941 WIN_SMALL .0, .100 ; - set position
1942 STRCPY_TEXT_PRINT tRestoring ; - print "restoring..."
1943 call copy_fw_backup_to_active ; - copy 0x3Cxxxx -> 0x3Exxxx
1944 EEPROM_RR_READ eeprom_fw_chksum_recovry,buffer,.6 ; - retrieve checksum of recovery firmware
1945 EEPROM_RR_WRITE buffer,eeprom_fw_chksum_current,.6 ; - store as checksum of current firmware (to be)
1946 goto comm_firmware_update_exec ; - initiate firmware update
1947
1948
1949 ;-----------------------------------------------------------------------------
1950 ; Helper Function - back to same menu
1951 ;
1952 do_firmware_abort:
1953 call menu_processor_pop ; back to last line
1954 bra do_menu_reset_reboot ; back to same menu
1955
1081 ENDIF 1956 ENDIF
1082 1957
1083 1958
1084 do_color_scheme: 1959 ;-----------------------------------------------------------------------------
1085 bsf imprint_color_schemes ; in color schemes menu 1960 ; Settings Menu - 4th Layer - System Settings - Reset - Reset Deco
1086 1961 ;
1087 MENU_BEGIN tColorScheme, .2 1962 do_menu_reset_deco:
1088 MENU_OPTION tColorSetDive, oColorSetDive, 0 1963 MENU_BEGIN tResetMenu2, .2
1089 MENU_CALL tBack, do_return_dispsets_menu 1964 MENU_CALL tAbort, do_return_menu_syssets_more_more
1090 MENU_END 1965 MENU_CALL tResetDeco, do_reset_deco ; reset deco and return to main reset menu
1091 1966 MENU_END
1092 1967
1093 ;============================================================================= 1968
1094 1969 ;-----------------------------------------------------------------------------
1095 do_new_battery_menu: 1970 ; Call Function - Reset Deco
1971 ;
1972 do_reset_deco:
1973 call deco_clear_tissue ; set all tissues to absolute pressure * N2_ratio (C-code)
1974 call deco_calc_dive_interval_1min; update tissues by 1 minute to calculate current GF factor (C-code)
1975 call deco_calc_desaturation_time ; calculate desaturation and no-fly/no-altitude time (C-code)
1976 banksel common
1977 call eeprom_deco_data_write ; store updated deco data into EEPROM
1978 bra do_return_menu_syssets_more_more
1979
1980
1981 ;-----------------------------------------------------------------------------
1982 ; Settings Menu - 4th Layer - System Settings - Reset - Reset Settings
1983 ;
1984 do_menu_reset_settings:
1985 MENU_BEGIN tResetMenu2, .2
1986 MENU_CALL tAbort, do_return_menu_syssets_more_more
1987 MENU_CALL tResetSettings, do_reset_settings ; reset all settings and go to surface mode
1988 MENU_END
1989
1990
1991 ;-----------------------------------------------------------------------------
1992 ; Call Function - Reset Settings
1993 ;
1994 do_reset_settings:
1995 call TFT_ClearScreen ; clear screen to show start of activity
1996 call option_reset_all ; reset all options to factory default
1997 call do_logoffset_reset ; reset log offset
1998 goto restart ; restart into surface mode
1999
2000
2001 ;-----------------------------------------------------------------------------
2002 ; Settings Menu - 4th Layer - System Settings - Reset - Reset Logbook
2003 ;
2004 do_menu_reset_logbook:
2005 MENU_BEGIN tResetMenu2, .2
2006 MENU_CALL tAbort, do_return_menu_syssets_more_more
2007 MENU_CALL tResetLogbook, do_reset_logbook ; reset logbook and return to main reset menu
2008 MENU_END
2009
2010
2011 ;-----------------------------------------------------------------------------
2012 ; Call Function - Reset Logbook
2013 ;
2014 do_reset_logbook:
2015 call erase_complete_logbook ; erase complete logbook
2016 bra do_return_menu_syssets_more_more
2017
2018
2019 ;-----------------------------------------------------------------------------
2020 ; Settings Menu - 4th Layer - System Settings - Reset - Reset Battery
2021 ;
2022 do_menu_reset_battery:
1096 MENU_BEGIN tNewBattTitle, .2 2023 MENU_BEGIN tNewBattTitle, .2
1097 MENU_CALL tAbort, do_return_settings_more_deeper 2024 MENU_CALL tAbort, do_return_menu_syssets_more_more
1098 MENU_CALL tYes, do_new_battery_select_1 2025 MENU_CALL tYes, do_new_battery_select
1099 MENU_END 2026 MENU_END
1100 2027
1101 2028
1102 global do_new_battery_select 2029 ;-----------------------------------------------------------------------------
1103 do_new_battery_select: 2030 ; Entry Point for Battery Selection after Power-Outage
2031 ;
2032 global new_battery_select
2033 new_battery_select:
1104 call TFT_boot ; initialize TFT (includes clear screen) 2034 call TFT_boot ; initialize TFT (includes clear screen)
1105 call TFT_Display_FadeIn ; dim up the display 2035 call TFT_Display_FadeIn ; dim up the display
1106 call menu_processor_reset ; reset menu stack 2036 call menu_processor_reset ; reset menu stack
1107 2037 ;bra do_new_battery_select ; enter menu system
1108 do_new_battery_select_1: 2038
1109 ; make sure to reset battery percentage 2039
1110 movlw .100 2040 ;-----------------------------------------------------------------------------
1111 movwf batt_percent ; set battery level to full 2041 ; Settings Menu - 5th Layer - System Settings - Reset - Reset - Battery Selection
1112 2042 ;
1113 ; default (in cases of timeout or USB): use old battery 2043 do_new_battery_select:
2044 movlw .100 ; set battery level to full
2045 movwf batt_percent ; ...
2046 ; default (in cases of timeout or USB) to use old battery:
1114 call eeprom_battery_gauge_read ; retrieve stored battery gauge value from EEPROM 2047 call eeprom_battery_gauge_read ; retrieve stored battery gauge value from EEPROM
1115 2048
1116 IFDEF _screendump 2049 IFDEF _screendump
1117 bsf screen_dump_avail ; enable screen dump function to prevent exiting into COMM mode immediately 2050 bsf screen_dump_avail ; enable screen dump function to prevent exiting into COMM mode immediately
1118 ELSE 2051 ELSE
1129 ; 0x0A: optical input and ambient sensor ---> OSTC 3 (USB model) YES NO 1.5V 3.6V disposable 3.6V rechargeable 2062 ; 0x0A: optical input and ambient sensor ---> OSTC 3 (USB model) YES NO 1.5V 3.6V disposable 3.6V rechargeable
1130 ; 0x1A: BLE and optical input and ambient sensor ---> OSTC 3 (BLE model) YES NO 1.5V 3.6V disposable 3.6V rechargeable 2063 ; 0x1A: BLE and optical input and ambient sensor ---> OSTC 3 (BLE model) YES NO 1.5V 3.6V disposable 3.6V rechargeable
1131 ; 0x02: ambient sensor ---> OSTC Sport (USB model) YES NO 1.5V 3.6V disposable 3.6V rechargeable 2064 ; 0x02: ambient sensor ---> OSTC Sport (USB model) YES NO 1.5V 3.6V disposable 3.6V rechargeable
1132 ; 0x52: BLE and ambient sensor and low volt core ---> OSTC Sport (BLE model) YES NO 1.5V 3.6V disposable 3.6V rechargeable 2065 ; 0x52: BLE and ambient sensor and low volt core ---> OSTC Sport (BLE model) YES NO 1.5V 3.6V disposable 3.6V rechargeable
1133 2066
1134
1135 movlw 0x11 ; OSTC 2 (old model) 2067 movlw 0x11 ; OSTC 2 (old model)
1136 cpfseq HW_descriptor 2068 cpfseq HW_descriptor
1137 bra $+4 2069 bra $+4
1138 bra use_18650_battery 2070 bra use_18650_battery
1139 2071
1143 bra use_18650_battery 2075 bra use_18650_battery
1144 2076
1145 movlw 0x33 ; OSTC 2 TR 2077 movlw 0x33 ; OSTC 2 TR
1146 cpfseq HW_descriptor 2078 cpfseq HW_descriptor
1147 bra $+4 2079 bra $+4
1148 bra use_16650_battery 2080 bra do_use_16650_battery
1149 2081
1150 ; movlw 0xXX ; OSTC 2 (new model) TODO: define signature 2082 ; movlw 0xXX ; OSTC 2 (new model) TODO: define signature
1151 ; cpfseq HW_descriptor 2083 ; cpfseq HW_descriptor
1152 ; bra $+4 2084 ; bra $+4
1153 ; bra use_16650_battery 2085 ; bra do_use_16650_battery
1154 2086
1155 movlw 0x13 ; OSTC Plus TODO: and OSTC 2 new model as of now 2087 movlw 0x13 ; OSTC Plus TODO: and OSTC 2 new model as of now
1156 cpfseq HW_descriptor 2088 cpfseq HW_descriptor
1157 bra $+4 2089 bra $+4
1158 bra menu_new_battery_AA_charger 2090 bra do_menu_new_battery_AA_charger
1159 2091
1160 ; movlw 0x0A ; OSTC 3 (USB model) 2092 ; movlw 0x0A ; OSTC 3 (USB model)
1161 ; cpfseq HW_descriptor 2093 ; cpfseq HW_descriptor
1162 ; bra $+4 2094 ; bra $+4
1163 ; bra menu_new_battery_AA_no_charger 2095 ; bra do_menu_new_battery_AA_no_charge
1164 2096
1165 ; movlw 0x1A ; OSTC 3 (BLE model) 2097 ; movlw 0x1A ; OSTC 3 (BLE model)
1166 ; cpfseq HW_descriptor 2098 ; cpfseq HW_descriptor
1167 ; bra $+4 2099 ; bra $+4
1168 ; bra menu_new_battery_AA_no_charger 2100 ; bra do_menu_new_battery_AA_no_charge
1169 2101
1170 ; movlw 0x02 ; OSTC Sport (USB model) 2102 ; movlw 0x02 ; OSTC Sport (USB model)
1171 ; cpfseq HW_descriptor 2103 ; cpfseq HW_descriptor
1172 ; bra $+4 2104 ; bra $+4
1173 ; bra menu_new_battery_AA_no_charger 2105 ; bra do_menu_new_battery_AA_no_charge
1174 2106
1175 ; movlw 0x52 ; OSTC Sport (BLE model) 2107 ; movlw 0x52 ; OSTC Sport (BLE model)
1176 ; cpfseq HW_descriptor 2108 ; cpfseq HW_descriptor
1177 ; bra $+4 2109 ; bra $+4
1178 ; bra menu_new_battery_AA_no_charger 2110 ; bra do_menu_new_battery_AA_no_charge
1179 2111
1180 bra menu_new_battery_AA_no_charger ; any other model 2112 bra do_menu_new_battery_AA_no_charge ; any other model
1181 2113
1182 2114
2115 ;-----------------------------------------------------------------------------
2116 ; return from confirm 3.6 V rechargeable
2117 ;
1183 do_return_menu_new_bat_AA_chrg: 2118 do_return_menu_new_bat_AA_chrg:
1184 call menu_processor_double_pop ; drop exit line and back to last line 2119 call menu_processor_double_pop ; drop exit line and back to last line
1185 2120 ;bra do_menu_new_battery_AA_charger ; continue
1186 ; OSTC Plus (charging function) TODO: and OSTC 2 new model as of now 2121
1187 menu_new_battery_AA_charger: 2122 ;-----------------------------------------------------------------------------
2123 ; Battery Selection for OSTC Plus (charging function) TODO: and OSTC 2 new model as of now
2124 ;
2125 do_menu_new_battery_AA_charger:
1188 MENU_BEGIN tNewBattTitle, .4 2126 MENU_BEGIN tNewBattTitle, .4
1189 MENU_CALL tNewBattOld, use_old_batteries 2127 MENU_CALL tNewBattOld, do_use_old_battery ; load data of old battery
1190 MENU_CALL tNewBattNew15, use_new_15V_batteries ; not rechargeable 2128 MENU_CALL tNewBattNew15, do_use_15V_disposable ; not rechargeable
1191 ; MENU_CALL tNewBattNew36, use_36V_disposable ; not rechargeable -> not allowed any more !!! 2129 ; MENU_CALL tNewBattNew36, do_use_36V_disposable ; not rechargeable -> not allowed any more !!!
1192 MENU_CALL tNewBattAccu, pre_36V_rechargeable ; rechargeable -> goto safety question 2130 MENU_CALL tNewBattAccu, do_menu_new_battery_36V_charge ; rechargeable -> goto safety question
1193 MENU_CALL tNew16650, use_16650_battery ; OSTC 2 new model TODO: remove when OSTC 2 new model can be separated from Plus 2131 MENU_CALL tNew16650, do_use_16650_battery ; OSTC 2 new model TODO: remove when OSTC 2 new model can be separated from Plus
1194 MENU_END 2132 MENU_END
1195 2133
1196 pre_36V_rechargeable: 2134
2135 ;-----------------------------------------------------------------------------
2136 ; Safety Question for 3.6 V rechargeable Battery
2137 ;
2138 do_menu_new_battery_36V_charge:
1197 MENU_BEGIN tNewBattTitle, .5 2139 MENU_BEGIN tNewBattTitle, .5
1198 MENU_CALL tConfirmChargeable1, 0 ; safety question, line 1 2140 MENU_CALL tConfirmChargeable1, 0 ; safety question, line 1
1199 MENU_CALL tConfirmChargeable2, 0 ; safety question, line 2 2141 MENU_CALL tConfirmChargeable2, 0 ; safety question, line 2
1200 MENU_CALL tConfirmChargeable3, 0 ; safety question, line 3 2142 MENU_CALL tConfirmChargeable3, 0 ; safety question, line 3
1201 MENU_CALL tNo, do_return_menu_new_bat_AA_chrg ; NO - go back 2143 MENU_CALL tNo, do_return_menu_new_bat_AA_chrg ; NO - go back
1202 MENU_CALL tYes, use_37V_rechargeable ; YES - confirmed rechargeable 2144 MENU_CALL tYes, do_use_36V_chargeable ; YES - confirmed rechargeable
1203 MENU_END 2145 MENU_END
1204 2146
1205 ; OSTC 3 and Sport (no charging function) 2147
1206 menu_new_battery_AA_no_charger: 2148 ;-----------------------------------------------------------------------------
2149 ; Battery Selection for OSTC 3 and Sport (no charging function)
2150 ;
2151 do_menu_new_battery_AA_no_charge:
1207 MENU_BEGIN tNewBattTitle, .4 2152 MENU_BEGIN tNewBattTitle, .4
1208 MENU_CALL tNewBattOld, use_old_batteries 2153 MENU_CALL tNewBattOld, do_use_old_battery ; load data of old battery
1209 MENU_CALL tNewBattNew15, use_new_15V_batteries ; not rechargeable 2154 MENU_CALL tNewBattNew15, do_use_15V_disposable ; not rechargeable
1210 MENU_CALL tNewBattNew36, use_36V_disposable ; not rechargeable 2155 MENU_CALL tNewBattNew36, do_use_36V_disposable ; not rechargeable
1211 MENU_CALL tNewBattAccu, use_37V_rechargeable ; rechargeable 2156 MENU_CALL tNewBattAccu, do_use_36V_chargeable ; rechargeable
1212 MENU_END 2157 MENU_END
1213 2158
1214 2159
2160 ;-----------------------------------------------------------------------------
2161 ; Call Function - keep old Battery
2162 ;
2163 do_use_old_battery:
2164 rcall get_battery_data ; load data of old battery
2165 goto surfloop ; proceed to surface mode
2166
2167
2168 ;-----------------------------------------------------------------------------
2169 ; Call Function - new 1.5 V disposable
2170 ;
2171 do_use_15V_disposable:
2172 rcall setup_new_15v
2173 bra use_batt_exit
2174
2175
2176 ;-----------------------------------------------------------------------------
2177 ; Call Function - new 3.6 V disposable
2178 ;
2179 do_use_36V_disposable:
2180 rcall setup_new_saft
2181 bra use_batt_exit
2182
2183
2184 ;-----------------------------------------------------------------------------
2185 ; Call Function - new 3.6 V rechargeable
2186 ;
2187 do_use_36V_chargeable:
2188 rcall setup_new_panasonic
2189 call reset_battery_gauge
2190 bra use_batt_exit_1
2191
2192
2193 ;-----------------------------------------------------------------------------
2194 ; Call Function - build-in 16650
2195 ;
2196 do_use_16650_battery:
2197 rcall setup_new_16650
2198 bra use_batt_exit
2199
2200
2201 ;-----------------------------------------------------------------------------
2202 ; Call Function - build-in 18650
2203 ;
2204 use_18650_battery:
2205 rcall setup_new_18650
2206 ;bra use_batt_exit
2207
2208
2209 ;-----------------------------------------------------------------------------
2210 ; Helper Function - finish Battery Selection
2211 ;
2212 use_batt_exit:
2213 call reset_battery_gauge_and_lt2942 ; reset battery hard- and software gauge
2214
2215 use_batt_exit_1:
2216 IFNDEF _screendump
2217 bcf comm_mode_disabled ; re-enable COMM mode again
2218 ENDIF
2219 goto surfloop ; exit to surface mode
2220
2221
2222 ;-----------------------------------------------------------------------------
2223 ; Migrate Battery Selection from Firmwares prior 2.09
2224 ;
1215 global use_old_prior_209 2225 global use_old_prior_209
1216 use_old_prior_209: 2226 use_old_prior_209:
1217 EEPROM_CC_READ eeprom_battery_type,WREG ; read battery type from EEPROM 2227 EEPROM_CC_READ eeprom_battery_type,WREG ; read battery type from EEPROM
1218 incfsz WREG,W ; battery type = 0xFF (undefined) ? 2228 incfsz WREG,W ; battery type = 0xFF (undefined) ?
1219 return ; NO - done 2229 return ; NO - done
1223 movlw .1 ; - NO - assume a Saft (disposable 3.6 V) 2233 movlw .1 ; - NO - assume a Saft (disposable 3.6 V)
1224 EEPROM_CC_WRITE WREG,eeprom_battery_type; - write battery type to EEPROM 2234 EEPROM_CC_WRITE WREG,eeprom_battery_type; - write battery type to EEPROM
1225 return ; - done 2235 return ; - done
1226 2236
1227 2237
1228 use_old_batteries: 2238 ;-----------------------------------------------------------------------------
1229 rcall get_battery_data ; load data of old battery 2239 ; Retrieve Battery Selection from EEPROM
1230 goto surfloop ; proceed to surface loop 2240 ;
1231
1232
1233 global get_battery_data 2241 global get_battery_data
1234 get_battery_data: 2242 get_battery_data:
1235 call eeprom_battery_gauge_read ; retrieve stored battery gauge value from EEPROM 2243 call eeprom_battery_gauge_read ; retrieve stored battery gauge value from EEPROM
1236 movff battery_type,lo ; copy retrieved battery type to lo 2244 movff battery_type,lo ; copy retrieved battery type to lo
1237 rcall setup_new_saft ; default battery configuration 2245 rcall setup_new_saft ; default battery configuration
1251 bcf comm_mode_disabled ; re-enable COMM mode again 2259 bcf comm_mode_disabled ; re-enable COMM mode again
1252 ENDIF 2260 ENDIF
1253 return ; done 2261 return ; done
1254 2262
1255 2263
2264 ;-----------------------------------------------------------------------------
2265 ; Helper Functions - configure Battery Types
2266
1256 ; disposable 1.5 Volt Alkaline 2267 ; disposable 1.5 Volt Alkaline
1257 setup_new_15v: 2268 setup_new_15v:
1258 bsf charge_disable ; set charging-inhibit signal 2269 bsf charge_disable ; set charging-inhibit signal
1259 bcf charge_enable ; activate charging-inhibit signal 2270 bcf charge_enable ; activate charging-inhibit signal
1260 movlw .100 2271 movlw .100
1305 MOVLI offset_ur16650, battery_offset 2316 MOVLI offset_ur16650, battery_offset
1306 movlw .4 2317 movlw .4
1307 movwf battery_type 2318 movwf battery_type
1308 return 2319 return
1309 2320
1310
1311 use_new_15V_batteries:
1312 rcall setup_new_15v
1313 bra use_batt_exit
1314
1315 use_36V_disposable:
1316 rcall setup_new_saft
1317 bra use_batt_exit
1318
1319 use_37V_rechargeable:
1320 rcall setup_new_panasonic
1321 call reset_battery_gauge
1322 bra use_batt_exit_1
1323
1324 use_16650_battery:
1325 rcall setup_new_16650
1326 bra use_batt_exit
1327
1328 use_18650_battery:
1329 rcall setup_new_18650
1330 ;bra use_batt_exit
1331
1332 use_batt_exit:
1333 call reset_battery_gauge_and_lt2942 ; reset battery pointer 0x07-0x0C and battery gauge
1334 use_batt_exit_1:
1335 IFNDEF _screendump
1336 bcf comm_mode_disabled ; re-enable COMM mode again
1337 ENDIF
1338 goto surfloop ; jump to surface loop
1339
1340 ;----------------------------------------------------------------------------- 2321 ;-----------------------------------------------------------------------------
1341 2322
1342 END 2323 END