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