Mercurial > public > hwos_code
comparison src/menu_tree.asm @ 623:c40025d8e750
3.03 beta released
author | heinrichsweikamp |
---|---|
date | Mon, 03 Jun 2019 14:01:48 +0200 |
parents | 7b3903536213 |
children | cd58f7fc86db |
comparison
equal
deleted
inserted
replaced
622:02d1386429a6 | 623:c40025d8e750 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File menu_tree.asm REFACTORED VERSION V2.99g | 3 ; File menu_tree.asm next combined generation V3.03.3 |
4 ; | 4 ; |
5 ; OSTC 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. |
17 #include "logbook.inc" | 17 #include "logbook.inc" |
18 #include "tft.inc" | 18 #include "tft.inc" |
19 #include "eeprom_rs232.inc" | 19 #include "eeprom_rs232.inc" |
20 #include "external_flash.inc" | 20 #include "external_flash.inc" |
21 #include "shared_definitions.h" ; mailbox from/to p2_deco.c | 21 #include "shared_definitions.h" ; mailbox from/to p2_deco.c |
22 #include "isr.inc" | |
23 #include "ghostwriter.inc" | 22 #include "ghostwriter.inc" |
24 #include "adc_lightsensor.inc" | 23 #include "adc_lightsensor.inc" |
25 #include "wait.inc" | 24 #include "wait.inc" |
26 #include "i2c.inc" | 25 #include "i2c.inc" |
26 #include "calibrate.inc" | |
27 #include "math.inc" | |
28 #include "rtc.inc" | |
27 | 29 |
28 | 30 |
29 extern do_demo_divemode | 31 extern do_demo_divemode |
30 extern restart | 32 extern restart |
31 extern option_save_all | 33 extern option_save_all |
32 extern option_reset | 34 extern option_reset |
33 extern do_demo_planner | 35 extern do_demo_planner |
34 extern calibrate_mix | 36 extern comm_mode_ble ; will also set CPU speed to normal |
35 extern comm_mode0 | |
36 extern piezo_config | 37 extern piezo_config |
37 extern compass_calibration_loop | |
38 extern option_reset_all | 38 extern option_reset_all |
39 extern rtc_set_rtc | 39 extern rtc_set_rtc |
40 extern surfloop | 40 extern surfloop |
41 extern oColorSetDive | 41 extern oColorSetDive |
42 extern vault_decodata_into_eeprom | |
43 | |
44 IFDEF _ccr_pscr | |
42 extern option_cleanup_oCCRMode | 45 extern option_cleanup_oCCRMode |
46 ENDIF | |
47 | |
48 IFDEF _compass | |
49 extern compass_calibration_loop | |
50 ENDIF | |
43 | 51 |
44 | 52 |
45 menu_tree CODE | 53 menu_tree CODE |
54 | |
55 ;----------------------------------------------------------------------------- | |
56 | |
46 | 57 |
47 ;============================================================================= | 58 ;============================================================================= |
48 ; Main Menu | 59 ; Main Menu |
49 | 60 |
50 do_return_main_menu: | 61 do_return_main_menu: |
51 call menu_processor_double_pop ; drop exit line and back to last line | 62 call menu_processor_double_pop ; drop exit line and back to last line |
52 bra do_main_menu_common | 63 bra do_main_menu_common |
53 | 64 |
54 global do_main_menu | 65 global do_main_menu |
55 do_main_menu: | 66 do_main_menu: |
56 movff menupos3,customview_surfmode ; save last customview | 67 movff active_customview,customview_surfmode ; save last custom view |
68 clrf MS_flags_imprint ; clear all flags for data imprinting | |
57 | 69 |
58 global do_main_menu2 | 70 global do_main_menu2 |
59 do_main_menu2: ; entry point used by logbook.asm | 71 do_main_menu2: ; entry point used by logbook.asm |
60 call TFT_boot | 72 call TFT_boot ; initialize display |
61 bcf sleepmode ; for timeout | 73 call menu_processor_reset ; reset menu stack |
62 call menu_processor_reset ; restart from first icon | |
63 | 74 |
64 do_main_menu_common: | 75 do_main_menu_common: |
76 IFDEF _ccr_pscr | |
65 MENU_BEGIN tMainMenu, .7 | 77 MENU_BEGIN tMainMenu, .7 |
66 MENU_CALL tLogbook, logbook | 78 MENU_CALL tLogbook, logbook |
67 MENU_CALL tGasSetup, do_gas_menu | 79 MENU_CALL tGasSetup, do_gas_menu |
68 MENU_CALL tCCRSetup, do_ccr_menu | 80 MENU_CALL tCCRSetup, do_ccr_menu |
69 MENU_CALL tPlan, do_planner_menu | 81 MENU_CALL tPlan, do_planner_menu |
70 MENU_CALL tDiveModeMenu, do_divemode_menu | 82 MENU_CALL tDiveModeMenu, do_divemode_menu |
71 MENU_CALL tSystSets, do_settings_menu | 83 MENU_CALL tSystSets, do_settings_menu |
72 MENU_CALL tExit, restart | 84 MENU_CALL tExit, do_restart |
73 MENU_END | 85 MENU_END |
74 | 86 ELSE |
87 MENU_BEGIN tMainMenu, .6 | |
88 MENU_CALL tLogbook, logbook | |
89 MENU_CALL tGasSetup, do_gas_menu | |
90 MENU_CALL tPlan, do_planner_menu | |
91 MENU_CALL tDiveModeMenu, do_divemode_menu | |
92 MENU_CALL tSystSets, do_settings_menu | |
93 MENU_CALL tExit, do_restart | |
94 MENU_END | |
95 ENDIF | |
96 | |
97 | |
98 do_restart: | |
99 bsf restart_fast ; skip logos and waits an restart | |
100 goto restart ; restart into surface mode | |
75 | 101 |
76 ;============================================================================= | 102 ;============================================================================= |
77 ; CCR Setup | 103 ; CCR Setup |
78 | 104 |
105 IFDEF _ccr_pscr | |
106 | |
79 do_return_ccr_menu: | 107 do_return_ccr_menu: |
80 call menu_processor_double_pop ; drop exit line and back to last line | 108 call menu_processor_double_pop ; drop exit line and back to last line |
81 | 109 |
82 do_ccr_menu: | 110 do_ccr_menu: |
83 bcf menu_update_sensor_mv ; stop imprinting of live sensor values | |
84 call option_cleanup_oCCRMode ; in pSCR mode, revert AutoSP (2) to calculated SP (0) | 111 call option_cleanup_oCCRMode ; in pSCR mode, revert AutoSP (2) to calculated SP (0) |
85 | 112 |
113 IFDEF _external_sensor | |
114 bcf imprint_sensor_mv ; stop imprinting of live O2 sensor mV data | |
86 btfsc analog_o2_input | 115 btfsc analog_o2_input |
87 bra do_ccr_menu_cR | 116 bra do_ccr_menu_cR |
88 | 117 ENDIF |
89 ; COMMENTED OUT - currently there is no difference between the OSTC 2 and 3 regarding this menu | |
90 ; btfss optical_input | |
91 ; bra do_ccr_menu_ostc2 | |
92 | 118 |
93 MENU_BEGIN tCCRSetup, .6 ; OSTC3 menu (and currently also the OSTC2 menu) | 119 MENU_BEGIN tCCRSetup, .6 ; OSTC3 menu (and currently also the OSTC2 menu) |
94 MENU_OPTION tCCRMode, oCCRMode, 0 | 120 MENU_OPTION tCCRMode, oCCRMode, 0 |
95 MENU_CALL tDiluentSetup, do_diluent_setup | 121 MENU_CALL tDiluentSetup, do_diluent_setup |
96 MENU_CALL tFixedSetpoints, do_fixed_setpoints | 122 MENU_CALL tFixedSetpoints, do_fixed_setpoints |
97 MENU_CALL tPSCRMenu, do_PSCR_menu | 123 MENU_CALL tPSCRMenu, do_PSCR_menu |
98 MENU_OPTION tCCmaxFracO2, oCCmaxFracO2, 0 | 124 MENU_OPTION tCCmaxFracO2, oCCmaxFracO2, 0 |
99 MENU_CALL tBack, do_return_main_menu | 125 MENU_CALL tBack, do_return_main_menu |
100 MENU_END | 126 MENU_END |
101 | 127 |
128 | |
129 IFDEF _external_sensor | |
102 | 130 |
103 do_ccr_menu_cR: ; cR menu | 131 do_ccr_menu_cR: ; cR menu |
104 MENU_BEGIN tCCRSetup, .7 | 132 MENU_BEGIN tCCRSetup, .7 |
105 MENU_OPTION tCCRMode, oCCRMode, 0 | 133 MENU_OPTION tCCRMode, oCCRMode, 0 |
106 MENU_CALL tCalibrateMenu, do_calibrate_menu | 134 MENU_CALL tCalibrateMenu, do_calibrate_menu |
109 MENU_CALL tPSCRMenu, do_PSCR_menu | 137 MENU_CALL tPSCRMenu, do_PSCR_menu |
110 MENU_OPTION tCCmaxFracO2, oCCmaxFracO2, 0 | 138 MENU_OPTION tCCmaxFracO2, oCCmaxFracO2, 0 |
111 MENU_CALL tBack, do_return_main_menu | 139 MENU_CALL tBack, do_return_main_menu |
112 MENU_END | 140 MENU_END |
113 | 141 |
114 ; COMMENTED OUT - currently there is no difference between the OSTC 2 and 3 regarding this menu | |
115 ;do_ccr_menu_ostc2: | |
116 ; MENU_BEGIN tCCRSetup, .6 ; ostc2 menu | |
117 ; MENU_OPTION tCCRMode, oCCRMode, 0 | |
118 ; MENU_CALL tDiluentSetup, do_diluent_setup | |
119 ; MENU_CALL tFixedSetpoints, do_fixed_setpoints | |
120 ; MENU_CALL tPSCRMenu, do_PSCR_menu | |
121 ; MENU_OPTION tCCmaxFracO2, oCCmaxFracO2, 0 | |
122 ; MENU_CALL tBack, do_return_main_menu | |
123 ; MENU_END | |
124 | |
125 | 142 |
126 do_calibrate_menu: | 143 do_calibrate_menu: |
127 call enable_ir_s8 ; enable IR/S8-Port | 144 call enable_ir_s8 ; enable IR/S8-Port |
128 bsf menu_update_sensor_mv ; start imprinting of live sensor values | 145 bsf imprint_sensor_mv ; start imprinting of live O2 sensor mV data |
129 | 146 |
130 do_calibrate_menu2: | 147 do_calibrate_menu2: |
131 MENU_BEGIN tCalibrateMenu, .6 | 148 MENU_BEGIN tCalibrateMenu, .6 |
132 MENU_CALL tDiveHudMask1, 0 | 149 MENU_CALL tDiveHudMask1, 0 |
133 MENU_CALL tDiveHudMask2, 0 | 150 MENU_CALL tDiveHudMask2, 0 |
134 MENU_CALL tDiveHudMask3, 0 | 151 MENU_CALL tDiveHudMask3, 0 |
135 MENU_OPTION tCalibrationGas,oCalGasO2, 0 | 152 MENU_OPTION tCalibrationGas, oCalGasO2, 0 |
136 MENU_CALL tCalibrate, do_calibrate_mix | 153 MENU_CALL tCalibrate, do_calibrate_mix |
137 MENU_CALL tBack, do_return_ccr_menu | 154 MENU_CALL tBack, do_return_ccr_menu |
138 MENU_END | 155 MENU_END |
139 | 156 |
140 | 157 |
141 do_calibrate_mix: | 158 do_calibrate_mix: |
142 call calibrate_mix ; calibrate with opt_calibration_O2_ratio, also calibrate S8 HUD if connected | 159 call calibrate_mix ; calibrate with opt_calibration_O2_ratio, also calibrate S8 HUD if connected |
143 WAITMS d'250' ; wait for HUD v3 | 160 WAITMS d'250' ; wait for HUD v3 |
144 movlw .9 | 161 movlw .9 |
145 movff WREG,customview_surfmode ; show sensor mV custom view after restart | 162 movff WREG,customview_surfmode ; show sensor mV custom view after restart |
163 bsf restart_fast ; skip logos and waits an restart | |
146 goto restart ; restart into surface mode | 164 goto restart ; restart into surface mode |
147 | 165 |
166 ENDIF ; _external_sensor | |
167 | |
148 | 168 |
149 do_diluent_setup: | 169 do_diluent_setup: |
150 bsf FLAG_diluent_setup ; setting up diluents | 170 bsf is_diluent_menu ; setting up diluents |
151 bcf short_gas_decriptions ; do not use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint | 171 bcf short_gas_descriptions ; do not use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint |
152 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) | 172 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) |
153 call gaslist_cleanup_list ; take care that only one gas can be first | 173 call gaslist_cleanup_list ; take care that only one gas can be first |
154 | 174 |
155 MENU_BEGIN tDiluentSetup, .6 | 175 MENU_BEGIN tDiluentSetup, .6 |
156 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu | 176 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu |
164 | 184 |
165 do_return_fixed_setpoints: | 185 do_return_fixed_setpoints: |
166 call menu_processor_double_pop ; drop exit line and back to last line | 186 call menu_processor_double_pop ; drop exit line and back to last line |
167 | 187 |
168 do_fixed_setpoints: | 188 do_fixed_setpoints: |
169 bcf short_gas_decriptions ; =1: use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint | 189 bcf short_gas_descriptions ; =1: use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint |
170 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) | 190 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) |
171 | 191 |
172 MENU_BEGIN tFixedSetpoints, .6 | 192 MENU_BEGIN tFixedSetpoints, .6 |
173 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu | 193 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu |
174 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu | 194 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu |
196 MENU_OPTION tPSCR_O2_drop, oPSCR_drop, 0 | 216 MENU_OPTION tPSCR_O2_drop, oPSCR_drop, 0 |
197 MENU_OPTION tPSCR_lungratio, oPSCR_lungratio, 0 | 217 MENU_OPTION tPSCR_lungratio, oPSCR_lungratio, 0 |
198 MENU_CALL tBack, do_return_ccr_menu | 218 MENU_CALL tBack, do_return_ccr_menu |
199 MENU_END | 219 MENU_END |
200 | 220 |
221 ENDIF ; _ccr_pscr | |
222 | |
201 ;============================================================================= | 223 ;============================================================================= |
202 ; OC Gas Setup | 224 ; OC Gas Setup |
203 | 225 |
204 do_return_gas_menu: | 226 do_return_gas_menu: |
205 call menu_processor_double_pop ; drop exit line and back to last line | 227 call menu_processor_double_pop ; drop exit line and back to last line |
206 | 228 |
207 btfsc FLAG_diluent_setup ; return to CCR-Menu? | 229 IFDEF _ccr_pscr |
230 btfsc is_diluent_menu ; return from setting up diluents? | |
208 bra do_diluent_setup ; YES | 231 bra do_diluent_setup ; YES |
232 ENDIF | |
209 | 233 |
210 do_gas_menu: | 234 do_gas_menu: |
211 bcf FLAG_diluent_setup ; not setting up diluents | 235 bcf is_diluent_menu ; setting up OC gases |
212 bcf short_gas_decriptions ; do not use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint | 236 bcf short_gas_descriptions ; do not use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint |
213 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) | 237 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) |
214 call gaslist_cleanup_list ; takes care that only one gas can be first | 238 call gaslist_cleanup_list ; takes care that only one gas can be first |
215 | 239 |
216 MENU_BEGIN tGaslist, .6 | 240 MENU_BEGIN tGaslist, .6 |
217 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu | 241 MENU_DYNAMIC gaslist_strcat_gas_cd, do_edit_gas_menu |
223 MENU_END | 247 MENU_END |
224 | 248 |
225 | 249 |
226 do_return_edit_gas_menu: | 250 do_return_edit_gas_menu: |
227 IFDEF _rx_functions | 251 IFDEF _rx_functions |
228 bcf menu_update_tank_pres ; stop imprinting of tank pressure updates | 252 bcf imprint_xmitter_pres ; stop imprinting of transmitter pressure data |
229 bcf FLAG_pairing_mode ; not in pairing menu any more (back to normal timeout) | 253 bcf imprint_xmitter_ID ; not in transmitter selection menu any more (back to normal timeout) |
230 ENDIF | 254 ENDIF |
231 call menu_processor_pop ; drop exit line and ... | 255 call menu_processor_double_pop ; drop exit line and back to last line |
232 do_abort_gas_depth_menu: | |
233 call menu_processor_pop ; back to last line | |
234 bra do_edit_gas_menu_common | 256 bra do_edit_gas_menu_common |
257 | |
235 do_edit_gas_menu: | 258 do_edit_gas_menu: |
236 movff PRODL,gaslist_gas ; get menu item we came from (0-4) | 259 movff PRODL,gaslist_gas ; get menu item we came from (0-4) |
237 movlw .5 ; offset between gases and diluents | 260 movlw .5 ; offset between gases and diluents |
238 btfsc FLAG_diluent_setup ; in CCR menu? | 261 btfsc is_diluent_menu ; setting up diluents? |
239 addwf gaslist_gas,F ; YES - add the offset | 262 addwf gaslist_gas,F ; YES - add the offset |
240 | 263 |
241 do_edit_gas_menu_common: | 264 do_edit_gas_menu_common: |
242 MENU_BEGIN tGasEdit, .7 | 265 MENU_BEGIN tGasEdit, .7 |
243 MENU_DYNAMIC gaslist_gastitle, 0 | 266 MENU_DYNAMIC gaslist_gastitle, 0 |
249 MENU_CALL tBack, do_return_gas_menu | 272 MENU_CALL tBack, do_return_gas_menu |
250 MENU_END | 273 MENU_END |
251 | 274 |
252 | 275 |
253 do_setup_mix_menu: | 276 do_setup_mix_menu: |
277 IFDEF _helium | |
254 MENU_BEGIN tGasEdit, .7 | 278 MENU_BEGIN tGasEdit, .7 |
255 MENU_DYNAMIC gaslist_gastitle, 0 | 279 MENU_DYNAMIC gaslist_gastitle, 0 |
256 MENU_DYNAMIC gaslist_MOD_END, 0 | 280 MENU_DYNAMIC gaslist_MOD_END, 0 |
257 MENU_CALL tO2Plus, gaslist_pO2 | 281 MENU_CALL tO2Plus, gaslist_pO2 |
258 MENU_CALL tO2Minus, gaslist_mO2 | 282 MENU_CALL tO2Minus, gaslist_mO2 |
259 MENU_CALL tHePlus, gaslist_pHe | 283 MENU_CALL tHePlus, gaslist_pHe |
260 MENU_CALL tHeMinus, gaslist_mHe | 284 MENU_CALL tHeMinus, gaslist_mHe |
261 MENU_CALL tBack, do_return_edit_gas_menu | 285 MENU_CALL tBack, do_return_edit_gas_menu |
262 MENU_END | 286 MENU_END |
287 ELSE | |
288 MENU_BEGIN tGasEdit, .5 | |
289 MENU_DYNAMIC gaslist_gastitle, 0 | |
290 MENU_DYNAMIC gaslist_MOD_END, 0 | |
291 MENU_CALL tO2Plus, gaslist_pO2 | |
292 MENU_CALL tO2Minus, gaslist_mO2 | |
293 MENU_CALL tBack, do_return_edit_gas_menu | |
294 MENU_END | |
295 ENDIF | |
263 | 296 |
264 | 297 |
265 do_setup_tank_menu: | 298 do_setup_tank_menu: |
266 IFDEF _rx_functions | 299 IFDEF _rx_functions |
267 btfsc FLAG_tr_enabled ; TR functions enabled? | 300 TSTOSC opt_TR_mode ; TR functions switched on? |
268 bra do_setup_tank_menu_rx ; YES | 301 bra do_setup_tank_menu_rx ; YES |
269 ENDIF | 302 ENDIF |
270 | 303 |
304 IFDEF _ccr_pscr | |
271 MENU_BEGIN tSetup_Tank, .6 | 305 MENU_BEGIN tSetup_Tank, .6 |
272 MENU_DYNAMIC gaslist_gastitle, 0 | 306 MENU_DYNAMIC gaslist_gastitle, 0 |
273 MENU_DYNAMIC gaslist_tank_size_pres, 0 | 307 MENU_DYNAMIC gaslist_tank_size_pres, 0 |
274 MENU_CALL tTankSize, gaslist_tank_size | 308 MENU_CALL tTankSize, gaslist_tank_size |
275 MENU_CALL tTankUsablePress, gaslist_tank_pres | 309 MENU_CALL tTankUsablePress, gaslist_tank_pres |
276 MENU_CALL tCopyDilToOC, gaslist_copy_dil_to_oc | 310 MENU_CALL tCopyDilToOC, gaslist_copy_dil_to_oc |
277 MENU_CALL tBack, do_return_edit_gas_menu | 311 MENU_CALL tBack, do_return_edit_gas_menu |
278 MENU_END | 312 MENU_END |
313 ELSE | |
314 MENU_BEGIN tSetup_Tank, .5 | |
315 MENU_DYNAMIC gaslist_gastitle, 0 | |
316 MENU_DYNAMIC gaslist_tank_size_pres, 0 | |
317 MENU_CALL tTankSize, gaslist_tank_size | |
318 MENU_CALL tTankUsablePress, gaslist_tank_pres | |
319 MENU_CALL tBack, do_return_edit_gas_menu | |
320 MENU_END | |
321 ENDIF | |
279 | 322 |
280 | 323 |
281 IFDEF _rx_functions | 324 IFDEF _rx_functions |
282 | |
283 do_setup_tank_menu_rx: | 325 do_setup_tank_menu_rx: |
284 setf pairing_slot ; prime slot number with 255 aka -1, used in pairing function | 326 setf pairing_slot ; prime slot number with 255 aka -1, used in pairing function |
285 bsf FLAG_pairing_mode ; in pairing menu (longer timeout) | 327 bsf imprint_xmitter_ID ; in transmitter selection menu (longer timeout) |
286 | 328 |
287 MENU_BEGIN tSetup_Tank, .7 | 329 MENU_BEGIN tSetup_Tank, .7 |
288 MENU_DYNAMIC gaslist_gastitle, 0 | 330 MENU_DYNAMIC gaslist_gastitle, 0 |
289 MENU_DYNAMIC gaslist_tank_id_pres, 0 ; when changing position, adopt TFT_menu_tank_pres! | 331 MENU_DYNAMIC gaslist_tank_id_pres, 0 ; when changing position, adopt TFT_menu_tank_pres! |
290 MENU_DYNAMIC gaslist_tank_size_pres, 0 | 332 MENU_DYNAMIC gaslist_tank_size_pres, 0 |
291 MENU_CALL tTankPairing, gaslist_tank_pairing | 333 MENU_CALL tTankPairing, gaslist_tank_pairing |
292 MENU_CALL tTankSize, gaslist_tank_size | 334 MENU_CALL tTankSize, gaslist_tank_size |
293 MENU_CALL tTankUsablePress, gaslist_tank_pres | 335 MENU_CALL tTankUsablePress, gaslist_tank_pres |
294 MENU_CALL tBack, do_return_edit_gas_menu | 336 MENU_CALL tBack, do_return_edit_gas_menu |
295 MENU_END | 337 MENU_END |
296 | |
297 ENDIF | 338 ENDIF |
298 | 339 |
299 | 340 |
300 do_setup_depth_menu: | 341 do_setup_depth_menu: |
301 | 342 |
320 do_return_demo_planner: | 361 do_return_demo_planner: |
321 call menu_processor_pop ; back to last line | 362 call menu_processor_pop ; back to last line |
322 bra do_planner_common | 363 bra do_planner_common |
323 | 364 |
324 do_planner_menu: | 365 do_planner_menu: |
325 ; to have correct simulator results after mode changes without prior excursion to surfacemode | 366 ; ensure correct simulator results after mode changes without prior excursion to surface mode |
326 call option_save_all | 367 call option_save_all |
327 call restart_set_modes_and_flags | 368 |
328 ; reset dive time/depth to default values | 369 ; reset dive time/depth to default values |
329 lfsr FSR0,odiveInterval | 370 lfsr FSR0,odiveInterval |
330 call option_reset | 371 call option_reset |
331 lfsr FSR0,obottomTime | 372 lfsr FSR0,obottomTime |
332 call option_reset | 373 call option_reset |
334 call option_reset | 375 call option_reset |
335 lfsr FSR0,oSimAGF | 376 lfsr FSR0,oSimAGF |
336 call option_reset | 377 call option_reset |
337 | 378 |
338 do_planner_common: | 379 do_planner_common: |
380 call restart_set_modes_and_flags ; initialize dive mode settings | |
339 movff opt_dive_mode,WREG ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR | 381 movff opt_dive_mode,WREG ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR |
340 dcfsnz WREG,W ; subtract one, became zero? | 382 dcfsnz WREG,W ; subtract one, became zero? |
341 bra do_planner_common_ccr ; YES - use CCR version | 383 bra do_planner_common_ccr ; YES - use CCR version |
342 | 384 |
343 MENU_BEGIN tPlan, .7 | 385 MENU_BEGIN tPlan, .7 |
386 MENU_CALL tBack, do_return_main_menu | 428 MENU_CALL tBack, do_return_main_menu |
387 MENU_END | 429 MENU_END |
388 | 430 |
389 | 431 |
390 do_ppo2_menu: | 432 do_ppo2_menu: |
433 IFDEF _ccr_pscr | |
391 MENU_BEGIN tppO2settings, .6 | 434 MENU_BEGIN tppO2settings, .6 |
392 MENU_DYNAMIC divesets_ppo2_max, do_toggle_ppo2_max | 435 MENU_DYNAMIC divesets_ppo2_max, do_toggle_ppo2_max_work |
393 MENU_DYNAMIC divesets_ppo2_max_deco, do_toggle_ppo2_max_deco | 436 MENU_DYNAMIC divesets_ppo2_max_deco, do_toggle_ppo2_max_deco |
394 MENU_DYNAMIC divesets_ppo2_min, do_toggle_ppo2_min | 437 MENU_DYNAMIC divesets_ppo2_min, do_toggle_ppo2_min |
395 MENU_DYNAMIC divesets_ppo2_min_cc, do_toggle_ppo2_min_cc | 438 MENU_DYNAMIC divesets_ppo2_min_cc, do_toggle_ppo2_min_cc |
396 MENU_OPTION tShowppO2, oShowppO2, 0 | 439 MENU_OPTION tShowppO2, oShowppO2, 0 |
397 MENU_CALL tBack, do_return_divemode_menu | 440 MENU_CALL tBack, do_return_divemode_menu |
398 MENU_END | 441 MENU_END |
442 ELSE | |
443 MENU_BEGIN tppO2settings, .5 | |
444 MENU_DYNAMIC divesets_ppo2_max, do_toggle_ppo2_max_work | |
445 MENU_DYNAMIC divesets_ppo2_max_deco, do_toggle_ppo2_max_deco | |
446 MENU_DYNAMIC divesets_ppo2_min, do_toggle_ppo2_min | |
447 MENU_OPTION tShowppO2, oShowppO2, 0 | |
448 MENU_CALL tBack, do_return_divemode_menu | |
449 MENU_END | |
450 ENDIF | |
399 | 451 |
400 | 452 |
401 do_return_decoparameters_menu: | 453 do_return_decoparameters_menu: |
402 call menu_processor_double_pop ; drop exit line and back to last line | 454 call menu_processor_double_pop ; drop exit line and back to last line |
403 | 455 |
427 MENU_CALL tBack, do_return_divemode_menu | 479 MENU_CALL tBack, do_return_divemode_menu |
428 MENU_END | 480 MENU_END |
429 | 481 |
430 | 482 |
431 do_decoparameters_menu_more: | 483 do_decoparameters_menu_more: |
432 MENU_BEGIN tDecoparameters, .4 | 484 MENU_BEGIN tDecoparameters, .7 |
433 MENU_OPTION tLastDecostop, oLastDeco, 0 | 485 MENU_OPTION tLastDecostop, oLastDeco, 0 |
434 MENU_OPTION tAscentSpeed, oAscentSpeed, 0 | 486 MENU_OPTION tAscentSpeed, oAscentSpeed, 0 |
435 MENU_OPTION tGasChangeTime, oGasChangeTime, 0 | 487 MENU_OPTION tGasChangeTime, oGasChangeTime, 0 |
488 MENU_OPTION tExtendedStops, oExtendedStops, 0 | |
489 MENU_OPTION tTimeoutDive, oDiveTimeout, 0 | |
490 MENU_OPTION tStoreApnoeDive, oStoreApnoeDive, 0 | |
436 MENU_CALL tBack, do_return_decoparameters_menu | 491 MENU_CALL tBack, do_return_decoparameters_menu |
437 MENU_END | 492 MENU_END |
438 | 493 |
439 | 494 |
440 do_2nd_deco_plan_menu: | 495 do_2nd_deco_plan_menu: |
457 | 512 |
458 | 513 |
459 ;============================================================================= | 514 ;============================================================================= |
460 ; Setup Menu | 515 ; Setup Menu |
461 | 516 |
462 do_return_settings_deeper: ; entry point for return from set time/date sub-menu | |
463 bcf settime_setdate ; clear flag | |
464 call menu_processor_pop ; drop one more stack entry | |
465 | |
466 do_return_settings: | 517 do_return_settings: |
518 bcf imprint_time_date ; stop imprinting of current time & date | |
467 call menu_processor_double_pop ; drop exit line and back to last line | 519 call menu_processor_double_pop ; drop exit line and back to last line |
468 IFDEF _rx_mode | 520 IFDEF _rx_mode |
469 bcf FLAG_tr_enabled ; clear TR functions flag by default | 521 bcf tr_functions_activated ; set TR functions as deactivated by default |
470 movff opt_TR_mode,WREG ; get TR functions mode | 522 btfss ostc_rx_present ; TR model / TR module up & running? |
471 tstfsz WREG ; TR functions enabled? | 523 bra do_settings_menu ; NO |
472 bsf FLAG_tr_enabled ; YES | 524 movff opt_TR_mode,WREG ; YES - get TR mode |
525 tstfsz WREG ; - TR mode <> off ? | |
526 bsf tr_functions_activated ; YES - set TR functions as activated | |
473 ENDIF | 527 ENDIF |
474 | 528 |
475 do_settings_menu: | 529 do_settings_menu: |
476 btfsc ble_available ; ble available? | 530 btfsc ble_available ; BLE available? |
477 bra do_settings_menu_ble ; YES | 531 bra do_settings_menu_ble ; YES |
478 | 532 |
479 MENU_BEGIN tSystSets, .5 | 533 MENU_BEGIN tSystSets, .5 |
480 MENU_CALL tInfoMenu, do_info_menu | 534 MENU_CALL tInfoMenu, do_info_menu |
481 MENU_CALL tSetTimeDate, do_date_time_menu | 535 MENU_CALL tSetTimeDate, do_date_time_menu |
484 MENU_CALL tBack, do_return_main_menu | 538 MENU_CALL tBack, do_return_main_menu |
485 MENU_END | 539 MENU_END |
486 | 540 |
487 do_settings_menu_ble: | 541 do_settings_menu_ble: |
488 IFDEF _rx_functions | 542 IFDEF _rx_functions |
489 btfsc ostc_rx_present ; RX model? | 543 btfsc ostc_rx_present ; TR model? |
490 bra do_settings_menu_rx ; YES | 544 bra do_settings_menu_rx ; YES |
491 ENDIF | 545 ENDIF |
492 | 546 |
493 MENU_BEGIN tSystSets, .6 | 547 MENU_BEGIN tSystSets, .6 |
494 MENU_CALL tInfoMenu, do_info_menu | 548 MENU_CALL tInfoMenu, do_info_menu |
495 MENU_CALL tBleTitle, comm_mode0 | 549 MENU_CALL tBleTitle, comm_mode_ble |
496 MENU_CALL tSetTimeDate, do_date_time_menu | 550 MENU_CALL tSetTimeDate, do_date_time_menu |
497 MENU_CALL tDispSets, do_dispsets_menu | 551 MENU_CALL tDispSets, do_dispsets_menu |
498 MENU_CALL tMore, do_settings_menu_more | 552 MENU_CALL tMore, do_settings_menu_more |
499 MENU_CALL tBack, do_return_main_menu | 553 MENU_CALL tBack, do_return_main_menu |
500 MENU_END | 554 MENU_END |
501 | 555 |
502 IFDEF _rx_functions | 556 IFDEF _rx_functions |
503 do_settings_menu_rx: | 557 do_settings_menu_rx: |
504 MENU_BEGIN tSystSets, .7 | 558 MENU_BEGIN tSystSets, .7 |
505 MENU_CALL tInfoMenu, do_info_menu | 559 MENU_CALL tInfoMenu, do_info_menu |
506 MENU_CALL tBleTitle, comm_mode0 | 560 MENU_CALL tBleTitle, comm_mode_ble |
507 MENU_CALL tTrSettings, do_settings_menu_TR | 561 MENU_CALL tTrSettings, do_settings_menu_TR |
508 MENU_CALL tSetTimeDate, do_date_time_menu | 562 MENU_CALL tSetTimeDate, do_date_time_menu |
509 MENU_CALL tDispSets, do_dispsets_menu | 563 MENU_CALL tDispSets, do_dispsets_menu |
510 MENU_CALL tMore, do_settings_menu_more | 564 MENU_CALL tMore, do_settings_menu_more |
511 MENU_CALL tBack, do_return_main_menu | 565 MENU_CALL tBack, do_return_main_menu |
541 MENU_END | 595 MENU_END |
542 ENDIF | 596 ENDIF |
543 | 597 |
544 | 598 |
545 IFDEF _rx_functions | 599 IFDEF _rx_functions |
600 | |
546 do_settings_menu_TR: | 601 do_settings_menu_TR: |
547 movff opt_dive_mode,WREG ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR | 602 movff opt_dive_mode,WREG ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR |
548 incf WREG,W ; add 1 | 603 incf WREG,W ; add 1 |
549 dcfsnz WREG,W ; subtract one, became zero? | 604 dcfsnz WREG,W ; subtract one, became zero? |
550 bra do_settings_menu_TR_MaxDelta; YES - OC | 605 bra do_settings_menu_TR_MaxDelta; YES - OC |
599 movlw max_pres_diff_min ; YES - load minimum value | 654 movlw max_pres_diff_min ; YES - load minimum value |
600 movwf lo ; - into lo | 655 movwf lo ; - into lo |
601 do_toggle_max_pres_diff_1: | 656 do_toggle_max_pres_diff_1: |
602 movff lo,char_I_max_pres_diff ; write back new value | 657 movff lo,char_I_max_pres_diff ; write back new value |
603 return ; done | 658 return ; done |
604 ENDIF | 659 |
660 ENDIF ; _rx_functions | |
605 | 661 |
606 | 662 |
607 do_return_settings_more_deeper: ; entry point for returns from reset sub-menu | 663 do_return_settings_more_deeper: ; entry point for returns from reset sub-menu |
608 call menu_processor_pop ; drop one more stack entry | 664 call menu_processor_pop ; drop one more stack entry |
609 | 665 |
610 do_return_settings_more: | 666 do_return_settings_more: |
611 call menu_processor_double_pop ; drop exit line and back to last line | 667 call menu_processor_double_pop ; drop exit line and back to last line |
612 | 668 |
613 do_settings_menu_more: | 669 do_settings_menu_more: |
614 btfsc battery_gauge_available ; piezo buttons available | 670 btfsc battery_gauge_available ; piezo buttons available? |
615 bra do_settings_menu_more_piezo | 671 bra do_settings_menu_more_piezo ; YES |
616 btfsc ble_available ; ble available | 672 |
617 bra do_settings_menu_more_ostc3p | 673 IFDEF _compass |
618 ; All MENU_CALLs that are | 674 MENU_BEGIN tSystSets, .6 ; All MENU_CALLs |
619 MENU_BEGIN tSystSets, .6 ; in all of this 3 menus | 675 MENU_CALL tCompassMenu, do_compass_menu ; in this menu need to |
620 MENU_CALL tCompassMenu, do_compass_menu ; need to stay together | 676 MENU_CALL tLogOffset, do_log_offset_menu ; stay together on this |
621 MENU_CALL tLogOffset, do_log_offset_menu ; on this menu level in | 677 MENU_OPTION tAltMode, oAltMode, 0 ; menu level in order to |
622 MENU_OPTION tAltMode, oAltMode, 0 ; oder to not mess up the | 678 MENU_OPTION tDvSalinity, oDiveSalinity, 0 ; not mess up the menu |
623 MENU_OPTION tDvSalinity, oDiveSalinity, 0 ; menu stack on doing the | 679 MENU_CALL tResetMenu, do_reset_menu ; stack on doing the |
624 MENU_CALL tResetMenu, do_reset_menu ; do_return_settings ! | 680 MENU_CALL tBack, do_return_settings ; do_return_settings ! |
625 MENU_CALL tBack, do_return_settings | 681 MENU_END |
626 MENU_END | 682 ELSE |
683 MENU_BEGIN tSystSets, .5 ; see above | |
684 MENU_CALL tLogOffset, do_log_offset_menu ; | |
685 MENU_OPTION tAltMode, oAltMode, 0 ; | |
686 MENU_OPTION tDvSalinity, oDiveSalinity, 0 ; | |
687 MENU_CALL tResetMenu, do_reset_menu ; | |
688 MENU_CALL tBack, do_return_settings ; | |
689 MENU_END | |
690 ENDIF ; _compass | |
627 | 691 |
628 | 692 |
629 do_return_settings_menu_more_pz: | 693 do_return_settings_menu_more_pz: |
630 call TFT_ClearScreen | 694 call TFT_ClearScreen |
631 call piezo_config ; configure buttons | 695 call piezo_config ; configure buttons |
632 call menu_processor_double_pop ; drop exit line and back to last line | 696 call menu_processor_double_pop ; drop exit line and back to last line |
633 | 697 |
634 do_settings_menu_more_piezo: | 698 do_settings_menu_more_piezo: |
699 IFDEF _compass | |
635 MENU_BEGIN tSystSets, .7 | 700 MENU_BEGIN tSystSets, .7 |
636 MENU_CALL tCompassMenu, do_compass_menu ; see above | 701 MENU_CALL tCompassMenu, do_compass_menu ; see above |
637 MENU_CALL tLogOffset, do_log_offset_menu ; | 702 MENU_CALL tLogOffset, do_log_offset_menu ; |
638 MENU_OPTION tAltMode, oAltMode, 0 | 703 MENU_OPTION tAltMode, oAltMode, 0 ; |
639 MENU_OPTION tDvSalinity, oDiveSalinity, 0 | 704 MENU_OPTION tDvSalinity, oDiveSalinity, 0 ; |
640 MENU_CALL tResetMenu, do_reset_menu ; | 705 MENU_CALL tResetMenu, do_reset_menu ; |
641 MENU_CALL tMore, do_settings_piezo_menu ; | 706 MENU_CALL tMore, do_settings_piezo_menu ; |
642 MENU_CALL tBack, do_return_settings | 707 MENU_CALL tBack, do_return_settings ; |
643 MENU_END | 708 MENU_END |
644 | 709 ELSE |
645 do_settings_menu_more_ostc3p: ; menu with BLE feature | |
646 MENU_BEGIN tSystSets, .6 | 710 MENU_BEGIN tSystSets, .6 |
647 MENU_CALL tCompassMenu, do_compass_menu ; see above | 711 MENU_CALL tLogOffset, do_log_offset_menu ; see above |
648 MENU_CALL tLogOffset, do_log_offset_menu ; | 712 MENU_OPTION tAltMode, oAltMode, 0 ; |
649 MENU_OPTION tAltMode, oAltMode, 0 | 713 MENU_OPTION tDvSalinity, oDiveSalinity, 0 ; |
650 MENU_OPTION tDvSalinity, oDiveSalinity, 0 | |
651 MENU_CALL tResetMenu, do_reset_menu ; | 714 MENU_CALL tResetMenu, do_reset_menu ; |
652 MENU_CALL tBack, do_return_settings | 715 MENU_CALL tMore, do_settings_piezo_menu ; |
653 MENU_END | 716 MENU_CALL tBack, do_return_settings ; |
717 MENU_END | |
718 ENDIF | |
654 | 719 |
655 | 720 |
656 do_settings_piezo_menu: | 721 do_settings_piezo_menu: |
657 ; Menu with features only available in piezo button hardware | 722 ; Menu with features only available in piezo button hardware |
658 MENU_BEGIN tSystSets, .3 | 723 MENU_BEGIN tSystSets, .3 |
660 MENU_OPTION tButtonright, ocR_button_right, 0 ; right button sensitivity | 725 MENU_OPTION tButtonright, ocR_button_right, 0 ; right button sensitivity |
661 MENU_CALL tBack, do_return_settings_menu_more_pz | 726 MENU_CALL tBack, do_return_settings_menu_more_pz |
662 MENU_END | 727 MENU_END |
663 | 728 |
664 | 729 |
730 IFDEF _compass | |
731 | |
665 do_compass_menu: | 732 do_compass_menu: |
666 MENU_BEGIN tSystSets, .5 | 733 MENU_BEGIN tSystSets, .5 |
667 MENU_CALL tCompassMenu, compass_calibration_loop ; exits to surfloop | 734 MENU_CALL tCompassMenu, compass_calibration_loop ; exits to surface loop |
668 ; MENU_OPTION tCompassGain, oCompassGain, 0 | 735 ; MENU_OPTION tCompassGain, oCompassGain, 0 |
669 MENU_DYNAMIC menu_cal_x, 0 | 736 MENU_DYNAMIC menu_cal_x, 0 |
670 MENU_DYNAMIC menu_cal_y, 0 | 737 MENU_DYNAMIC menu_cal_y, 0 |
671 MENU_DYNAMIC menu_cal_z, 0 | 738 MENU_DYNAMIC menu_cal_z, 0 |
672 MENU_CALL tBack, do_return_settings_more | 739 MENU_CALL tBack, do_return_settings_more |
673 MENU_END | 740 MENU_END |
674 | 741 |
742 ENDIF ; _compass | |
743 | |
675 | 744 |
676 ;============================================================================= | 745 ;============================================================================= |
677 ; Reset and confirmation menu | 746 ; Reset and confirmation menu |
678 | 747 |
679 do_reset_menu: | 748 do_reset_menu: |
680 MENU_BEGIN tResetMenu, .6 | 749 MENU_BEGIN tResetMenu, .6 |
681 MENU_CALL tBack, do_return_settings_more | 750 MENU_CALL tBack, do_return_settings_more |
682 MENU_CALL tReboot, do_reset_menu2 ; confirm | 751 MENU_CALL tReboot, do_reset_menu_reboot ; confirm |
683 MENU_CALL tResetDeco, do_reset_menu3 ; confirm | 752 MENU_CALL tResetDeco, do_reset_menu_deco ; confirm |
684 MENU_CALL tResetSettings, do_reset_menu4 ; confirm | 753 MENU_CALL tResetSettings, do_reset_menu_settings ; confirm |
685 MENU_CALL tResetLogbook, do_reset_menu5 ; confirm | 754 MENU_CALL tResetLogbook, do_reset_menu_logbook ; confirm |
686 MENU_CALL tResetBattery, do_new_battery_menu ; confirm | 755 MENU_CALL tResetBattery, do_new_battery_menu ; confirm |
687 MENU_END | 756 MENU_END |
688 | 757 |
689 do_reset_menu2: | 758 do_reset_menu_reboot: |
690 MENU_BEGIN tResetMenu2, .2 | 759 MENU_BEGIN tResetMenu2, .2 |
691 MENU_CALL tAbort, do_return_settings_more_deeper | 760 MENU_CALL tAbort, do_return_settings_more_deeper |
692 MENU_CALL tReboot, do_reboot ; reboot | 761 MENU_CALL tReboot, do_reboot ; reboot (cold start) |
693 MENU_END | 762 MENU_END |
694 | 763 |
695 do_reset_menu3: | 764 do_reset_menu_deco: |
696 MENU_BEGIN tResetMenu2, .2 | 765 MENU_BEGIN tResetMenu2, .2 |
697 MENU_CALL tAbort, do_return_settings_more_deeper | 766 MENU_CALL tAbort, do_return_settings_more_deeper |
698 MENU_CALL tResetDeco, do_reset_deco ; reset deco | 767 MENU_CALL tResetDeco, do_reset_deco ; reset deco and return to main reset menu |
699 MENU_END | 768 MENU_END |
700 | 769 |
701 do_reset_menu4: | 770 do_reset_menu_settings: |
702 MENU_BEGIN tResetMenu2, .2 | 771 MENU_BEGIN tResetMenu2, .2 |
703 MENU_CALL tAbort, do_return_settings_more_deeper | 772 MENU_CALL tAbort, do_return_settings_more_deeper |
704 MENU_CALL tResetSettings, do_reset_settings ; reset all settings | 773 MENU_CALL tResetSettings, do_reset_settings ; reset all settings and go to surface mode |
705 MENU_END | 774 MENU_END |
706 | 775 |
707 do_reset_menu5: | 776 do_reset_menu_logbook: |
708 MENU_BEGIN tResetMenu2, .2 | 777 MENU_BEGIN tResetMenu2, .2 |
709 MENU_CALL tAbort, do_return_settings_more_deeper | 778 MENU_CALL tAbort, do_return_settings_more_deeper |
710 MENU_CALL tResetLogbook, do_reset_logbook ; reset logbook | 779 MENU_CALL tResetLogbook, do_reset_logbook ; reset logbook and return to main reset menu |
711 MENU_END | 780 MENU_END |
712 | 781 |
713 | 782 |
714 do_reset_logbook: | 783 do_reset_logbook: |
715 clrf EEADRH ; make sure to select EEPROM bank 0 | 784 clrf EEADRH ; make sure to select EEPROM bank 0 |
727 call ext_flash_erase_logbook ; and complete logbook | 796 call ext_flash_erase_logbook ; and complete logbook |
728 bra do_return_settings_more_deeper | 797 bra do_return_settings_more_deeper |
729 | 798 |
730 | 799 |
731 do_reset_deco: | 800 do_reset_deco: |
732 SAFE_2BYTE_COPY last_surfpressure_30min,int_I_pres_respiration ; copy surface pressure to deco routine | 801 call deco_clear_tissue ; set all tissues to absolute pressure * N2_ratio (C-code) |
733 SAFE_2BYTE_COPY last_surfpressure_30min,int_I_pres_surface ; copy surface pressure to deco routine | 802 call deco_calc_dive_interval_1min ; update tissues by 1 minute to calculate current GF factor (C-code) |
734 | 803 call deco_calc_desaturation_time ; calculate desaturation and no-fly/no-altitude time (C-code) |
735 call deco_clear_tissue ; set all tissues to Pamb * N2_ratio (C-Code) | |
736 call deco_calc_dive_interval_1min; calculate deco in surface mode | |
737 call deco_calc_desaturation_time ; calculate desaturation and no-fly time | |
738 banksel common | 804 banksel common |
805 call vault_decodata_into_eeprom ; store updated deco data to EEPROM | |
739 bra do_return_settings_more_deeper | 806 bra do_return_settings_more_deeper |
740 | 807 |
741 | 808 |
742 do_reset_settings: | 809 do_reset_settings: |
743 call TFT_ClearScreen ; clear screen | 810 call TFT_ClearScreen ; clear screen |
744 call option_reset_all ; reset all options to factory default | 811 call option_reset_all ; reset all options to factory default |
745 goto restart ; restart into surfacemode | 812 call do_logoffset_reset ; reset log offset |
813 goto restart ; restart into surface mode | |
746 | 814 |
747 do_reboot: | 815 do_reboot: |
748 call ext_flash_enable_protection ; enables write protection | 816 call ext_flash_enable_protection ; set write protection on external EEPROM |
817 call rtc_init ; reset the real time clock (will reset to firmware creation date) | |
749 reset | 818 reset |
750 | 819 |
820 do_return_date_time_menu: | |
821 call menu_processor_double_pop ; drop exit line and back to last line | |
751 | 822 |
752 do_date_time_menu: | 823 do_date_time_menu: |
824 bsf imprint_time_date ; start imprinting current time & date | |
825 bcf block_option_value ; allow display of option values again | |
826 | |
753 MENU_BEGIN tSetTimeDate, .4 | 827 MENU_BEGIN tSetTimeDate, .4 |
754 MENU_CALL tSetTime, do_time_menu | 828 MENU_CALL tSetTime, do_time_menu |
755 MENU_CALL tSetDate, do_date_menu | 829 MENU_CALL tSetDate, do_date_menu |
756 MENU_OPTION tDateFormat, oDateFormat, 0 | 830 MENU_OPTION tDateFormat, oDateFormat, 0 |
757 MENU_CALL tBack, do_return_settings | 831 MENU_CALL tBack, do_return_settings |
758 MENU_END | 832 MENU_END |
759 | 833 |
760 | 834 |
761 do_date_menu: | 835 do_date_menu: |
762 bsf settime_setdate | 836 bsf block_option_value ; suspend display of option values |
763 | 837 |
764 MENU_BEGIN tSetDate, .4 | 838 MENU_BEGIN tSetDate, .4 |
765 MENU_OPTION tSetDay, oSetDay, 0 | 839 MENU_OPTION tSetDay, oSetDay, 0 |
766 MENU_OPTION tSetMonth, oSetMonth, 0 | 840 MENU_OPTION tSetMonth, oSetMonth, 0 |
767 MENU_OPTION tSetYear, oSetYear, 0 | 841 MENU_OPTION tSetYear, oSetYear, 0 |
768 MENU_CALL tBack, do_return_settings_deeper | 842 MENU_CALL tBack, do_return_date_time_menu |
769 MENU_END | 843 MENU_END |
770 | 844 |
771 | |
772 do_reset_seconds: | |
773 clrf secs | |
774 call rtc_set_rtc ; writes mins, sec, hours, day, month and year to RTC module | |
775 call menu_processor_pop ; clear the MENU_CALL for do_reset_seconds from the stack | |
776 ;bra do_time_menu ; direct jump-back into the menu | |
777 | 845 |
778 do_time_menu: | 846 do_time_menu: |
779 bsf settime_setdate | 847 bsf block_option_value ; suspend display of option values |
780 | 848 |
781 MENU_BEGIN tSetTime, .4 | 849 MENU_BEGIN tSetTime, .4 |
782 MENU_OPTION tSetHours, oSetHours, 0 | 850 MENU_OPTION tSetHours, oSetHours, 0 |
783 MENU_OPTION tSetMinutes, oSetMinutes, 0 | 851 MENU_OPTION tSetMinutes, oSetMinutes, 0 |
784 MENU_CALL tSetSeconds, do_reset_seconds | 852 MENU_OPTION tSetSeconds, oClearSeconds, 0 |
785 MENU_CALL tBack, do_return_settings_deeper | 853 MENU_CALL tBack, do_return_date_time_menu |
786 MENU_END | 854 MENU_END |
787 | 855 |
788 | 856 |
789 do_toggle_ppo2_max: ; add 0.1 bar, with hard-coded max. | 857 do_toggle_ppo2_max_work: ; add 0.1 bar, with hard-coded max. |
790 movff char_I_ppO2_max,lo ; banksafe | 858 movff char_I_ppO2_max_work,lo ; bank-safe copy |
791 movlw .10 | 859 movlw .10 |
792 addwf lo,F | 860 addwf lo,F |
793 movlw ppo2_warning_high_highest | 861 movlw ppo2_warning_high_highest |
794 cpfsgt lo | 862 cpfsgt lo |
795 bra do_toggle_ppo2_max2 | 863 bra do_toggle_ppo2_max2 |
796 movlw ppo2_warning_high_lowest | 864 movlw ppo2_warning_high_lowest |
797 movwf lo | 865 movwf lo |
798 do_toggle_ppo2_max2: | 866 do_toggle_ppo2_max2: |
799 movff lo,char_I_ppO2_max | 867 movff lo,char_I_ppO2_max_work |
800 return | 868 return |
801 | 869 |
802 do_toggle_ppo2_max_deco: ; add 0.1 bar, with hard-coded max. | 870 do_toggle_ppo2_max_deco: ; add 0.1 bar, with hard-coded max. |
803 movff char_I_ppO2_max_deco,lo ; banksafe | 871 movff char_I_ppO2_max_deco,lo ; bank-safe copy |
804 movlw .10 | 872 movlw .10 |
805 addwf lo,F | 873 addwf lo,F |
806 movlw ppo2_warning_deco_highest | 874 movlw ppo2_warning_deco_highest |
807 cpfsgt lo | 875 cpfsgt lo |
808 bra do_toggle_ppo2_max_deco2 | 876 bra do_toggle_ppo2_max_deco2 |
811 do_toggle_ppo2_max_deco2: | 879 do_toggle_ppo2_max_deco2: |
812 movff lo,char_I_ppO2_max_deco | 880 movff lo,char_I_ppO2_max_deco |
813 return | 881 return |
814 | 882 |
815 do_toggle_ppo2_min: ; sub 0.1 bar, with hard-coded min. | 883 do_toggle_ppo2_min: ; sub 0.1 bar, with hard-coded min. |
816 movff char_I_ppO2_min,lo ; banksafe | 884 movff char_I_ppO2_min,lo ; bank-safe copy |
817 incf lo,F | 885 incf lo,F |
818 movlw ppo2_warning_low_highest | 886 movlw ppo2_warning_low_highest |
819 cpfsgt lo | 887 cpfsgt lo |
820 bra do_toggle_ppo2_min2 | 888 bra do_toggle_ppo2_min2 |
821 movlw ppo2_warning_low_lowest | 889 movlw ppo2_warning_low_lowest |
823 do_toggle_ppo2_min2: | 891 do_toggle_ppo2_min2: |
824 movff lo,char_I_ppO2_min | 892 movff lo,char_I_ppO2_min |
825 return | 893 return |
826 | 894 |
827 do_toggle_ppo2_min_cc: ; sub 0.1 bar, with hard-coded min. | 895 do_toggle_ppo2_min_cc: ; sub 0.1 bar, with hard-coded min. |
828 movff char_I_ppO2_min_loop,lo ; banksafe | 896 movff char_I_ppO2_min_loop,lo ; bank-safe copy |
829 incf lo,F | 897 incf lo,F |
830 movlw ppo2_warning_loop_highest | 898 movlw ppo2_warning_loop_highest |
831 cpfsgt lo | 899 cpfsgt lo |
832 bra do_toggle_ppo2_min_cc2 | 900 bra do_toggle_ppo2_min_cc2 |
833 movlw ppo2_warning_loop_lowest | 901 movlw ppo2_warning_loop_lowest |
837 return | 905 return |
838 | 906 |
839 | 907 |
840 ; Logbook offset sub-menu | 908 ; Logbook offset sub-menu |
841 do_log_offset_menu: | 909 do_log_offset_menu: |
842 MENU_BEGIN tLogOffset, .6 | 910 |
843 MENU_DYNAMIC TFT_LogOffset_Logtitle, 0 | 911 clrf WREG ; select an initial step size of 1 |
844 MENU_CALL tLogOffsetp1, do_logoffset_plus1 | 912 movff WREG,opt_logoffset_step ; bank-safe write to option variable |
845 MENU_CALL tLogOffsetp10, do_logoffset_plus10 | 913 |
846 MENU_CALL tLogOffsetm1, do_logoffset_minus1 | 914 MENU_BEGIN tLogOffset, .5 |
847 MENU_CALL tLogOffsetm10, do_logoffset_minus10 | 915 MENU_DYNAMIC TFT_LogOffset, 0 |
916 MENU_OPTION tLogOffStepSize, oLogOffsetStep, 0 | |
917 MENU_CALL tLogOffsetplus, do_logoffset_plus | |
918 MENU_CALL tLogOffsetminus, do_logoffset_minus | |
848 MENU_CALL tBack, do_return_settings_more | 919 MENU_CALL tBack, do_return_settings_more |
849 MENU_END | 920 MENU_END |
850 | 921 |
851 | 922 |
852 do_logoffset_minus1: | 923 do_logoffset_common: |
853 call do_logoffset_common_read ; read into lo:hi | 924 call do_logoffset_common_read ; read current offset into mpr+1:mpr+0 |
854 movlw .1 | 925 movff opt_logoffset_step,ul ; get step size: 0=1, 1=10, 2=100, 3=1000 |
855 subwf lo | 926 incf ul,F ; 0...3 -> 1...4 |
856 movlw .0 | 927 clrf mpr+3 ; clear step size, high byte |
857 subwfb hi | 928 movlw .1 ; set a step size of 1 |
858 btfss hi,7 ; < 0 ? | 929 movwf mpr+2 ; copy to step size, low byte |
859 bra do_logoffset_exit ; store and return | 930 dcfsnz ul,F ; ul--, did ul became 0, i.e. step size = 1 ? |
860 clrf lo | 931 return ; YES - done |
861 clrf hi | 932 movlw .10 ; NO - set a step size of 10 |
862 bra do_logoffset_exit ; store and return | 933 movwf mpr+2 ; - copy to step size, low byte |
863 | 934 dcfsnz ul,F ; ul--, did ul became 0, i.e. step size = 10 ? |
864 do_logoffset_minus10: | 935 return ; YES - done |
865 call do_logoffset_common_read ; read into lo:hi | 936 movlw .100 ; NO - set a step size of 100 |
866 movlw .10 | 937 movwf mpr+2 ; - copy to step size, low byte |
867 subwf lo | 938 dcfsnz ul,F ; ul--, did ul became 0, i.e. step size = 100 ? |
868 movlw .0 | 939 return ; YES - done |
869 subwfb hi | 940 movlw LOW .1000 ; NO - set a step size of 1000, low byte |
870 btfss hi,7 ; < 0 ? | 941 movwf mpr+2 ; - copy to step size, low byte |
871 bra do_logoffset_exit ; store and return | 942 movlw HIGH .1000 ; - set a step size of 1000, high byte |
872 clrf lo | 943 movwf mpr+3 ; - copy to step size, high byte |
873 clrf hi | 944 return ; - done |
874 bra do_logoffset_exit ; store and return | 945 |
875 | 946 do_logoffset_plus: |
876 do_logoffset_plus1: | 947 rcall do_logoffset_common ; load current offset and step size |
877 call do_logoffset_common_read ; read into lo:hi | 948 ; add step size to current offset |
878 infsnz lo,F | 949 movf mpr+2,W ; get step size, low byte |
879 incf hi,F | 950 addwf mpr+0,F ; add to offset, low byte |
880 bra do_logoffset_exit ; store and return | 951 movf mpr+3,W ; get step size, high byte |
881 | 952 addwfc mpr+1,F ; add to offset, high byte, considering carry flag |
882 do_logoffset_plus10: | 953 ; check if new offset is within limit |
883 call do_logoffset_common_read ; read into lo:hi | 954 MOVLI .9999,sub_a ; load max limit into sub_a |
884 movlw .10 | 955 MOVII mpr, sub_b ; copy new offset into sub_b |
885 addwf lo | 956 call cmpU16 ; compute sub_a - sub_b, setting neg_flag if result becomes negative |
886 movlw .0 | 957 btfss neg_flag ; neg_flag set, i.e. new offset > 9999 ? |
887 addwfc hi | 958 bra do_logoffset_exit ; NO - store offset and return |
959 MOVLI .9999,mpr ; YES - limit offset to 9999 | |
960 bra do_logoffset_exit ; - store offset and return | |
961 | |
962 do_logoffset_minus: | |
963 rcall do_logoffset_common ; load current offset and step size | |
964 ; subtract step size from current offset | |
965 movf mpr+2,W ; get step size, low byte | |
966 subwf mpr+0,F ; subtract from offset, low byte | |
967 movf mpr+3,W ; get step size, high byte | |
968 subwfb mpr+1,F ; subtract from offset, high byte, considering borrow flag | |
969 ; check if new offset is within limit | |
970 btfsc STATUS,C ; borrow to propagate (B == /CARRY) ? | |
971 bra do_logoffset_exit ; NO - result >= 0, store and return | |
972 do_logoffset_reset: | |
973 clrf mpr+0 ; YES - revert offset to 0, low byte | |
974 clrf mpr+1 ; - ... high byte | |
975 ;bra do_logoffset_exit ; - store offset and return | |
976 | |
888 do_logoffset_exit: | 977 do_logoffset_exit: |
889 goto do_logoffset_common_write ; store and return | 978 goto do_logoffset_common_write ; store offset and return |
979 | |
890 | 980 |
891 do_return_dispsets_menu: | 981 do_return_dispsets_menu: |
892 bcf in_color_menu | 982 bcf imprint_color_schemes ; not in color schemes menu any more |
893 call menu_processor_double_pop ; drop exit line and back to last line | 983 call menu_processor_double_pop ; drop exit line and back to last line |
894 | 984 |
895 do_dispsets_menu: | 985 do_dispsets_menu: |
896 | |
897 IF _language_2!=none | 986 IF _language_2!=none |
898 MENU_BEGIN tDispSets, .7 | 987 MENU_BEGIN tDispSets, .7 |
899 MENU_OPTION tBright, oBrightness, 0 | 988 MENU_OPTION tBright, oBrightness, 0 |
900 MENU_OPTION tLanguage, oLanguage, 0 | 989 MENU_OPTION tLanguage, oLanguage, 0 |
901 MENU_OPTION tUnits, oUnits, 0 | 990 MENU_OPTION tUnits, oUnits, 0 |
915 MENU_END | 1004 MENU_END |
916 ENDIF | 1005 ENDIF |
917 | 1006 |
918 | 1007 |
919 do_dispsets_menu_more: | 1008 do_dispsets_menu_more: |
1009 IFDEF _helium | |
920 MENU_BEGIN tDispSets, .7 | 1010 MENU_BEGIN tDispSets, .7 |
921 MENU_OPTION tMODwarning, oMODwarning, 0 | 1011 MENU_OPTION tMODwarning, oMODwarning, 0 |
922 MENU_OPTION tIBCDwarning, oEnable_IBCD, 0 | 1012 ; MENU_OPTION tIBCDwarning, oEnable_IBCD, 0 ; taken out in favor of option oLayout |
923 MENU_OPTION tVSItext2, oVSItextv2, 0 | 1013 MENU_OPTION tVSItext2, oVSItextv2, 0 |
924 MENU_OPTION tVSIgraph, oVSIgraph, 0 | 1014 MENU_OPTION tVSIgraph, oVSIgraph, 0 |
925 MENU_OPTION tTimeoutDive, oDiveTimeout, 0 | 1015 MENU_OPTION tLayout, oLayout, 0 |
1016 MENU_OPTION t2ndDepth, o2ndDepthDisp, 0 | |
1017 MENU_OPTION tTissueGraphics, oTissueGraphics, 0 | |
1018 MENU_CALL tBack, do_return_dispsets_menu | |
1019 MENU_END | |
1020 ELSE | |
1021 MENU_BEGIN tDispSets, .6 | |
1022 MENU_OPTION tMODwarning, oMODwarning, 0 | |
1023 ; MENU_OPTION tIBCDwarning, oEnable_IBCD, 0 ; taken out in favor of option oLayout | |
1024 MENU_OPTION tVSItext2, oVSItextv2, 0 | |
1025 MENU_OPTION tVSIgraph, oVSIgraph, 0 | |
1026 MENU_OPTION tLayout, oLayout, 0 | |
926 MENU_OPTION t2ndDepth, o2ndDepthDisp, 0 | 1027 MENU_OPTION t2ndDepth, o2ndDepthDisp, 0 |
927 MENU_CALL tBack, do_return_dispsets_menu | 1028 MENU_CALL tBack, do_return_dispsets_menu |
928 MENU_END | 1029 MENU_END |
1030 ENDIF | |
929 | 1031 |
930 | 1032 |
931 do_color_scheme: | 1033 do_color_scheme: |
932 bsf in_color_menu | 1034 bsf imprint_color_schemes ; in color schemes menu |
933 | 1035 |
934 MENU_BEGIN tColorScheme, .2 | 1036 MENU_BEGIN tColorScheme, .2 |
935 MENU_OPTION tColorSetDive, oColorSetDive, 0 | 1037 MENU_OPTION tColorSetDive, oColorSetDive, 0 |
936 MENU_CALL tBack, do_return_dispsets_menu | 1038 MENU_CALL tBack, do_return_dispsets_menu |
937 MENU_END | 1039 MENU_END |
940 ;============================================================================= | 1042 ;============================================================================= |
941 | 1043 |
942 do_new_battery_menu: | 1044 do_new_battery_menu: |
943 MENU_BEGIN tNewBattTitle, .2 | 1045 MENU_BEGIN tNewBattTitle, .2 |
944 MENU_CALL tAbort, do_return_settings_more_deeper | 1046 MENU_CALL tAbort, do_return_settings_more_deeper |
945 MENU_CALL tYes, do_new_battery_select | 1047 MENU_CALL tYes, do_new_battery_select_1 |
946 MENU_END | 1048 MENU_END |
1049 | |
947 | 1050 |
948 global do_new_battery_select | 1051 global do_new_battery_select |
949 do_new_battery_select: | 1052 do_new_battery_select: |
1053 call TFT_boot ; initialize TFT (includes clear screen) | |
1054 call TFT_Display_FadeIn ; dim up the display | |
1055 call menu_processor_reset ; reset menu stack | |
1056 | |
1057 do_new_battery_select_1: | |
1058 ; make sure to reset battery percentage | |
1059 movlw .100 | |
1060 movwf batt_percent ; set battery level to full | |
1061 | |
1062 ; default (in cases of timeout or USB): use old battery | |
1063 call retrieve_battery_registers ; retrieve stored battery gauge value from EEPROM | |
950 | 1064 |
951 IFDEF _screendump | 1065 IFDEF _screendump |
952 bsf enable_screen_dumps ; to prevent exiting into COMM mode immediately | 1066 bsf screen_dump_avail ; enable screen dump function to prevent exiting into COMM mode immediately |
953 ELSE | 1067 ELSE |
954 bsf disable_comm_mode ; to prevent exiting into COMM mode immediately | 1068 bsf comm_mode_disabled ; disable COMM mode to prevent exiting into COMM mode immediately |
955 ENDIF | 1069 ENDIF |
956 | 1070 |
957 call TFT_boot ; initialize TFT (includes clear screen) | 1071 ; hardware descriptor: user changeable battery charger supported battery types |
958 call TFT_Display_FadeIn ; switch on backlight | |
959 movlw .100 | |
960 movwf batt_percent ; make sure to reset batt_percent | |
961 | |
962 ; Default (in cases of timeout or USB): use old battery | |
963 clrf EEADRH | |
964 read_int_eeprom 0x07 | |
965 movff EEDATA,battery_gauge+0 | |
966 read_int_eeprom 0x08 | |
967 movff EEDATA,battery_gauge+1 | |
968 read_int_eeprom 0x09 | |
969 movff EEDATA,battery_gauge+2 | |
970 read_int_eeprom 0x0A | |
971 movff EEDATA,battery_gauge+3 | |
972 read_int_eeprom 0x0B | |
973 movff EEDATA,battery_gauge+4 | |
974 read_int_eeprom 0x0C | |
975 movff EEDATA,battery_gauge+5 | |
976 | |
977 call menu_processor_reset ; restart from first item | |
978 | |
979 ; hardware_flag1: battery changeable by user charger supported battery types | |
980 ; ------------------------------------------------------------------------------------------------------------------------------------------------------- | 1072 ; ------------------------------------------------------------------------------------------------------------------------------------------------------- |
981 ; 0x11: BLE and battery gauge ---> OSTC 2 (old model ) NO YES internal 18650 | 1073 ; 0x11: BLE and battery gauge ---> OSTC 2 (old model) NO YES internal 18650 |
982 ; 0x05: analog input and battery gauge ---> OSTC 2 cR NO YES internal 18650 | 1074 ; 0x05: analog input and battery gauge ---> OSTC 2 cR NO YES internal 18650 |
983 ; 0x33: BLE and xmitter input and ambient sensor and battery gauge ---> OSTC 2 TR NO YES internal 16650 | 1075 ; 0x33: BLE and RX module and ambient sensor and battery gauge ---> OSTC 2 TR NO YES internal 16650 |
984 ; 0x13: BLE and ambient sensor and battery gauge -+-> OSTC 2 (new model ) NO YES internal 16650 | 1076 ; 0x13: BLE and ambient sensor and battery gauge -+-> OSTC 2 (new model) NO YES internal 16650 |
985 ; +-> OSTC Plus YES YES 1.5V ----- NO! ----- 3.6V rechargeable | 1077 ; +-> OSTC Plus YES YES 1.5V ----- NO! ----- 3.6V rechargeable |
986 ; 0x12; BLE and ambient sensor ---> OSTC Sport (both models) YES NO 1.5V 3.6V disposable 3.6V rechargeable | 1078 ; 0x0A: optical input and ambient sensor ---> OSTC 3 (USB model) YES NO 1.5V 3.6V disposable 3.6V rechargeable |
987 ; 0x0A: optical input and ambient sensor ---> OSTC 3 /USB YES NO 1.5V 3.6V disposable 3.6V rechargeable | 1079 ; 0x1A: BLE and optical input and ambient sensor ---> OSTC 3 (BLE model) YES NO 1.5V 3.6V disposable 3.6V rechargeable |
988 ; 0x02: ambient sensor ---> OSTC sport /USB YES NO 1.5V 3.6V disposable 3.6V rechargeable | 1080 ; 0x02: ambient sensor ---> OSTC Sport (USB model) YES NO 1.5V 3.6V disposable 3.6V rechargeable |
989 ; 0x1A: BLE and optical input and ambient sensor ---> OSTC 3 /BLE YES NO 1.5V 3.6V disposable 3.6V rechargeable | 1081 ; 0x52: BLE and ambient sensor and low volt core ---> OSTC Sport (BLE model) YES NO 1.5V 3.6V disposable 3.6V rechargeable |
990 | 1082 |
991 | 1083 |
992 movlw 0x0A ; OSTC 3 /USB | 1084 movlw 0x11 ; OSTC 2 (old model) |
993 cpfseq hardware_flag1 | 1085 cpfseq HW_descriptor |
994 bra $+4 | 1086 bra $+4 |
995 bra menu_new_battery_AA | 1087 bra use_18650_battery |
996 | 1088 |
997 movlw 0x02 ; OSTC Sport (USB model) | 1089 movlw 0x05 ; OSTC 2 cR |
998 cpfseq hardware_flag1 | 1090 cpfseq HW_descriptor |
999 bra $+4 | |
1000 bra menu_new_battery_AA | |
1001 | |
1002 movlw 0x13 ; OSTC 2 and Plus | |
1003 cpfseq hardware_flag1 | |
1004 bra $+4 | 1091 bra $+4 |
1005 bra menu_new_battery_AA_16650 | 1092 bra use_18650_battery |
1006 | 1093 |
1007 movlw 0x33 ; OSTC 2 TR | 1094 movlw 0x33 ; OSTC 2 TR |
1008 cpfseq hardware_flag1 | 1095 cpfseq HW_descriptor |
1009 bra $+4 | 1096 bra $+4 |
1010 bra menu_new_battery_AA_16650 | 1097 bra use_16650_battery |
1011 | 1098 |
1012 movlw 0x12 ; OSTC Sport | 1099 ; movlw 0xXX ; OSTC 2 (new model) TODO: define signature |
1013 cpfseq hardware_flag1 | 1100 ; cpfseq HW_descriptor |
1101 ; bra $+4 | |
1102 ; bra use_16650_battery | |
1103 | |
1104 movlw 0x13 ; OSTC Plus TODO: and OSTC 2 new model as of now | |
1105 cpfseq HW_descriptor | |
1014 bra $+4 | 1106 bra $+4 |
1015 bra menu_new_battery_AA | 1107 bra menu_new_battery_AA_charger |
1016 | 1108 |
1017 movlw 0x1A ; OSTC 3 /BLE | 1109 ; movlw 0x0A ; OSTC 3 (USB model) |
1018 cpfseq hardware_flag1 | 1110 ; cpfseq HW_descriptor |
1019 bra $+4 | 1111 ; bra $+4 |
1020 bra menu_new_battery_AA | 1112 ; bra menu_new_battery_AA_no_charger |
1021 | 1113 |
1022 movlw 0x11 ; OSTC 2 (old model) | 1114 ; movlw 0x1A ; OSTC 3 (BLE model) |
1023 cpfseq hardware_flag1 | 1115 ; cpfseq HW_descriptor |
1024 bra $+4 | 1116 ; bra $+4 |
1025 bra menu_new_battery_18650 | 1117 ; bra menu_new_battery_AA_no_charger |
1026 | 1118 |
1027 movlw 0x05 ; OSTC 2 cR | 1119 ; movlw 0x02 ; OSTC Sport (USB model) |
1028 cpfseq hardware_flag1 | 1120 ; cpfseq HW_descriptor |
1029 bra $+4 | 1121 ; bra $+4 |
1030 bra menu_new_battery_18650 | 1122 ; bra menu_new_battery_AA_no_charger |
1031 | 1123 |
1032 bra use_old_batteries ; any unsupported value | 1124 ; movlw 0x52 ; OSTC Sport (BLE model) |
1033 | 1125 ; cpfseq HW_descriptor |
1034 | 1126 ; bra $+4 |
1035 do_return_menu_new_bat_AA_16650: | 1127 ; bra menu_new_battery_AA_no_charger |
1128 | |
1129 bra menu_new_battery_AA_no_charger ; any other model | |
1130 | |
1131 | |
1132 do_return_menu_new_bat_AA_chrg: | |
1036 call menu_processor_double_pop ; drop exit line and back to last line | 1133 call menu_processor_double_pop ; drop exit line and back to last line |
1037 | 1134 |
1038 ; OSTC 2, TR and Plus | 1135 ; OSTC Plus (charging function) TODO: and OSTC 2 new model as of now |
1039 menu_new_battery_AA_16650: | 1136 menu_new_battery_AA_charger: |
1040 MENU_BEGIN tNewBattTitle, .4 | |
1041 MENU_CALL tNewBattOld, use_old_batteries | |
1042 MENU_CALL tNewBattNew15, use_new_15V_batteries ; OSTC Plus : not rechargeable | |
1043 ; MENU_CALL tNewBattNew36, use_new_36V_batteries ; OSTC Plus : not rechargeable -> not allowed any more !!! | |
1044 MENU_CALL tNewBattAccu, pre_36V_rechargeable ; OSTC Plus : rechargeable -> goto safety question | |
1045 MENU_CALL tNew16650, use_16650_battery ; OSTC 2, TR: rechargeable | |
1046 MENU_END | |
1047 | |
1048 ; OSTC 3 and Sport (no charging function) | |
1049 menu_new_battery_AA: | |
1050 MENU_BEGIN tNewBattTitle, .4 | 1137 MENU_BEGIN tNewBattTitle, .4 |
1051 MENU_CALL tNewBattOld, use_old_batteries | 1138 MENU_CALL tNewBattOld, use_old_batteries |
1052 MENU_CALL tNewBattNew15, use_new_15V_batteries ; not rechargeable | 1139 MENU_CALL tNewBattNew15, use_new_15V_batteries ; not rechargeable |
1053 MENU_CALL tNewBattNew36, use_new_36V_batteries ; not rechargeable | 1140 ; MENU_CALL tNewBattNew36, use_36V_disposable ; not rechargeable -> not allowed any more !!! |
1054 MENU_CALL tNewBattAccu, use_36V_rechargeable ; rechargeable | 1141 MENU_CALL tNewBattAccu, pre_36V_rechargeable ; rechargeable -> goto safety question |
1055 MENU_END | 1142 MENU_CALL tNew16650, use_16650_battery ; OSTC 2 new model TODO: remove when OSTC 2 new model can be separated from Plus |
1056 | 1143 MENU_END |
1057 ; OSTC 2 (big housing) and cR | |
1058 menu_new_battery_18650: | |
1059 MENU_BEGIN tNewBattTitle, .2 | |
1060 MENU_CALL tNewBattOld, use_old_batteries | |
1061 MENU_CALL tNew18650, use_18650_battery ; rechargeable | |
1062 MENU_END | |
1063 | |
1064 | 1144 |
1065 pre_36V_rechargeable: | 1145 pre_36V_rechargeable: |
1066 MENU_BEGIN tNewBattTitle, .5 | 1146 MENU_BEGIN tNewBattTitle, .5 |
1067 MENU_CALL tConfirmChargeable1, 0 ; safety question, line 1 | 1147 MENU_CALL tConfirmChargeable1, 0 ; safety question, line 1 |
1068 MENU_CALL tConfirmChargeable2, 0 ; safety question, line 2 | 1148 MENU_CALL tConfirmChargeable2, 0 ; safety question, line 2 |
1069 MENU_CALL tConfirmChargeable3, 0 ; safety question, line 3 | 1149 MENU_CALL tConfirmChargeable3, 0 ; safety question, line 3 |
1070 MENU_CALL tNo, do_return_menu_new_bat_AA_16650 ; NO - go back | 1150 MENU_CALL tNo, do_return_menu_new_bat_AA_chrg ; NO - go back |
1071 MENU_CALL tYes, use_36V_rechargeable ; YES - confirmed rechargeable | 1151 MENU_CALL tYes, use_37V_rechargeable ; YES - confirmed rechargeable |
1152 MENU_END | |
1153 | |
1154 ; OSTC 3 and Sport (no charging function) | |
1155 menu_new_battery_AA_no_charger: | |
1156 MENU_BEGIN tNewBattTitle, .4 | |
1157 MENU_CALL tNewBattOld, use_old_batteries | |
1158 MENU_CALL tNewBattNew15, use_new_15V_batteries ; not rechargeable | |
1159 MENU_CALL tNewBattNew36, use_36V_disposable ; not rechargeable | |
1160 MENU_CALL tNewBattAccu, use_37V_rechargeable ; rechargeable | |
1072 MENU_END | 1161 MENU_END |
1073 | 1162 |
1074 | 1163 |
1075 global use_old_prior_209 | 1164 global use_old_prior_209 |
1076 use_old_prior_209: | 1165 use_old_prior_209: |
1078 read_int_eeprom 0x0F ; =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 | 1167 read_int_eeprom 0x0F ; =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 |
1079 incfsz EEDATA,F ; was 0xFF? | 1168 incfsz EEDATA,F ; was 0xFF? |
1080 return ; NO - done | 1169 return ; NO - done |
1081 | 1170 |
1082 call lt2942_get_status ; check for gauge IC | 1171 call lt2942_get_status ; check for gauge IC |
1083 movlw .3 ; assume a 18650 | 1172 movlw .3 ; Assume a 18650 |
1084 btfss battery_gauge_available ; cR/2 hardware? | 1173 btfss battery_gauge_available ; cR/2 hardware? |
1085 movlw .1 ; assume a Saft | 1174 movlw .1 ; assume a Saft |
1086 movwf EEDATA | 1175 movwf EEDATA |
1087 write_int_eeprom 0x0F ; store the new battery type into EEPROM | 1176 write_int_eeprom 0x0F ; store the new battery type into EEPROM |
1088 return | 1177 return |
1089 | 1178 |
1090 | 1179 |
1091 global use_old_batteries | |
1092 use_old_batteries: | 1180 use_old_batteries: |
1093 clrf EEADRH | 1181 rcall get_battery_data ; load data of old battery |
1094 read_int_eeprom 0x07 | 1182 goto surfloop ; proceed to surface loop |
1095 movff EEDATA,battery_gauge+0 | 1183 |
1096 read_int_eeprom 0x08 | 1184 |
1097 movff EEDATA,battery_gauge+1 | 1185 global get_battery_data |
1098 read_int_eeprom 0x09 | 1186 get_battery_data: |
1099 movff EEDATA,battery_gauge+2 | 1187 call retrieve_battery_registers ; retrieve stored battery gauge value from EEPROM |
1100 read_int_eeprom 0x0A | 1188 movff battery_type,lo ; copy retrieved battery type to lo |
1101 movff EEDATA,battery_gauge+3 | 1189 rcall setup_new_saft ; default battery configuration |
1102 read_int_eeprom 0x0B | 1190 incf lo,F ; (0-4) -> (1-5) |
1103 movff EEDATA,battery_gauge+4 | 1191 dcfsnz lo,F |
1104 read_int_eeprom 0x0C | |
1105 movff EEDATA,battery_gauge+5 | |
1106 read_int_eeprom 0x0F | |
1107 movff EEDATA,battery_type ; =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 | |
1108 | |
1109 rcall setup_new_saft ; set a save default, not rechargeable | |
1110 | |
1111 incf EEDATA,F ; 1...5 | |
1112 dcfsnz EEDATA,F | |
1113 rcall setup_new_15v ; =0 | 1192 rcall setup_new_15v ; =0 |
1114 dcfsnz EEDATA,F | 1193 dcfsnz lo,F |
1115 rcall setup_new_saft ; =1 | 1194 rcall setup_new_saft ; =1 |
1116 dcfsnz EEDATA,F | 1195 dcfsnz lo,F |
1117 rcall setup_new_panasonic ; =2 | 1196 rcall setup_new_panasonic ; =2 |
1118 dcfsnz EEDATA,F | 1197 dcfsnz lo,F |
1119 rcall setup_new_18650 ; =3 | 1198 rcall setup_new_18650 ; =3 |
1120 dcfsnz EEDATA,F | 1199 dcfsnz lo,F |
1121 rcall setup_new_16650 ; =4 | 1200 rcall setup_new_16650 ; =4 |
1122 | |
1123 bcf use_old_batt_flag ; clear flag | 1201 bcf use_old_batt_flag ; clear flag |
1124 | |
1125 IFNDEF _screendump | 1202 IFNDEF _screendump |
1126 bcf disable_comm_mode ; re-enable COMM mode again | 1203 bcf comm_mode_disabled ; re-enable COMM mode again |
1127 ENDIF | 1204 ENDIF |
1128 | 1205 return ; done |
1129 goto surfloop ; jump to surface loop | 1206 |
1130 | 1207 |
1131 | 1208 ; disposable 1.5 Volt Alkaline |
1132 setup_new_15v: | 1209 setup_new_15v: |
1133 bsf charge_disable | 1210 bsf charge_disable ; set charging-inhibit signal |
1134 bcf TRISE,2 | 1211 bcf charge_enable ; activate charging-inhibit signal |
1135 movlw .100 | 1212 movlw .100 |
1136 movwf batt_percent ; to have 1.5V batteries right after firmware update | 1213 movwf batt_percent ; to have 1.5V batteries right after firmware update |
1137 movlw .0 | 1214 movlw .0 |
1138 movff WREG,battery_type | 1215 movwf battery_type |
1139 return | 1216 return |
1140 | 1217 |
1141 | 1218 ; disposable 3.6 Volt Lithium |
1142 setup_new_saft: | 1219 setup_new_saft: |
1143 banksel battery_capacity | 1220 bsf charge_disable ; set charging-inhibit signal |
1144 movlw LOW internal_saft_capacity | 1221 bcf charge_enable ; activate charging-inhibit signal |
1145 movwf internal_battery_capacity+0 | 1222 MOVLI capacity_saft_internal, battery_capacity_internal |
1146 movlw HIGH internal_saft_capacity | 1223 MOVLI capacity_saft, battery_capacity |
1147 movwf internal_battery_capacity+1 | 1224 MOVLI offset_saft, battery_offset |
1148 movlw LOW saft_capacity | |
1149 movwf battery_capacity+0 | |
1150 movlw HIGH saft_capacity | |
1151 movwf battery_capacity+1 | |
1152 movlw LOW saft_offset | |
1153 movwf battery_offset+0 | |
1154 movlw HIGH saft_offset | |
1155 movwf battery_offset+1 | |
1156 banksel common | |
1157 bsf charge_disable | |
1158 bcf TRISE,2 | |
1159 movlw .1 | 1225 movlw .1 |
1160 movff WREG,battery_type | 1226 movwf battery_type |
1161 return | 1227 return |
1162 | 1228 |
1163 | 1229 ; rechargeable user-changeable 3.7 Volt Lithium-ion |
1164 setup_new_panasonic: | 1230 setup_new_panasonic: |
1165 banksel battery_capacity | 1231 bcf charge_disable ; release charging-inhibit signal |
1166 movlw LOW internal_panasonic_capacity | 1232 bsf charge_enable ; tristate charging-inhibit signal |
1167 movwf internal_battery_capacity+0 | 1233 MOVLI capacity_panasonic_internal, battery_capacity_internal |
1168 movlw HIGH internal_panasonic_capacity | 1234 MOVLI capacity_panasonic, battery_capacity |
1169 movwf internal_battery_capacity+1 | 1235 MOVLI offset_panasonic, battery_offset |
1170 movlw LOW panasonic_capacity | |
1171 movwf battery_capacity+0 | |
1172 movlw HIGH panasonic_capacity | |
1173 movwf battery_capacity+1 | |
1174 movlw LOW panasonic_offset | |
1175 movwf battery_offset+0 | |
1176 movlw HIGH panasonic_offset | |
1177 movwf battery_offset+1 | |
1178 banksel common | |
1179 bcf charge_disable | |
1180 bsf TRISE,2 | |
1181 movlw .2 | 1236 movlw .2 |
1182 movff WREG,battery_type | 1237 movwf battery_type |
1183 return | 1238 return |
1184 | 1239 |
1185 | 1240 ; rechargeable internal Lithium-ion |
1186 setup_new_18650: | 1241 setup_new_18650: |
1187 banksel battery_capacity | 1242 bcf charge_disable ; release charging-inhibit signal |
1188 clrf internal_battery_capacity+0 | 1243 bsf charge_enable ; tristate charging-inhibit signal |
1189 clrf internal_battery_capacity+1 | 1244 CLRI battery_capacity_internal |
1190 movlw LOW ncr18650_capacity | 1245 MOVLI capacity_ncr18650, battery_capacity |
1191 movwf battery_capacity+0 | 1246 MOVLI offset_ncr18650, battery_offset |
1192 movlw HIGH ncr18650_capacity | |
1193 movwf battery_capacity+1 | |
1194 movlw LOW ncr18650_offset | |
1195 movwf battery_offset+0 | |
1196 movlw HIGH ncr18650_offset | |
1197 movwf battery_offset+1 | |
1198 banksel common | |
1199 bcf charge_disable | |
1200 bsf TRISE,2 | |
1201 movlw .3 | 1247 movlw .3 |
1202 movff WREG,battery_type | 1248 movwf battery_type |
1203 return | 1249 return |
1204 | 1250 |
1205 | 1251 ; rechargeable internal Lithium-ion |
1206 setup_new_16650: | 1252 setup_new_16650: |
1207 banksel battery_capacity | 1253 bcf charge_disable ; release charging-inhibit signal |
1208 clrf internal_battery_capacity+0 | 1254 bsf charge_enable ; tristate charging-inhibit signal |
1209 clrf internal_battery_capacity+1 | 1255 CLRI battery_capacity_internal |
1210 movlw LOW ur16650_capacity | 1256 MOVLI capacity_ur16650, battery_capacity |
1211 movwf battery_capacity+0 | 1257 MOVLI offset_ur16650, battery_offset |
1212 movlw HIGH ur16650_capacity | |
1213 movwf battery_capacity+1 | |
1214 movlw LOW ur16650_offset | |
1215 movwf battery_offset+0 | |
1216 movlw HIGH ur16650_offset | |
1217 movwf battery_offset+1 | |
1218 banksel common | |
1219 bcf charge_disable | |
1220 bsf TRISE,2 | |
1221 movlw .4 | 1258 movlw .4 |
1222 movff WREG,battery_type | 1259 movwf battery_type |
1223 return | 1260 return |
1224 | 1261 |
1262 | |
1263 use_new_15V_batteries: | |
1264 rcall setup_new_15v | |
1265 bra use_batt_exit | |
1266 | |
1267 use_36V_disposable: | |
1268 rcall setup_new_saft | |
1269 bra use_batt_exit | |
1270 | |
1271 use_37V_rechargeable: | |
1272 rcall setup_new_panasonic | |
1273 call reset_battery_internal_only | |
1274 bra use_batt_exit_1 | |
1225 | 1275 |
1226 use_16650_battery: | 1276 use_16650_battery: |
1227 rcall setup_new_16650 | 1277 rcall setup_new_16650 |
1228 bra use_batt_exit | 1278 bra use_batt_exit |
1279 | |
1229 use_18650_battery: | 1280 use_18650_battery: |
1230 rcall setup_new_18650 | 1281 rcall setup_new_18650 |
1231 bra use_batt_exit | 1282 ;bra use_batt_exit |
1232 use_new_36V_batteries: | 1283 |
1233 rcall setup_new_saft | |
1234 bra use_batt_exit | |
1235 use_new_15V_batteries: | |
1236 rcall setup_new_15v | |
1237 use_batt_exit: | 1284 use_batt_exit: |
1238 call reset_battery_pointer ; resets battery pointer 0x07-0x0C and battery_gauge:5 | 1285 call reset_battery_pointer ; reset battery pointer 0x07-0x0C and battery gauge |
1239 use_batt_exit1: | 1286 use_batt_exit_1: |
1240 | |
1241 IFNDEF _screendump | 1287 IFNDEF _screendump |
1242 bcf disable_comm_mode ; re-enable COMM mode again | 1288 bcf comm_mode_disabled ; re-enable COMM mode again |
1243 ENDIF | 1289 ENDIF |
1244 | |
1245 goto surfloop ; jump to surface loop | 1290 goto surfloop ; jump to surface loop |
1246 | 1291 |
1247 use_36V_rechargeable: | 1292 ;----------------------------------------------------------------------------- |
1248 rcall setup_new_panasonic | |
1249 call reset_battery_internal_only | |
1250 bra use_batt_exit1 ; jump to surface loop | |
1251 | 1293 |
1252 END | 1294 END |