Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/menu.asm @ 0:96a35aeda5f2
Initial setup
author | heinrichsweikamp |
---|---|
date | Tue, 12 Jan 2010 15:05:59 +0100 |
parents | |
children | 588a969a0cae |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:96a35aeda5f2 |
---|---|
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 ; bsf LEDg | |
28 movlw d'40' | |
29 btfss button_delay_done ; Start counting? | |
30 movlw d'200' | |
31 movwf switch_timeout | |
32 | |
33 wait_switches1: | |
34 WAITMS d'5' | |
35 btfsc SWITCH2 | |
36 bra wait_switches2 ; Check other switch | |
37 | |
38 decfsz switch_timeout,F | |
39 bra wait_switches1 | |
40 | |
41 btfsc SWITCH2 | |
42 bra wait_switches3 | |
43 | |
44 bsf button_delay_done ; Start counting | |
45 bsf switch_left ; Set button flag | |
46 bcf switch_right ; only for the other button | |
47 ; bcf LEDg | |
48 return | |
49 | |
50 wait_switches2: | |
51 btfss SWITCH1 | |
52 bra wait_switches1 ; Wait | |
53 | |
54 ; Yes, both switches released before timeout... | |
55 wait_switches3: | |
56 bcf switch_left | |
57 bcf switch_right | |
58 bcf button_delay_done | |
59 call clear_LEDg | |
60 return | |
61 | |
62 menu: | |
63 bcf deco_mode_changed ; Clear flag (Description is only showed once) | |
64 movlw d'1' | |
65 movwf menupos | |
66 menu2: | |
67 | |
68 bcf leftbind | |
69 call PLED_ClearScreen | |
70 clrf timeout_counter2 | |
71 bcf sleepmode | |
72 bcf menubit2 | |
73 bcf menubit3 | |
74 bsf menubit | |
75 bsf cursor | |
76 call PLED_menu_mask | |
77 call PLED_menu_cursor | |
78 bcf switch_left | |
79 bcf switch_right | |
80 | |
81 menu_loop: | |
82 call check_switches_menu | |
83 | |
84 btfsc menubit2 | |
85 bra do_menu ; call submenu | |
86 | |
87 btfss menubit | |
88 goto restart ; exit menu, restart | |
89 | |
90 btfsc onesecupdate | |
91 call timeout_surfmode | |
92 | |
93 btfsc onesecupdate | |
94 call set_dive_modes | |
95 | |
96 btfsc onesecupdate | |
97 call test_charger ; check if charger IC is active | |
98 | |
99 btfsc onesecupdate | |
100 call get_battery_voltage ; get battery voltage | |
101 | |
102 bcf onesecupdate ; End of one second tasks | |
103 | |
104 btfsc sleepmode | |
105 goto restart | |
106 | |
107 btfsc divemode | |
108 goto restart ; exit menu, restart and enter divemode | |
109 | |
110 bra menu_loop | |
111 | |
112 check_switches_menu: ; checks switches | |
113 btfss switch_right | |
114 bra check_switches_menu2 | |
115 bsf menubit3 | |
116 incf menupos,F | |
117 movlw d'6' | |
118 cpfsgt menupos | |
119 bra refresh_cursor | |
120 movlw d'1' | |
121 movwf menupos | |
122 bra refresh_cursor | |
123 check_switches_menu2: | |
124 btfsc switch_left | |
125 bsf menubit2 ; Enter! | |
126 return | |
127 | |
128 | |
129 do_menu: ; calls submenu | |
130 dcfsnz menupos,F | |
131 goto menu_logbook | |
132 dcfsnz menupos,F | |
133 goto menu_gassetup | |
134 dcfsnz menupos,F | |
135 goto menu_reset | |
136 dcfsnz menupos,F | |
137 goto setup_menu | |
138 dcfsnz menupos,F | |
139 goto more_menu | |
140 dcfsnz menupos,F | |
141 goto restart ; exit... | |
142 | |
143 refresh_cursor: | |
144 clrf timeout_counter2 | |
145 btfsc cursor | |
146 call PLED_menu_cursor | |
147 bcf switch_right | |
148 return | |
149 | |
150 more_menu: | |
151 movlw d'1' | |
152 movwf menupos | |
153 more_menu2: | |
154 bcf leftbind | |
155 call PLED_ClearScreen | |
156 more_menu3: | |
157 clrf timeout_counter2 | |
158 bcf sleepmode | |
159 bcf menubit2 | |
160 bcf menubit3 | |
161 bsf menubit | |
162 bsf cursor | |
163 call PLED_more_menu_mask | |
164 call PLED_menu_cursor | |
165 bcf switch_left | |
166 bcf switch_right | |
167 more_menu_loop: | |
168 call check_switches_menu | |
169 | |
170 movlw d'5' ; 5 items in "More Menu" | |
171 cpfseq menupos | |
172 bra more_menu_loop2 | |
173 movlw d'6' | |
174 movwf menupos | |
175 call PLED_menu_cursor | |
176 | |
177 more_menu_loop2: | |
178 btfsc menubit2 | |
179 bra do_more_menu ; call submenu | |
180 | |
181 btfss menubit | |
182 bra menu ; exit setup menu and return to main menu | |
183 | |
184 btfsc onesecupdate | |
185 call timeout_surfmode | |
186 | |
187 btfsc onesecupdate | |
188 call set_dive_modes | |
189 | |
190 btfsc onesecupdate | |
191 call test_charger ; check if charger IC is active | |
192 | |
193 btfsc onesecupdate | |
194 call get_battery_voltage ; get battery voltage | |
195 | |
196 bcf onesecupdate ; End of one second tasks | |
197 | |
198 btfsc sleepmode | |
199 bra menu | |
200 | |
201 btfsc divemode | |
202 goto restart ; exit menu, restart and enter divemode | |
203 | |
204 bra more_menu_loop | |
205 | |
206 do_more_menu: ; calls submenu | |
207 dcfsnz menupos,F | |
208 goto menu_settime | |
209 dcfsnz menupos,F | |
210 goto menu_const_ppO2 | |
211 dcfsnz menupos,F | |
212 goto menu_battery_state | |
213 dcfsnz menupos,F | |
214 goto menu_simulator | |
215 dcfsnz menupos,F | |
216 goto menu_simulator | |
217 movlw d'5' | |
218 movwf menupos | |
219 bra menu2 ; exit... | |
220 | |
221 setup_menu: | |
222 bcf deco_mode_changed ; Clear flag | |
223 movlw d'1' | |
224 movwf menupos | |
225 setup_menu2: | |
226 bcf leftbind | |
227 call PLED_ClearScreen | |
228 call PLED_setup_menu_mask | |
229 setup_menu3a: | |
230 clrf timeout_counter2 | |
231 bcf sleepmode | |
232 bcf menubit2 | |
233 bcf menubit3 | |
234 bsf menubit | |
235 bsf cursor | |
236 call show_decotype | |
237 call show_salinity_value | |
238 call PLED_menu_cursor | |
239 bcf switch_left | |
240 bcf switch_right | |
241 | |
242 setup_menu_loop: | |
243 call check_switches_menu | |
244 | |
245 btfsc menubit2 | |
246 bra do_setup_menu ; call submenu | |
247 | |
248 btfss menubit | |
249 goto restart ; exit menu, restart and enter surfmode | |
250 btfsc onesecupdate | |
251 call timeout_surfmode | |
252 btfsc onesecupdate | |
253 call set_dive_modes | |
254 btfsc onesecupdate | |
255 call test_charger ; check if charger IC is active | |
256 btfsc onesecupdate | |
257 call get_battery_voltage ; get battery voltage | |
258 | |
259 bcf onesecupdate ; End of one second tasks | |
260 | |
261 btfsc sleepmode | |
262 goto restart ; exit menu, restart and enter surfmode | |
263 | |
264 btfsc divemode | |
265 goto restart ; exit menu, restart and enter divemode | |
266 | |
267 bra setup_menu_loop | |
268 | |
269 | |
270 do_setup_menu: ; calls submenu | |
271 dcfsnz menupos,F | |
272 goto menu_custom_functions | |
273 dcfsnz menupos,F | |
274 goto menu_custom_functions_page2 | |
275 dcfsnz menupos,F | |
276 bra toggle_salinity | |
277 dcfsnz menupos,F | |
278 bra toggle_decotype | |
279 dcfsnz menupos,F | |
280 bra more_setup_menu | |
281 bra exit_setup_menu ; exit... | |
282 | |
283 toggle_decotype: | |
284 bsf deco_mode_changed ; Set flag | |
285 read_int_eeprom d'34' ; Read deco data | |
286 incf EEDATA,F | |
287 | |
288 toggle_decotype0: | |
289 movlw d'6' ; number of different modes | |
290 cpfseq EEDATA | |
291 bra toggle_decotype1 | |
292 clrf EEDATA | |
293 | |
294 toggle_decotype1: | |
295 call write_eeprom ; save new mode | |
296 movlw d'4' | |
297 movwf menupos | |
298 bcf switch_right | |
299 bra setup_menu3a ; return to manu loop | |
300 | |
301 show_decotype: | |
302 read_int_eeprom d'34' ; Read deco data | |
303 tstfsz EEDATA | |
304 bra show_decotype2 | |
305 DISPLAYTEXT .101 ; ZH-L16 OC =0 | |
306 return | |
307 show_decotype2: | |
308 decfsz EEDATA,F | |
309 bra show_decotype3 | |
310 DISPLAYTEXT .102 ; Gauge =1 | |
311 return | |
312 show_decotype3: | |
313 decfsz EEDATA,F | |
314 bra show_decotype4 | |
315 DISPLAYTEXT .104 ; ZH-L16 CC =2 | |
316 return | |
317 show_decotype4: | |
318 decfsz EEDATA,F | |
319 bra show_decotype5 | |
320 DISPLAYTEXT .138 ; Apnoe =3 | |
321 return | |
322 show_decotype5: | |
323 decfsz EEDATA,F | |
324 bra show_decotype6 | |
325 DISPLAYTEXT .152 ; L16-GF OC =4 | |
326 return | |
327 show_decotype6: | |
328 decfsz EEDATA,F | |
329 return | |
330 DISPLAYTEXT .236 ; L16-GF CC =5 | |
331 return | |
332 | |
333 exit_setup_menu: | |
334 btfss deco_mode_changed ; Was the decomode changed in Setup menu? | |
335 goto restart ; No, restart to surfacemode | |
336 | |
337 call PLED_ClearScreen | |
338 | |
339 deco_info_screen1: | |
340 call PLED_topline_box | |
341 WIN_INVERT .1 ; Init new Wordprocessor | |
342 DISPLAYTEXT .235 ;Decomode changed! | |
343 WIN_INVERT .0 ; Init new Wordprocessor | |
344 | |
345 read_int_eeprom d'34' ; Read deco data | |
346 | |
347 movlw d'7' ; length of description text | |
348 mulwf EEDATA ; Multiply with Decomode 0-5 (5=Spare) | |
349 | |
350 movf PRODL,W | |
351 addlw d'193' ; Description text offset | |
352 movwf menupos ; Used as loop counter temp | |
353 | |
354 movlw d'7' | |
355 movwf temp1 ; Loop 7 times | |
356 | |
357 menu0: | |
358 movf menupos,W | |
359 call displaytext1 ; Display text! | |
360 incf menupos,F | |
361 | |
362 decfsz temp1,F | |
363 bra menu0 ; loop 7 times | |
364 | |
365 movlw d'30' | |
366 call startup_screen3a | |
367 goto restart ; Restart to surfacemode | |
368 | |
369 more_setup_menu: | |
370 movlw d'1' | |
371 movwf menupos | |
372 more_setup_menu2: | |
373 bcf leftbind | |
374 call PLED_ClearScreen | |
375 call PLED_more_setup_menu_mask | |
376 more_setup_menu3a: | |
377 clrf timeout_counter2 | |
378 bcf sleepmode | |
379 bcf menubit2 | |
380 bcf menubit3 | |
381 bsf menubit | |
382 bsf cursor | |
383 call show_debugstate | |
384 call show_dateformat | |
385 call PLED_menu_cursor | |
386 bcf switch_left | |
387 bcf switch_right | |
388 | |
389 more_setup_menu_loop: | |
390 call check_switches_menu | |
391 | |
392 movlw d'3' ; x-1 menu entries | |
393 cpfseq menupos | |
394 bra more_setup_menu_loop2 | |
395 movlw d'6' | |
396 movwf menupos | |
397 call PLED_menu_cursor | |
398 more_setup_menu_loop2: | |
399 | |
400 btfsc menubit2 | |
401 bra do_more_setup_menu ; call submenu | |
402 | |
403 btfss menubit | |
404 goto restart ; exit menu, restart and enter surfmode | |
405 | |
406 btfsc onesecupdate | |
407 call timeout_surfmode | |
408 btfsc onesecupdate | |
409 call set_dive_modes | |
410 btfsc onesecupdate | |
411 call test_charger ; check if charger IC is active | |
412 btfsc onesecupdate | |
413 call get_battery_voltage ; get battery voltage | |
414 | |
415 bcf onesecupdate ; End of one second tasks | |
416 | |
417 btfsc sleepmode | |
418 goto setup_menu ; exit menu | |
419 | |
420 btfsc divemode | |
421 goto restart ; exit menu, restart and enter divemode | |
422 | |
423 bra more_setup_menu_loop | |
424 | |
425 do_more_setup_menu: ; calls submenu | |
426 dcfsnz menupos,F | |
427 bra toggle_datemode | |
428 dcfsnz menupos,F | |
429 bra toggle_debugmode | |
430 dcfsnz menupos,F | |
431 bra setup_menu ; spare | |
432 dcfsnz menupos,F | |
433 bra setup_menu ; spare | |
434 dcfsnz menupos,F | |
435 bra setup_menu ; spare | |
436 movlw d'5' ; set cursor to "More again" | |
437 movwf menupos | |
438 bra setup_menu2 ; exit... | |
439 | |
440 toggle_salinity: | |
441 ; Toggles between 1.00 and 1.04 | |
442 read_int_eeprom d'26' ; Read Salinity from EEPROM | |
443 incf EEDATA,F ; Increase value | |
444 | |
445 movlw d'99' ; 99% ? | |
446 cpfsgt EEDATA ; Salinity lower limit | |
447 bra toggle_salinity_reset ; Out of limit, reset value to 1.00 | |
448 movlw d'105' ; 105% ? | |
449 cpfslt EEDATA ; Salinity higher limit | |
450 bra toggle_salinity_reset ; Out of limit, reset value to 1.00 | |
451 | |
452 toggle_salinity2: | |
453 write_int_eeprom d'26' ; Store salinity | |
454 movlw d'3' | |
455 movwf menupos | |
456 bcf switch_right | |
457 bra setup_menu3a ; return to manu loop | |
458 | |
459 toggle_salinity_reset: | |
460 movlw d'100' | |
461 movwf EEDATA | |
462 bra toggle_salinity2 ; back | |
463 | |
464 show_salinity_value: | |
465 read_int_eeprom d'26' ; Read Salinity from EEPROM | |
466 movlw d'99' ; 99% ? | |
467 cpfsgt EEDATA ; Salinity lower limit | |
468 rcall toggle_salinity_reset2 ; Reset before display! | |
469 movlw d'105' ; 105% ? | |
470 cpfslt EEDATA ; Salinity higher limit | |
471 rcall toggle_salinity_reset2 ; Reset before display! | |
472 WIN_TOP .95 | |
473 WIN_LEFT .83 | |
474 WIN_FONT FT_SMALL | |
475 lfsr FSR2,letter | |
476 movff EEDATA,lo | |
477 clrf hi | |
478 bsf leftbind | |
479 output_16dp d'3' | |
480 bcf leftbind | |
481 movlw 'k' | |
482 movwf POSTINC2 | |
483 movlw 'g' | |
484 movwf POSTINC2 | |
485 movlw '/' | |
486 movwf POSTINC2 | |
487 movlw 'l' | |
488 movwf POSTINC2 | |
489 call word_processor | |
490 return | |
491 | |
492 toggle_salinity_reset2: | |
493 movlw d'100' | |
494 movwf EEDATA | |
495 write_int_eeprom d'26' ; Store salinity | |
496 return | |
497 | |
498 toggle_datemode: | |
499 ; Toggles setting for | |
500 ; MM/DD/YY =0, Default | |
501 ; DD/MM/YY =1 | |
502 ; YY/MM/DD =2 | |
503 read_int_eeprom d'91' ; Read date format | |
504 incf EEDATA,F | |
505 movlw d'2' | |
506 cpfsgt EEDATA | |
507 bra toggle_datemode1 | |
508 clrf EEDATA | |
509 toggle_datemode1: | |
510 write_int_eeprom d'91' ; Store date format | |
511 movlw d'1' | |
512 movwf menupos | |
513 bcf switch_right | |
514 bra more_setup_menu3a ; return to manu loop | |
515 | |
516 show_dateformat: | |
517 read_int_eeprom d'91' ; Read date format (0=MMDDYY, 1=DDMMYY, 2=YYMMDD) | |
518 tstfsz EEDATA | |
519 bra show_dateformat2 | |
520 DISPLAYTEXTH .259 ; MM/DD/YY = 0 | |
521 return | |
522 show_dateformat2: | |
523 decfsz EEDATA,F | |
524 bra show_dateformat3 | |
525 DISPLAYTEXTH .260 ; DD/MM/YY = 1 | |
526 return | |
527 show_dateformat3: | |
528 DISPLAYTEXTH .261 ; YY/MM/DD = 2 | |
529 return | |
530 | |
531 toggle_debugmode: | |
532 read_int_eeprom d'39' ; Read status | |
533 incf EEDATA,F | |
534 movlw d'1' | |
535 cpfsgt EEDATA | |
536 bra toggle_debugmode1 | |
537 clrf EEDATA | |
538 toggle_debugmode1: | |
539 write_int_eeprom d'39' ; Store status | |
540 bsf debug_mode ; set flag | |
541 movlw d'1' | |
542 cpfseq EEDATA | |
543 bcf debug_mode ; clear flag | |
544 movlw d'2' | |
545 movwf menupos | |
546 bcf switch_right | |
547 bra more_setup_menu3a ; return to manu loop | |
548 | |
549 show_debugstate: | |
550 read_int_eeprom d'39' | |
551 tstfsz EEDATA | |
552 bra show_debugstate2 | |
553 DISPLAYTEXT .131 ; OFF | |
554 show_debugstate2: | |
555 decf EEDATA,F | |
556 tstfsz EEDATA | |
557 bra show_decotype3 | |
558 DISPLAYTEXT .130 ; ON | |
559 return |