Mercurial > public > hwos_code
annotate src/menu_tree.asm @ 63:5c4d4a42e7a0
allow logbook erase from reset menu
author | heinrichsweikamp |
---|---|
date | Thu, 19 Dec 2013 22:12:29 +0100 |
parents | ec4d8503ec45 |
children | 40a5cc0664ed |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File menu_tree.asm | |
4 ; | |
5 ; OSTC3 menus | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-07-11 : [jDG] Creation. | |
11 | |
12 #include "ostc3.inc" ; Mandatory header | |
13 #include "gaslist.inc" | |
14 #include "menu_processor.inc" | |
15 #include "start.inc" | |
16 #include "comm.inc" | |
17 #include "logbook.inc" | |
18 #include "tft.inc" | |
19 #include "eeprom_rs232.inc" | |
20 #include "external_flash.inc" | |
21 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | |
22 #include "isr.inc" | |
23 #include "ghostwriter.inc" | |
24 #include "adc_lightsensor.inc" | |
25 | |
26 gui CODE | |
27 ;============================================================================= | |
28 ; Main Menu | |
29 global do_main_menu | |
30 do_main_menu: | |
39
e4e91fe8b09d
remember last customview in dive and surface mode
mh@mh-THINK.fritz.box
parents:
23
diff
changeset
|
31 movff menupos3,customview_surfmode; save last customview |
0 | 32 bcf sleepmode ; for timeout |
33 call menu_processor_reset ; restart from first icon. | |
34 | |
35 do_continue_main_menu: | |
36 call menu_processor_pop ; drop exit line. | |
37 call menu_processor_pop ; back to last icon. | |
38 | |
39 extern do_demo_divemode, restart | |
40 MENU_BEGIN tMainMenu, .7 | |
41 MENU_CALL tLogbook, logbook | |
42 MENU_CALL tGasSetup, do_gas_menu | |
43 MENU_CALL tCCRSetup, do_ccr_menu | |
44 MENU_CALL tPlan, do_planner_menu_reset | |
45 MENU_CALL tDiveModeMenu, do_divemode_menu | |
46 MENU_CALL tSystSets, do_settings_menu | |
47 MENU_CALL tExit, restart | |
48 MENU_END | |
49 | |
50 do_info_menu: | |
51 MENU_BEGIN tInfoMenu, .4 | |
52 MENU_DYNAMIC info_menu_serial, 0 | |
53 MENU_DYNAMIC info_menu_firmware, 0 | |
54 MENU_DYNAMIC info_menu_total_dives, 0 | |
55 MENU_CALL tExit, do_return_settings | |
56 MENU_END | |
57 | |
58 ;============================================================================= | |
59 ; CCR Setup | |
60 | |
61 return_ccr_menu: | |
62 call menu_processor_pop ; drop exit line. | |
63 call menu_processor_pop ; back to last gas. | |
64 | |
65 do_ccr_menu: | |
66 bcf menu_show_sensors ; Set flag | |
67 MENU_BEGIN tCCRSetup, .5 | |
68 MENU_OPTION tCCRMode, oCCRMode, 0 | |
69 MENU_CALL tCCRSensor, do_ccr_sensor | |
70 MENU_CALL tDiluentSetup, do_diluent_setup | |
71 MENU_CALL tFixedSetpoints, do_fixed_setpoints | |
72 MENU_CALL tExit, do_continue_main_menu | |
73 MENU_END | |
74 | |
75 do_ccr_sensor: | |
76 call enable_ir ; Enable IR-Port | |
77 bsf menu_show_sensors ; Set flag | |
78 MENU_BEGIN tCCRSensor, .4 | |
79 MENU_CALL tDiveHudMask1, 0 | |
80 MENU_CALL tDiveHudMask2, 0 | |
81 MENU_CALL tDiveHudMask3, 0 | |
82 MENU_CALL tExit, return_ccr_menu | |
83 MENU_END | |
84 | |
85 do_diluent_setup: | |
86 bsf ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") | |
87 call gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth | |
88 MENU_BEGIN tDiluentSetup, .6 | |
89 MENU_DYNAMIC gaslist_strcat_gas_mod, do_edit_gas_menu | |
90 MENU_DYNAMIC gaslist_strcat_gas_mod, do_edit_gas_menu | |
91 MENU_DYNAMIC gaslist_strcat_gas_mod, do_edit_gas_menu | |
92 MENU_DYNAMIC gaslist_strcat_gas_mod, do_edit_gas_menu | |
93 MENU_DYNAMIC gaslist_strcat_gas_mod, do_edit_gas_menu | |
94 MENU_CALL tExit, return_ccr_menu | |
95 MENU_END | |
96 | |
97 do_return_fixed_setpoints: | |
98 call menu_processor_pop ; drop exit line. | |
99 call menu_processor_pop ; back to last gas. | |
100 | |
101 do_fixed_setpoints: | |
102 MENU_BEGIN tFixedSetpoints, .6 | |
103 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu | |
104 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu | |
105 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu | |
106 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu | |
107 MENU_DYNAMIC gaslist_strcat_setpoint, do_edit_sp_menu | |
108 MENU_CALL tExit, return_ccr_menu | |
109 MENU_END | |
110 | |
111 do_edit_sp_menu: | |
112 call gaslist_setSP ; Save current item. | |
113 MENU_BEGIN tFixedSetpoints, .5 | |
114 MENU_DYNAMIC gaslist_strcat_setpoint_0,0 | |
115 MENU_CALL tSPPlus, gaslist_spplus | |
116 MENU_CALL tDepthPlus, gaslist_spdepthplus | |
117 MENU_CALL tDepthMinus, gaslist_spdepthminus | |
118 MENU_CALL tExit, do_return_fixed_setpoints | |
119 MENU_END | |
120 | |
121 ;============================================================================= | |
122 ; OC Gas Setup | |
123 | |
124 return_gas_menu: | |
125 call menu_processor_pop ; drop exit line. | |
126 call menu_processor_pop ; back to last gas. | |
127 | |
128 btfsc ccr_diluent_setup ; Return to CCR-Menu? | |
129 bra do_diluent_setup ; Yes. | |
130 do_gas_menu: | |
131 bcf ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") | |
132 call gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth | |
133 MENU_BEGIN tGaslist, .6 | |
134 MENU_DYNAMIC gaslist_strcat_gas_mod, do_edit_gas_menu | |
135 MENU_DYNAMIC gaslist_strcat_gas_mod, do_edit_gas_menu | |
136 MENU_DYNAMIC gaslist_strcat_gas_mod, do_edit_gas_menu | |
137 MENU_DYNAMIC gaslist_strcat_gas_mod, do_edit_gas_menu | |
138 MENU_DYNAMIC gaslist_strcat_gas_mod, do_edit_gas_menu | |
139 MENU_CALL tExit, do_continue_main_menu | |
140 MENU_END | |
141 | |
142 return_gas_depth: | |
143 call menu_processor_pop ; drop exit line. | |
144 call menu_processor_pop ; back to last gas. | |
145 bra do_edit_gas_menu_1 | |
146 | |
147 do_edit_gas_menu: | |
148 call gaslist_setgas ; Save current item. | |
149 do_edit_gas_menu_1: ; Keep current gas. | |
150 MENU_BEGIN tGasEdit, .6 | |
151 MENU_DYNAMIC gaslist_gastitle, 0 | |
152 MENU_DYNAMIC gaslist_MOD_END, 0 | |
153 MENU_DYNAMIC gaslist_show_type, gaslist_toggle_type | |
154 MENU_CALL tSetup_mix, do_setup_mix | |
155 MENU_CALL tGasDepth, do_gas_depth_menu | |
156 MENU_CALL tExit, return_gas_menu | |
157 MENU_END | |
158 | |
159 do_setup_mix: | |
160 MENU_BEGIN tGasEdit, .7 | |
161 MENU_DYNAMIC gaslist_gastitle, 0 | |
162 MENU_DYNAMIC gaslist_MOD_END, 0 | |
163 MENU_CALL tO2Plus, gaslist_pO2 | |
164 MENU_CALL tO2Minus, gaslist_mO2 | |
165 MENU_CALL tHePlus, gaslist_pHe | |
166 MENU_CALL tHeMinus, gaslist_mHe | |
167 MENU_CALL tExit, return_gas_depth | |
168 MENU_END | |
169 | |
170 global do_gas_depth_menu | |
171 do_gas_depth_menu: | |
172 MENU_BEGIN tGasEdit, .6 | |
173 MENU_DYNAMIC gaslist_gastitle, 0 | |
174 MENU_DYNAMIC gaslist_MOD_END, 0 | |
175 MENU_CALL tDepthPlus, gaslist_pDepth | |
176 MENU_CALL tDepthMinus, gaslist_mDepth | |
177 MENU_DYNAMIC gaslist_reset_mod_title,gaslist_reset_mod | |
178 MENU_CALL tExit, return_gas_depth | |
179 MENU_END | |
180 | |
181 ;============================================================================= | |
182 ; Simulator menus | |
183 | |
184 global do_planner_menu | |
185 | |
186 do_planner_menu_reset: | |
187 extern option_save_all | |
188 call option_save_all | |
189 ;---- Reset dive time/depth to default values | |
190 extern option_reset | |
191 lfsr FSR0,odiveInterval | |
192 call option_reset | |
193 lfsr FSR0,obottomTime | |
194 call option_reset | |
195 lfsr FSR0,obottomDepth | |
196 call option_reset | |
197 | |
198 do_planner_menu: | |
199 extern do_demo_planner | |
200 MENU_BEGIN tPlan, .6 | |
201 MENU_CALL tInter, do_demo_divemode | |
202 MENU_OPTION tIntvl, odiveInterval, 0 | |
203 MENU_OPTION tBtTm, obottomTime, 0 | |
204 MENU_OPTION tMxDep, obottomDepth, 0 | |
205 MENU_CALL tDeco, do_demo_planner | |
206 MENU_CALL tExit, do_continue_main_menu | |
207 MENU_END | |
208 | |
209 ;============================================================================= | |
210 ; Divemode menu | |
211 | |
212 do_return_divemode_menu: | |
213 call menu_processor_pop ; drop exit line. | |
214 call menu_processor_pop ; back to last gas. | |
215 | |
216 do_divemode_menu: | |
217 MENU_BEGIN tDiveModeMenu, .7 | |
218 MENU_OPTION tDvMode, oDiveMode, 0 | |
219 MENU_OPTION tDkMode, oDecoMode, 0 | |
220 MENU_DYNAMIC divesets_ppo2_max, do_toggle_ppo2_max | |
221 MENU_DYNAMIC divesets_ppo2_min, do_toggle_ppo2_min | |
222 MENU_OPTION tFTTSMenu, oExtraTime,0 | |
223 MENU_CALL tDecoparameters, do_decoparameters_menu | |
224 MENU_CALL tExit, do_continue_main_menu | |
225 MENU_END | |
226 | |
227 do_return_decoparameters_menu: | |
228 call menu_processor_pop ; drop exit line. | |
229 call menu_processor_pop ; back to setting | |
230 do_decoparameters_menu: | |
231 MENU_BEGIN tDecoparameters, .7 | |
232 MENU_OPTION tGF_low, oGF_low, 0 | |
233 MENU_OPTION tGF_high, oGF_high, 0 | |
234 MENU_CALL taGFMenu, do_aGF_menu | |
235 MENU_OPTION tSaturationMult,osatmult, 0 | |
236 MENU_OPTION tDesaturationMult,odesatmult,0 | |
237 MENU_OPTION tLastDecostop,oLastDeco, 0 | |
238 MENU_CALL tExit, do_return_divemode_menu | |
239 MENU_END | |
240 | |
241 do_aGF_menu: | |
242 MENU_BEGIN taGFMenu, .4 | |
243 MENU_OPTION taGF_enable,oEnable_aGF, 0 | |
244 MENU_OPTION taGF_low, oaGF_low, 0 | |
245 MENU_OPTION taGF_high, oaGF_high, 0 | |
246 MENU_CALL tExit, do_return_decoparameters_menu | |
247 MENU_END | |
248 ;============================================================================= | |
249 ; Setup Menu | |
250 | |
251 do_return_settings: | |
252 bcf settime_setdate ; Clear flag | |
253 call menu_processor_pop ; Drop exit entry | |
254 call menu_processor_pop ; Pop return line. | |
255 | |
256 extern compass_calibration_loop | |
257 do_settings_menu: | |
258 MENU_BEGIN tSystSets, .7 | |
259 MENU_CALL tInfoMenu, do_info_menu | |
260 MENU_CALL tSetTimeDate, do_date_time_menu | |
261 MENU_CALL tDispSets, do_dispsets_menu | |
262 MENU_OPTION tLanguage, oLanguage, 0 | |
18
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
263 MENU_CALL tCompassMenu, do_compass_menu |
0 | 264 MENU_CALL tResetMenu, do_reset_menu |
265 MENU_CALL tExit, do_continue_main_menu | |
266 MENU_END | |
267 | |
18
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
268 do_compass_menu: |
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
269 MENU_BEGIN tSystSets, .3 |
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
270 MENU_CALL tCompassMenu, compass_calibration_loop |
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
271 MENU_OPTION tCompassGain, oCompassGain, 0 |
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
272 MENU_CALL tExit, do_return_settings |
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
273 MENU_END |
4e3f133dfbf4
add new opt_compass_gain option to work with more magnetic battery types
heinrichsweikamp
parents:
0
diff
changeset
|
274 |
0 | 275 ;============================================================================= |
276 ; Reset and confirmation menu. | |
277 | |
278 do_reset_menu: | |
63 | 279 MENU_BEGIN tResetMenu, .6 |
0 | 280 MENU_CALL tExit, do_return_settings |
281 MENU_CALL tReboot, do_reset_menu2 ; Confirm | |
282 MENU_CALL tResetDeco, do_reset_menu3 ; Confirm | |
283 MENU_CALL tResetSettings, do_reset_menu4 ; Confirm | |
63 | 284 MENU_CALL tResetLogbook, do_reset_menu5 ; Confirm |
0 | 285 MENU_CALL tResetBattery, new_battery_menu ; New Battery submenu |
286 MENU_END | |
287 | |
288 do_reset_menu2: | |
289 MENU_BEGIN tResetMenu2, .2 | |
290 MENU_CALL tAbort, do_continue_menu_3stack | |
291 MENU_CALL tReboot, do_reboot ; Reboot | |
292 MENU_END | |
293 | |
294 do_reset_menu3: | |
295 MENU_BEGIN tResetMenu2, .2 | |
296 MENU_CALL tAbort, do_continue_menu_3stack | |
297 MENU_CALL tResetDeco, do_reset_deco ; Reset Deco | |
298 MENU_END | |
299 | |
300 do_reset_menu4: | |
301 MENU_BEGIN tResetMenu2, .2 | |
302 MENU_CALL tAbort, do_continue_menu_3stack | |
303 MENU_CALL tResetSettings, do_reset_settings ; Reset all settings | |
304 MENU_END | |
305 | |
63 | 306 do_reset_menu5: |
307 MENU_BEGIN tResetMenu2, .2 | |
308 MENU_CALL tAbort, do_continue_menu_3stack | |
309 MENU_CALL tResetLogbook, do_reset_logbook ; Reset logbook | |
310 MENU_END | |
311 | |
312 do_reset_logbook: | |
313 clrf EEADRH ; Make sure to select eeprom bank 0 | |
314 clrf EEDATA | |
315 write_int_eeprom .4 | |
316 write_int_eeprom .5 | |
317 write_int_eeprom .6 ; Reset logbook pointers | |
318 call ext_flash_erase_logbook ; And complete logbook (!) | |
319 goto do_continue_main_menu ; back to menu | |
320 | |
0 | 321 |
322 do_reset_deco: | |
323 movlw d'79' ; 79% N2 | |
324 movff WREG,char_I_N2_ratio | |
325 movlw d'0' | |
326 movff WREG,char_I_step_is_1min ; 2 second deco mode | |
327 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy for deco routine | |
328 movff int_I_pres_respiration+0,int_I_pres_surface+0 ; copy for desat routine | |
329 movff int_I_pres_respiration+1,int_I_pres_surface+1 | |
330 | |
331 extern deco_reset | |
332 call deco_reset | |
333 call deco_calc_desaturation_time ; calculate desaturation time | |
334 banksel common | |
335 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode | |
336 banksel common | |
337 clrf nofly_time+0 ; Reset NoFly | |
338 clrf nofly_time+1 | |
339 clrf desaturation_time+0 ; Reset Desat | |
340 clrf desaturation_time+1 | |
341 goto do_return_settings ; back to menu | |
342 | |
343 do_reset_settings: | |
344 extern option_reset_all | |
345 call option_reset_all ; Reset all options to factory default. | |
346 goto do_continue_main_menu ; back to menu | |
347 | |
348 do_continue_menu_3stack: ; Return three levels deep | |
349 call menu_processor_pop | |
350 goto do_return_settings | |
351 | |
352 do_reboot: | |
353 call ext_flash_enable_protection ; Enables write protection | |
354 reset | |
355 | |
356 | |
357 do_date_time_menu: | |
358 MENU_BEGIN tSetTimeDate, .4 | |
359 MENU_CALL tSetTime, do_time_menu | |
360 MENU_CALL tSetDate, do_date_menu | |
361 MENU_OPTION tDateFormat,oDateFormat, 0 | |
362 MENU_CALL tExit, do_return_settings | |
363 MENU_END | |
364 | |
365 do_date_menu: | |
366 bsf settime_setdate | |
367 MENU_BEGIN tSetDate, .4 | |
368 MENU_OPTION tSetDay, oSetDay, 0 | |
50 | 369 MENU_OPTION tSetMonth, oSetMonth, 0 |
0 | 370 MENU_OPTION tSetYear, oSetYear, 0 |
371 MENU_CALL tExit, do_continue_menu_3stack | |
372 MENU_END | |
373 | |
374 | |
375 do_reset_seconds: | |
376 clrf secs | |
377 extern rtc_set_rtc | |
378 call rtc_set_rtc ; writes mins,sec,hours,day,month and year to rtc module | |
379 do_time_menu: | |
380 bsf settime_setdate | |
381 MENU_BEGIN tSetTime, .4 | |
382 MENU_OPTION tSetHours, oSetHours, 0 | |
383 MENU_OPTION tSetMinutes,oSetMinutes, 0 | |
384 MENU_CALL tSetSeconds, do_reset_seconds | |
385 MENU_CALL tExit, do_continue_menu_3stack | |
386 MENU_END | |
387 | |
388 | |
389 do_toggle_ppo2_max: ; add 0.1bar, with hard-coded max. | |
390 movff opt_ppO2_max,lo ; banksafe | |
391 movlw .10 | |
392 addwf lo,F | |
393 movlw ppo2_highest_setting | |
394 cpfsgt lo | |
395 bra do_toggle_ppo2_max2 | |
396 movlw .120 | |
397 movwf lo | |
398 do_toggle_ppo2_max2: | |
399 movff lo,opt_ppO2_max | |
400 return | |
401 | |
402 do_toggle_ppo2_min: ; sub 0.1bar, with hard-coded min. | |
403 movff opt_ppO2_min,lo ; banksafe | |
404 incf lo,F | |
405 movlw .21 | |
406 cpfsgt lo | |
407 bra do_toggle_ppo2_min2 | |
408 movlw ppo2_lowest_setting | |
409 movwf lo | |
410 do_toggle_ppo2_min2: | |
411 movff lo,opt_ppO2_min | |
412 return | |
413 | |
414 | |
415 ; Logbook offset sub-menu | |
416 do_log_offset_menu: | |
417 MENU_BEGIN tLogOffset, .6 | |
418 MENU_DYNAMIC TFT_LogOffset_Logtitle, 0 | |
419 MENU_CALL tLogOffsetp1, do_logoffset_plus1 | |
420 MENU_CALL tLogOffsetp10, do_logoffset_plus10 | |
421 MENU_CALL tLogOffsetm1, do_logoffset_minus1 | |
422 MENU_CALL tLogOffsetm10, do_logoffset_minus10 | |
423 MENU_CALL tExit, do_dispsets_menu_3stack | |
424 MENU_END | |
425 | |
426 | |
427 do_logoffset_minus1: | |
428 call do_logoffset_common_read ; Read into lo:hi | |
429 movlw d'1' | |
430 subwf lo | |
431 movlw d'0' | |
432 subwfb hi | |
433 btfss hi,7 ; <0? | |
434 goto do_logoffset_common_write ; Store and return | |
435 clrf lo | |
436 clrf hi | |
437 goto do_logoffset_common_write ; Store and return | |
438 | |
439 do_logoffset_minus10: | |
440 call do_logoffset_common_read ; Read into lo:hi | |
441 movlw d'10' | |
442 subwf lo | |
443 movlw d'0' | |
444 subwfb hi | |
445 btfss hi,7 ; <0? | |
446 goto do_logoffset_common_write ; Store and return | |
447 clrf lo | |
448 clrf hi | |
449 goto do_logoffset_common_write ; Store and return | |
450 | |
451 do_logoffset_plus1: | |
452 call do_logoffset_common_read ; Read into lo:hi | |
453 movlw d'1' | |
454 addwf lo | |
455 movlw d'0' | |
456 addwfc hi | |
457 goto do_logoffset_common_write ; Store and return | |
458 | |
459 do_logoffset_plus10: | |
460 call do_logoffset_common_read ; Read into lo:hi | |
461 movlw d'10' | |
462 addwf lo | |
463 movlw d'0' | |
464 addwfc hi | |
465 goto do_logoffset_common_write ; Store and return | |
466 | |
467 do_dispsets_menu_3stack: | |
50 | 468 bcf in_color_menu |
0 | 469 call menu_processor_pop |
470 call menu_processor_pop | |
471 | |
472 do_dispsets_menu: | |
50 | 473 MENU_BEGIN tDispSets, .7 |
0 | 474 MENU_OPTION tBright, oBrightness, 0 |
475 MENU_OPTION tUnits, oUnits, 0 | |
476 MENU_CALL tLogOffset, do_log_offset_menu | |
23
e402813343b6
new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents:
18
diff
changeset
|
477 MENU_OPTION tSamplingrate,oSamplingRate,0 |
0 | 478 MENU_OPTION tDvSalinity,oDiveSalinity, 0 |
50 | 479 MENU_CALL tColorScheme, do_color_scheme |
0 | 480 MENU_CALL tExit, do_return_settings |
481 MENU_END | |
482 | |
50 | 483 |
484 extern oColorSetDive | |
485 do_color_scheme: | |
486 bsf in_color_menu | |
487 MENU_BEGIN tColorScheme, .2 | |
488 MENU_OPTION tColorSetDive,oColorSetDive, 0 | |
489 MENU_CALL tExit, do_dispsets_menu_3stack | |
490 MENU_END | |
491 | |
492 | |
0 | 493 ;============================================================================= |
494 | |
495 global new_battery_menu | |
496 new_battery_menu: | |
497 bsf enable_screen_dumps ; To prevent exiting into COMM mode immediately | |
498 call TFT_boot ; Initialize TFT (includes clear screen) | |
499 call TFT_Display_FadeIn ; Show splash | |
500 movlw .100 | |
501 movwf batt_percent ; make sure to reset batt_percent | |
502 | |
503 ; Default (In cases of timeout or USB): Use old battery | |
504 clrf EEADRH | |
505 read_int_eeprom 0x07 | |
506 movff EEDATA,battery_gauge+0 | |
507 read_int_eeprom 0x08 | |
508 movff EEDATA,battery_gauge+1 | |
509 read_int_eeprom 0x09 | |
510 movff EEDATA,battery_gauge+2 | |
511 read_int_eeprom 0x0A | |
512 movff EEDATA,battery_gauge+3 | |
513 read_int_eeprom 0x0B | |
514 movff EEDATA,battery_gauge+4 | |
515 read_int_eeprom 0x0C | |
516 movff EEDATA,battery_gauge+5 | |
517 | |
518 MENU_BEGIN tNewBattTitle, .3 | |
519 MENU_CALL tNewBattOld, use_old_batteries | |
520 MENU_CALL tNewBattNew36, use_new_36V_batteries | |
521 MENU_CALL tNewBattNew15, use_new_15V_batteries | |
522 MENU_END | |
523 | |
524 global use_old_batteries | |
525 use_old_batteries: | |
526 clrf EEADRH | |
527 read_int_eeprom 0x07 | |
528 movff EEDATA,battery_gauge+0 | |
529 read_int_eeprom 0x08 | |
530 movff EEDATA,battery_gauge+1 | |
531 read_int_eeprom 0x09 | |
532 movff EEDATA,battery_gauge+2 | |
533 read_int_eeprom 0x0A | |
534 movff EEDATA,battery_gauge+3 | |
535 read_int_eeprom 0x0B | |
536 movff EEDATA,battery_gauge+4 | |
537 read_int_eeprom 0x0C | |
538 movff EEDATA,battery_gauge+5 | |
539 movlw .100 | |
540 movwf batt_percent ; To have 1,5V batteries right after firmware update | |
541 goto power_on_return | |
542 | |
543 use_new_15V_batteries: | |
544 use_new_36V_batteries: | |
545 call reset_battery_pointer ; Resets battery pointer 0x07-0x0C and battery_gauge:5 | |
546 goto power_on_return | |
547 | |
548 END |