Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu.asm @ 467:59ff7a1aa1cb 2.01stable
show firmware version in logbook correctly
author | heinrichsweikamp |
---|---|
date | Mon, 03 Oct 2011 09:36:53 +0200 |
parents | 6e57b5bb98ce |
children | 2ac77db9c150 |
rev | line source |
---|---|
0 | 1 |
2 ; OSTC - diving computer code | |
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
4 | |
5 ; This program is free software: you can redistribute it and/or modify | |
6 ; it under the terms of the GNU General Public License as published by | |
7 ; the Free Software Foundation, either version 3 of the License, or | |
8 ; (at your option) any later version. | |
9 | |
10 ; This program is distributed in the hope that it will be useful, | |
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ; GNU General Public License for more details. | |
14 | |
15 ; You should have received a copy of the GNU General Public License | |
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | |
18 | |
19 ; Main Menu and Setup menu | |
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
21 ; written: 11/1/05 | |
22 ; last updated: 05/15/80 | |
23 ; known bugs: | |
24 ; ToDo: | |
25 | |
26 wait_switches: | |
27 bcf switch_left | |
28 bcf switch_right | |
41 | 29 return |
0 | 30 |
31 menu: | |
32 bcf deco_mode_changed ; Clear flag (Description is only showed once) | |
41 | 33 bcf LED_blue |
0 | 34 movlw d'1' |
35 movwf menupos | |
36 menu2: | |
37 | |
38 bcf leftbind | |
39 call PLED_ClearScreen | |
40 clrf timeout_counter2 | |
41 bcf sleepmode | |
42 bcf menubit2 | |
43 bcf menubit3 | |
44 bsf menubit | |
45 bsf cursor | |
46 call PLED_menu_mask | |
47 call PLED_menu_cursor | |
297
ceedf078b2d8
Gas Setup page 2 reworked, Texts 107, 108, 109,150, 149, 168, 42, 43, 53,54,55, 165 need update in french, spanish and german
Heinrichsweikamp
parents:
188
diff
changeset
|
48 rcall wait_switches |
0 | 49 |
50 menu_loop: | |
51 call check_switches_menu | |
52 | |
53 btfsc menubit2 | |
297
ceedf078b2d8
Gas Setup page 2 reworked, Texts 107, 108, 109,150, 149, 168, 42, 43, 53,54,55, 165 need update in french, spanish and german
Heinrichsweikamp
parents:
188
diff
changeset
|
54 bra do_menu ; call submenu |
0 | 55 |
56 btfss menubit | |
57 goto restart ; exit menu, restart | |
58 | |
59 btfsc onesecupdate | |
60 call timeout_surfmode | |
61 | |
62 btfsc onesecupdate | |
63 call set_dive_modes | |
64 | |
65 btfsc onesecupdate | |
66 call test_charger ; check if charger IC is active | |
67 | |
68 btfsc onesecupdate | |
69 call get_battery_voltage ; get battery voltage | |
70 | |
71 bcf onesecupdate ; End of one second tasks | |
72 | |
73 btfsc sleepmode | |
74 goto restart | |
75 | |
76 btfsc divemode | |
77 goto restart ; exit menu, restart and enter divemode | |
78 | |
79 bra menu_loop | |
80 | |
337 | 81 check_switches_menu: ; checks switches |
82 btfsc uart_dump_screen ; Asked to dump screen contains ? | |
83 call dump_screen ; Yes! | |
84 | |
0 | 85 btfss switch_right |
297
ceedf078b2d8
Gas Setup page 2 reworked, Texts 107, 108, 109,150, 149, 168, 42, 43, 53,54,55, 165 need update in french, spanish and german
Heinrichsweikamp
parents:
188
diff
changeset
|
86 bra check_switches_menu2 |
0 | 87 bsf menubit3 |
88 incf menupos,F | |
89 movlw d'6' | |
90 cpfsgt menupos | |
297
ceedf078b2d8
Gas Setup page 2 reworked, Texts 107, 108, 109,150, 149, 168, 42, 43, 53,54,55, 165 need update in french, spanish and german
Heinrichsweikamp
parents:
188
diff
changeset
|
91 bra refresh_cursor |
0 | 92 movlw d'1' |
93 movwf menupos | |
297
ceedf078b2d8
Gas Setup page 2 reworked, Texts 107, 108, 109,150, 149, 168, 42, 43, 53,54,55, 165 need update in french, spanish and german
Heinrichsweikamp
parents:
188
diff
changeset
|
94 bra refresh_cursor |
0 | 95 check_switches_menu2: |
96 btfsc switch_left | |
97 bsf menubit2 ; Enter! | |
98 return | |
99 | |
100 | |
101 do_menu: ; calls submenu | |
102 dcfsnz menupos,F | |
103 goto menu_logbook | |
104 dcfsnz menupos,F | |
105 goto menu_gassetup | |
106 dcfsnz menupos,F | |
107 goto menu_reset | |
108 dcfsnz menupos,F | |
109 goto setup_menu | |
110 dcfsnz menupos,F | |
111 goto more_menu | |
112 dcfsnz menupos,F | |
113 goto restart ; exit... | |
114 | |
115 refresh_cursor: | |
116 clrf timeout_counter2 | |
117 btfsc cursor | |
118 call PLED_menu_cursor | |
119 bcf switch_right | |
297
ceedf078b2d8
Gas Setup page 2 reworked, Texts 107, 108, 109,150, 149, 168, 42, 43, 53,54,55, 165 need update in french, spanish and german
Heinrichsweikamp
parents:
188
diff
changeset
|
120 bcf switch_left |
0 | 121 return |
122 | |
123 more_menu: | |
124 movlw d'1' | |
125 movwf menupos | |
126 more_menu2: | |
127 bcf leftbind | |
128 call PLED_ClearScreen | |
129 more_menu3: | |
130 clrf timeout_counter2 | |
131 bcf sleepmode | |
132 bcf menubit2 | |
133 bcf menubit3 | |
134 bsf menubit | |
135 bsf cursor | |
136 call PLED_more_menu_mask | |
137 call PLED_menu_cursor | |
138 bcf switch_left | |
139 bcf switch_right | |
140 more_menu_loop: | |
141 call check_switches_menu | |
142 | |
125 | 143 ; movlw d'5' ; 5 items in "More Menu" |
144 ; cpfseq menupos | |
145 ; bra more_menu_loop2 | |
146 ; movlw d'6' | |
147 ; movwf menupos | |
148 ; call PLED_menu_cursor | |
149 | |
150 ;more_menu_loop2: | |
0 | 151 btfsc menubit2 |
152 bra do_more_menu ; call submenu | |
153 | |
154 btfss menubit | |
155 bra menu ; exit setup menu and return to main menu | |
156 | |
157 btfsc onesecupdate | |
158 call timeout_surfmode | |
159 | |
160 btfsc onesecupdate | |
161 call set_dive_modes | |
162 | |
163 btfsc onesecupdate | |
164 call test_charger ; check if charger IC is active | |
165 | |
166 btfsc onesecupdate | |
167 call get_battery_voltage ; get battery voltage | |
168 | |
169 bcf onesecupdate ; End of one second tasks | |
170 | |
171 btfsc sleepmode | |
172 bra menu | |
173 | |
174 btfsc divemode | |
175 goto restart ; exit menu, restart and enter divemode | |
176 | |
177 bra more_menu_loop | |
178 | |
179 do_more_menu: ; calls submenu | |
180 dcfsnz menupos,F | |
181 goto menu_settime | |
182 dcfsnz menupos,F | |
183 goto menu_const_ppO2 | |
184 dcfsnz menupos,F | |
185 goto menu_battery_state | |
186 dcfsnz menupos,F | |
187 goto menu_simulator | |
188 dcfsnz menupos,F | |
125 | 189 goto altimeter_menu |
0 | 190 movlw d'5' |
191 movwf menupos | |
192 bra menu2 ; exit... | |
193 | |
194 setup_menu: | |
195 bcf deco_mode_changed ; Clear flag | |
196 movlw d'1' | |
197 movwf menupos | |
198 setup_menu2: | |
199 bcf leftbind | |
200 call PLED_ClearScreen | |
201 call PLED_setup_menu_mask | |
202 setup_menu3a: | |
203 clrf timeout_counter2 | |
204 bcf sleepmode | |
205 bcf menubit2 | |
206 bcf menubit3 | |
207 bsf menubit | |
208 bsf cursor | |
209 call show_decotype | |
210 call show_salinity_value | |
211 call PLED_menu_cursor | |
212 bcf switch_left | |
213 bcf switch_right | |
214 | |
215 setup_menu_loop: | |
216 call check_switches_menu | |
217 | |
218 btfsc menubit2 | |
219 bra do_setup_menu ; call submenu | |
220 | |
221 btfss menubit | |
222 goto restart ; exit menu, restart and enter surfmode | |
223 btfsc onesecupdate | |
224 call timeout_surfmode | |
225 btfsc onesecupdate | |
226 call set_dive_modes | |
227 btfsc onesecupdate | |
228 call test_charger ; check if charger IC is active | |
229 btfsc onesecupdate | |
230 call get_battery_voltage ; get battery voltage | |
231 | |
232 bcf onesecupdate ; End of one second tasks | |
233 | |
234 btfsc sleepmode | |
235 goto restart ; exit menu, restart and enter surfmode | |
236 | |
237 btfsc divemode | |
238 goto restart ; exit menu, restart and enter divemode | |
239 | |
240 bra setup_menu_loop | |
241 | |
242 | |
243 do_setup_menu: ; calls submenu | |
244 dcfsnz menupos,F | |
245 goto menu_custom_functions | |
246 dcfsnz menupos,F | |
247 goto menu_custom_functions_page2 | |
248 dcfsnz menupos,F | |
249 bra toggle_salinity | |
250 dcfsnz menupos,F | |
251 bra toggle_decotype | |
252 dcfsnz menupos,F | |
253 bra more_setup_menu | |
254 bra exit_setup_menu ; exit... | |
255 | |
256 toggle_decotype: | |
257 bsf deco_mode_changed ; Set flag | |
258 read_int_eeprom d'34' ; Read deco data | |
259 incf EEDATA,F | |
260 | |
261 toggle_decotype0: | |
262 movlw d'6' ; number of different modes | |
263 cpfseq EEDATA | |
264 bra toggle_decotype1 | |
265 clrf EEDATA | |
266 | |
267 toggle_decotype1: | |
268 call write_eeprom ; save new mode | |
269 movlw d'4' | |
270 movwf menupos | |
271 bcf switch_right | |
272 bra setup_menu3a ; return to manu loop | |
273 | |
274 show_decotype: | |
275 read_int_eeprom d'34' ; Read deco data | |
276 tstfsz EEDATA | |
277 bra show_decotype2 | |
278 DISPLAYTEXT .101 ; ZH-L16 OC =0 | |
279 return | |
280 show_decotype2: | |
281 decfsz EEDATA,F | |
282 bra show_decotype3 | |
283 DISPLAYTEXT .102 ; Gauge =1 | |
284 return | |
285 show_decotype3: | |
286 decfsz EEDATA,F | |
287 bra show_decotype4 | |
288 DISPLAYTEXT .104 ; ZH-L16 CC =2 | |
289 return | |
290 show_decotype4: | |
291 decfsz EEDATA,F | |
292 bra show_decotype5 | |
293 DISPLAYTEXT .138 ; Apnoe =3 | |
294 return | |
295 show_decotype5: | |
296 decfsz EEDATA,F | |
297 bra show_decotype6 | |
298 DISPLAYTEXT .152 ; L16-GF OC =4 | |
299 return | |
300 show_decotype6: | |
301 decfsz EEDATA,F | |
302 return | |
303 DISPLAYTEXT .236 ; L16-GF CC =5 | |
304 return | |
305 | |
306 exit_setup_menu: | |
307 btfss deco_mode_changed ; Was the decomode changed in Setup menu? | |
308 goto restart ; No, restart to surfacemode | |
309 | |
310 call PLED_ClearScreen | |
311 | |
312 deco_info_screen1: | |
313 call PLED_topline_box | |
314 WIN_INVERT .1 ; Init new Wordprocessor | |
315 DISPLAYTEXT .235 ;Decomode changed! | |
316 WIN_INVERT .0 ; Init new Wordprocessor | |
317 | |
318 read_int_eeprom d'34' ; Read deco data | |
319 | |
320 movlw d'7' ; length of description text | |
321 mulwf EEDATA ; Multiply with Decomode 0-5 (5=Spare) | |
322 | |
323 movf PRODL,W | |
324 addlw d'193' ; Description text offset | |
325 movwf menupos ; Used as loop counter temp | |
326 | |
327 movlw d'7' | |
328 movwf temp1 ; Loop 7 times | |
329 | |
330 menu0: | |
331 movf menupos,W | |
174 | 332 call displaytext_1_low ; Display text! |
0 | 333 incf menupos,F |
334 | |
335 decfsz temp1,F | |
336 bra menu0 ; loop 7 times | |
337 | |
338 movlw d'30' | |
339 call startup_screen3a | |
340 goto restart ; Restart to surfacemode | |
341 | |
342 more_setup_menu: | |
343 movlw d'1' | |
344 movwf menupos | |
345 more_setup_menu2: | |
346 bcf leftbind | |
347 call PLED_ClearScreen | |
348 call PLED_more_setup_menu_mask | |
349 more_setup_menu3a: | |
350 clrf timeout_counter2 | |
351 bcf sleepmode | |
352 bcf menubit2 | |
353 bcf menubit3 | |
354 bsf menubit | |
355 bsf cursor | |
356 call show_debugstate | |
357 call show_dateformat | |
358 call PLED_menu_cursor | |
359 bcf switch_left | |
360 bcf switch_right | |
361 | |
362 more_setup_menu_loop: | |
363 call check_switches_menu | |
364 | |
188 | 365 movlw d'5' ; x-1 menu entries |
0 | 366 cpfseq menupos |
367 bra more_setup_menu_loop2 | |
368 movlw d'6' | |
369 movwf menupos | |
370 call PLED_menu_cursor | |
371 more_setup_menu_loop2: | |
372 | |
373 btfsc menubit2 | |
374 bra do_more_setup_menu ; call submenu | |
375 | |
376 btfss menubit | |
377 goto restart ; exit menu, restart and enter surfmode | |
378 | |
379 btfsc onesecupdate | |
380 call timeout_surfmode | |
381 btfsc onesecupdate | |
382 call set_dive_modes | |
383 btfsc onesecupdate | |
384 call test_charger ; check if charger IC is active | |
385 btfsc onesecupdate | |
386 call get_battery_voltage ; get battery voltage | |
387 | |
388 bcf onesecupdate ; End of one second tasks | |
389 | |
390 btfsc sleepmode | |
391 goto setup_menu ; exit menu | |
392 | |
393 btfsc divemode | |
394 goto restart ; exit menu, restart and enter divemode | |
395 | |
396 bra more_setup_menu_loop | |
397 | |
398 do_more_setup_menu: ; calls submenu | |
399 dcfsnz menupos,F | |
400 bra toggle_datemode | |
401 dcfsnz menupos,F | |
402 bra toggle_debugmode | |
403 dcfsnz menupos,F | |
12 | 404 bra show_license |
0 | 405 dcfsnz menupos,F |
188 | 406 bra show_rawdata |
0 | 407 dcfsnz menupos,F |
408 bra setup_menu ; spare | |
409 movlw d'5' ; set cursor to "More again" | |
410 movwf menupos | |
411 bra setup_menu2 ; exit... | |
412 | |
188 | 413 show_rawdata: ; Displays Sensor raw data |
414 call PLED_ClearScreen | |
415 call PLED_topline_box | |
416 WIN_INVERT .1 ; Init new Wordprocessor | |
417 DISPLAYTEXTH .296 ; Raw Data: | |
418 WIN_INVERT .0 ; Init new Wordprocessor | |
419 | |
420 call PLED_static_raw_data | |
421 | |
432 | 422 |
188 | 423 clrf timeout_counter2 |
424 bcf sleepmode | |
425 bcf menubit3 | |
426 bsf menubit | |
432 | 427 |
428 show_rawdata_loop: | |
429 rcall show_rawdata_wait | |
430 | |
431 btfsc menubit2 | |
432 bra show_rawdata_next | |
433 | |
434 btfsc onesecupdate | |
435 call PLED_update_raw_data | |
436 | |
437 bcf onesecupdate ; End of one second tasks, if any. | |
438 | |
439 goto show_rawdata_loop | |
440 | |
441 show_rawdata_wait: | |
442 bcf menubit2 | |
188 | 443 bcf switch_left |
444 bcf switch_right | |
432 | 445 |
446 show_rawdata_wait_1: | |
337 | 447 btfsc uart_dump_screen ; Asked to dump screen contains ? |
448 call dump_screen ; Yes! | |
449 | |
188 | 450 btfsc switch_left ; Ack? |
451 bsf menubit2 | |
452 btfsc switch_right ; Ack? | |
453 bsf menubit2 | |
454 | |
455 btfsc menubit2 | |
432 | 456 return |
188 | 457 |
458 btfss menubit | |
459 goto restart ; exit menu, restart and enter surfmode | |
460 | |
461 btfsc onesecupdate | |
462 call timeout_surfmode | |
463 | |
464 btfsc onesecupdate | |
465 call set_dive_modes | |
466 | |
467 btfsc sleepmode | |
468 bra show_rawdata_exit ; Exit | |
469 | |
470 btfsc divemode | |
471 goto restart ; exit menu, restart and enter divemode | |
472 | |
432 | 473 btfsc onesecupdate |
474 return | |
475 | |
476 bra show_rawdata_wait_1 | |
477 | |
478 ; Display blank/red/green/blue screens until click, to test OLED ageing. | |
479 show_rawdata_next: | |
444 | 480 ; display test draws more power then allowed -> potential hardware risk! |
481 #ifndef DISPLAY_TEST | |
482 bra show_rawdata_exit | |
483 #endif | |
484 | |
432 | 485 setf WREG |
486 WIN_BOX_COLOR .0,.240,.0,.160 | |
487 rcall show_rawdata_screen_wait | |
488 movlw color_red | |
489 WIN_BOX_COLOR .0,.240,.0,.160 | |
490 rcall show_rawdata_screen_wait | |
491 movlw color_green | |
492 WIN_BOX_COLOR .0,.240,.0,.160 | |
493 rcall show_rawdata_screen_wait | |
494 movlw color_blue | |
495 WIN_BOX_COLOR .0,.240,.0,.160 | |
496 rcall show_rawdata_screen_wait | |
497 bra show_rawdata_exit | |
498 | |
499 show_rawdata_screen_wait: | |
500 rcall show_rawdata_wait | |
501 bcf onesecupdate ; No dynamic update here... | |
502 | |
503 btfsc menubit2 | |
504 return | |
505 | |
506 bra show_rawdata_screen_wait | |
188 | 507 |
508 show_rawdata_exit: | |
509 movlw d'4' | |
510 movwf menupos | |
511 bcf switch_right | |
512 bra more_setup_menu2 ; return to "more menu" loop | |
513 | |
12 | 514 show_license: |
515 call startup_screen1 ;1/2 | |
516 call startup_screen2 ;1/2 | |
517 movlw d'3' | |
518 movwf menupos | |
519 bcf switch_right | |
520 bra more_setup_menu2 ; return to "more menu" loop | |
521 | |
0 | 522 toggle_salinity: |
523 ; Toggles between 1.00 and 1.04 | |
524 read_int_eeprom d'26' ; Read Salinity from EEPROM | |
525 incf EEDATA,F ; Increase value | |
526 | |
527 movlw d'99' ; 99% ? | |
528 cpfsgt EEDATA ; Salinity lower limit | |
529 bra toggle_salinity_reset ; Out of limit, reset value to 1.00 | |
530 movlw d'105' ; 105% ? | |
531 cpfslt EEDATA ; Salinity higher limit | |
532 bra toggle_salinity_reset ; Out of limit, reset value to 1.00 | |
533 | |
534 toggle_salinity2: | |
535 write_int_eeprom d'26' ; Store salinity | |
536 movlw d'3' | |
537 movwf menupos | |
538 bcf switch_right | |
539 bra setup_menu3a ; return to manu loop | |
540 | |
541 toggle_salinity_reset: | |
542 movlw d'100' | |
543 movwf EEDATA | |
544 bra toggle_salinity2 ; back | |
545 | |
546 show_salinity_value: | |
547 read_int_eeprom d'26' ; Read Salinity from EEPROM | |
548 movlw d'99' ; 99% ? | |
549 cpfsgt EEDATA ; Salinity lower limit | |
550 rcall toggle_salinity_reset2 ; Reset before display! | |
551 movlw d'105' ; 105% ? | |
552 cpfslt EEDATA ; Salinity higher limit | |
553 rcall toggle_salinity_reset2 ; Reset before display! | |
554 WIN_TOP .95 | |
183 | 555 WIN_LEFT .90 ; +7 for spanish |
0 | 556 WIN_FONT FT_SMALL |
557 lfsr FSR2,letter | |
558 movff EEDATA,lo | |
559 clrf hi | |
560 bsf leftbind | |
561 output_16dp d'3' | |
562 bcf leftbind | |
445 | 563 STRCAT_PRINT TXT_KGL4 |
0 | 564 return |
565 | |
566 toggle_salinity_reset2: | |
567 movlw d'100' | |
568 movwf EEDATA | |
569 write_int_eeprom d'26' ; Store salinity | |
570 return | |
571 | |
572 toggle_datemode: | |
573 ; Toggles setting for | |
574 ; MM/DD/YY =0, Default | |
575 ; DD/MM/YY =1 | |
576 ; YY/MM/DD =2 | |
577 read_int_eeprom d'91' ; Read date format | |
578 incf EEDATA,F | |
579 movlw d'2' | |
580 cpfsgt EEDATA | |
581 bra toggle_datemode1 | |
582 clrf EEDATA | |
583 toggle_datemode1: | |
584 write_int_eeprom d'91' ; Store date format | |
585 movlw d'1' | |
586 movwf menupos | |
587 bcf switch_right | |
588 bra more_setup_menu3a ; return to manu loop | |
589 | |
590 show_dateformat: | |
591 read_int_eeprom d'91' ; Read date format (0=MMDDYY, 1=DDMMYY, 2=YYMMDD) | |
592 tstfsz EEDATA | |
593 bra show_dateformat2 | |
594 DISPLAYTEXTH .259 ; MM/DD/YY = 0 | |
595 return | |
596 show_dateformat2: | |
597 decfsz EEDATA,F | |
598 bra show_dateformat3 | |
599 DISPLAYTEXTH .260 ; DD/MM/YY = 1 | |
600 return | |
601 show_dateformat3: | |
602 DISPLAYTEXTH .261 ; YY/MM/DD = 2 | |
603 return | |
604 | |
605 toggle_debugmode: | |
606 read_int_eeprom d'39' ; Read status | |
607 incf EEDATA,F | |
608 movlw d'1' | |
609 cpfsgt EEDATA | |
610 bra toggle_debugmode1 | |
611 clrf EEDATA | |
612 toggle_debugmode1: | |
613 write_int_eeprom d'39' ; Store status | |
614 bsf debug_mode ; set flag | |
615 movlw d'1' | |
616 cpfseq EEDATA | |
617 bcf debug_mode ; clear flag | |
618 movlw d'2' | |
619 movwf menupos | |
620 bcf switch_right | |
621 bra more_setup_menu3a ; return to manu loop | |
622 | |
623 show_debugstate: | |
624 read_int_eeprom d'39' | |
625 tstfsz EEDATA | |
626 bra show_debugstate2 | |
627 DISPLAYTEXT .131 ; OFF | |
628 show_debugstate2: | |
629 decf EEDATA,F | |
630 tstfsz EEDATA | |
631 bra show_decotype3 | |
632 DISPLAYTEXT .130 ; ON | |
633 return |