Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu.asm @ 385:af703be9ead2 64kByte Logbook
Fix simulator start
author | heinrichsweikamp |
---|---|
date | Sat, 18 Jun 2011 17:52:52 +0200 |
parents | 6bdf80d7276c |
children | efe06a146773 |
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 | |
422 clrf timeout_counter2 | |
423 bcf sleepmode | |
424 bcf menubit2 | |
425 bcf menubit3 | |
426 bsf menubit | |
427 bcf switch_left | |
428 bcf switch_right | |
429 show_rawdata_loop: | |
337 | 430 btfsc uart_dump_screen ; Asked to dump screen contains ? |
431 call dump_screen ; Yes! | |
432 | |
188 | 433 btfsc switch_left ; Ack? |
434 bsf menubit2 | |
435 btfsc switch_right ; Ack? | |
436 bsf menubit2 | |
437 | |
438 btfsc menubit2 | |
439 bra show_rawdata_exit | |
440 | |
441 btfss menubit | |
442 goto restart ; exit menu, restart and enter surfmode | |
443 | |
444 btfsc onesecupdate | |
445 call timeout_surfmode | |
446 | |
447 btfsc onesecupdate | |
448 call PLED_update_raw_data | |
449 | |
450 btfsc onesecupdate | |
451 call set_dive_modes | |
452 | |
453 bcf onesecupdate ; End of one second tasks | |
454 | |
455 btfsc sleepmode | |
456 bra show_rawdata_exit ; Exit | |
457 | |
458 btfsc divemode | |
459 goto restart ; exit menu, restart and enter divemode | |
460 | |
461 bra show_rawdata_loop | |
462 | |
463 show_rawdata_exit: | |
464 movlw d'4' | |
465 movwf menupos | |
466 bcf switch_right | |
467 bra more_setup_menu2 ; return to "more menu" loop | |
468 | |
12 | 469 show_license: |
470 call startup_screen1 ;1/2 | |
471 call startup_screen2 ;1/2 | |
472 movlw d'3' | |
473 movwf menupos | |
474 bcf switch_right | |
475 bra more_setup_menu2 ; return to "more menu" loop | |
476 | |
0 | 477 toggle_salinity: |
478 ; Toggles between 1.00 and 1.04 | |
479 read_int_eeprom d'26' ; Read Salinity from EEPROM | |
480 incf EEDATA,F ; Increase value | |
481 | |
482 movlw d'99' ; 99% ? | |
483 cpfsgt EEDATA ; Salinity lower limit | |
484 bra toggle_salinity_reset ; Out of limit, reset value to 1.00 | |
485 movlw d'105' ; 105% ? | |
486 cpfslt EEDATA ; Salinity higher limit | |
487 bra toggle_salinity_reset ; Out of limit, reset value to 1.00 | |
488 | |
489 toggle_salinity2: | |
490 write_int_eeprom d'26' ; Store salinity | |
491 movlw d'3' | |
492 movwf menupos | |
493 bcf switch_right | |
494 bra setup_menu3a ; return to manu loop | |
495 | |
496 toggle_salinity_reset: | |
497 movlw d'100' | |
498 movwf EEDATA | |
499 bra toggle_salinity2 ; back | |
500 | |
501 show_salinity_value: | |
502 read_int_eeprom d'26' ; Read Salinity from EEPROM | |
503 movlw d'99' ; 99% ? | |
504 cpfsgt EEDATA ; Salinity lower limit | |
505 rcall toggle_salinity_reset2 ; Reset before display! | |
506 movlw d'105' ; 105% ? | |
507 cpfslt EEDATA ; Salinity higher limit | |
508 rcall toggle_salinity_reset2 ; Reset before display! | |
509 WIN_TOP .95 | |
183 | 510 WIN_LEFT .90 ; +7 for spanish |
0 | 511 WIN_FONT FT_SMALL |
512 lfsr FSR2,letter | |
513 movff EEDATA,lo | |
514 clrf hi | |
515 bsf leftbind | |
516 output_16dp d'3' | |
517 bcf leftbind | |
123 | 518 STRCAT_PRINT "kg/l" |
0 | 519 return |
520 | |
521 toggle_salinity_reset2: | |
522 movlw d'100' | |
523 movwf EEDATA | |
524 write_int_eeprom d'26' ; Store salinity | |
525 return | |
526 | |
527 toggle_datemode: | |
528 ; Toggles setting for | |
529 ; MM/DD/YY =0, Default | |
530 ; DD/MM/YY =1 | |
531 ; YY/MM/DD =2 | |
532 read_int_eeprom d'91' ; Read date format | |
533 incf EEDATA,F | |
534 movlw d'2' | |
535 cpfsgt EEDATA | |
536 bra toggle_datemode1 | |
537 clrf EEDATA | |
538 toggle_datemode1: | |
539 write_int_eeprom d'91' ; Store date format | |
540 movlw d'1' | |
541 movwf menupos | |
542 bcf switch_right | |
543 bra more_setup_menu3a ; return to manu loop | |
544 | |
545 show_dateformat: | |
546 read_int_eeprom d'91' ; Read date format (0=MMDDYY, 1=DDMMYY, 2=YYMMDD) | |
547 tstfsz EEDATA | |
548 bra show_dateformat2 | |
549 DISPLAYTEXTH .259 ; MM/DD/YY = 0 | |
550 return | |
551 show_dateformat2: | |
552 decfsz EEDATA,F | |
553 bra show_dateformat3 | |
554 DISPLAYTEXTH .260 ; DD/MM/YY = 1 | |
555 return | |
556 show_dateformat3: | |
557 DISPLAYTEXTH .261 ; YY/MM/DD = 2 | |
558 return | |
559 | |
560 toggle_debugmode: | |
561 read_int_eeprom d'39' ; Read status | |
562 incf EEDATA,F | |
563 movlw d'1' | |
564 cpfsgt EEDATA | |
565 bra toggle_debugmode1 | |
566 clrf EEDATA | |
567 toggle_debugmode1: | |
568 write_int_eeprom d'39' ; Store status | |
569 bsf debug_mode ; set flag | |
570 movlw d'1' | |
571 cpfseq EEDATA | |
572 bcf debug_mode ; clear flag | |
573 movlw d'2' | |
574 movwf menupos | |
575 bcf switch_right | |
576 bra more_setup_menu3a ; return to manu loop | |
577 | |
578 show_debugstate: | |
579 read_int_eeprom d'39' | |
580 tstfsz EEDATA | |
581 bra show_debugstate2 | |
582 DISPLAYTEXT .131 ; OFF | |
583 show_debugstate2: | |
584 decf EEDATA,F | |
585 tstfsz EEDATA | |
586 bra show_decotype3 | |
587 DISPLAYTEXT .130 ; ON | |
588 return |