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 ; 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
|
12
|
392 movlw d'4' ; x-1 menu entries
|
0
|
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
|
12
|
431 bra show_license
|
0
|
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
|
12
|
440 show_license:
|
|
441 call startup_screen1 ;1/2
|
|
442 call startup_screen2 ;1/2
|
|
443 movlw d'3'
|
|
444 movwf menupos
|
|
445 bcf switch_right
|
|
446 bra more_setup_menu2 ; return to "more menu" loop
|
|
447
|
0
|
448 toggle_salinity:
|
|
449 ; Toggles between 1.00 and 1.04
|
|
450 read_int_eeprom d'26' ; Read Salinity from EEPROM
|
|
451 incf EEDATA,F ; Increase value
|
|
452
|
|
453 movlw d'99' ; 99% ?
|
|
454 cpfsgt EEDATA ; Salinity lower limit
|
|
455 bra toggle_salinity_reset ; Out of limit, reset value to 1.00
|
|
456 movlw d'105' ; 105% ?
|
|
457 cpfslt EEDATA ; Salinity higher limit
|
|
458 bra toggle_salinity_reset ; Out of limit, reset value to 1.00
|
|
459
|
|
460 toggle_salinity2:
|
|
461 write_int_eeprom d'26' ; Store salinity
|
|
462 movlw d'3'
|
|
463 movwf menupos
|
|
464 bcf switch_right
|
|
465 bra setup_menu3a ; return to manu loop
|
|
466
|
|
467 toggle_salinity_reset:
|
|
468 movlw d'100'
|
|
469 movwf EEDATA
|
|
470 bra toggle_salinity2 ; back
|
|
471
|
|
472 show_salinity_value:
|
|
473 read_int_eeprom d'26' ; Read Salinity from EEPROM
|
|
474 movlw d'99' ; 99% ?
|
|
475 cpfsgt EEDATA ; Salinity lower limit
|
|
476 rcall toggle_salinity_reset2 ; Reset before display!
|
|
477 movlw d'105' ; 105% ?
|
|
478 cpfslt EEDATA ; Salinity higher limit
|
|
479 rcall toggle_salinity_reset2 ; Reset before display!
|
|
480 WIN_TOP .95
|
|
481 WIN_LEFT .83
|
|
482 WIN_FONT FT_SMALL
|
|
483 lfsr FSR2,letter
|
|
484 movff EEDATA,lo
|
|
485 clrf hi
|
|
486 bsf leftbind
|
|
487 output_16dp d'3'
|
|
488 bcf leftbind
|
|
489 movlw 'k'
|
|
490 movwf POSTINC2
|
|
491 movlw 'g'
|
|
492 movwf POSTINC2
|
|
493 movlw '/'
|
|
494 movwf POSTINC2
|
|
495 movlw 'l'
|
|
496 movwf POSTINC2
|
|
497 call word_processor
|
|
498 return
|
|
499
|
|
500 toggle_salinity_reset2:
|
|
501 movlw d'100'
|
|
502 movwf EEDATA
|
|
503 write_int_eeprom d'26' ; Store salinity
|
|
504 return
|
|
505
|
|
506 toggle_datemode:
|
|
507 ; Toggles setting for
|
|
508 ; MM/DD/YY =0, Default
|
|
509 ; DD/MM/YY =1
|
|
510 ; YY/MM/DD =2
|
|
511 read_int_eeprom d'91' ; Read date format
|
|
512 incf EEDATA,F
|
|
513 movlw d'2'
|
|
514 cpfsgt EEDATA
|
|
515 bra toggle_datemode1
|
|
516 clrf EEDATA
|
|
517 toggle_datemode1:
|
|
518 write_int_eeprom d'91' ; Store date format
|
|
519 movlw d'1'
|
|
520 movwf menupos
|
|
521 bcf switch_right
|
|
522 bra more_setup_menu3a ; return to manu loop
|
|
523
|
|
524 show_dateformat:
|
|
525 read_int_eeprom d'91' ; Read date format (0=MMDDYY, 1=DDMMYY, 2=YYMMDD)
|
|
526 tstfsz EEDATA
|
|
527 bra show_dateformat2
|
|
528 DISPLAYTEXTH .259 ; MM/DD/YY = 0
|
|
529 return
|
|
530 show_dateformat2:
|
|
531 decfsz EEDATA,F
|
|
532 bra show_dateformat3
|
|
533 DISPLAYTEXTH .260 ; DD/MM/YY = 1
|
|
534 return
|
|
535 show_dateformat3:
|
|
536 DISPLAYTEXTH .261 ; YY/MM/DD = 2
|
|
537 return
|
|
538
|
|
539 toggle_debugmode:
|
|
540 read_int_eeprom d'39' ; Read status
|
|
541 incf EEDATA,F
|
|
542 movlw d'1'
|
|
543 cpfsgt EEDATA
|
|
544 bra toggle_debugmode1
|
|
545 clrf EEDATA
|
|
546 toggle_debugmode1:
|
|
547 write_int_eeprom d'39' ; Store status
|
|
548 bsf debug_mode ; set flag
|
|
549 movlw d'1'
|
|
550 cpfseq EEDATA
|
|
551 bcf debug_mode ; clear flag
|
|
552 movlw d'2'
|
|
553 movwf menupos
|
|
554 bcf switch_right
|
|
555 bra more_setup_menu3a ; return to manu loop
|
|
556
|
|
557 show_debugstate:
|
|
558 read_int_eeprom d'39'
|
|
559 tstfsz EEDATA
|
|
560 bra show_debugstate2
|
|
561 DISPLAYTEXT .131 ; OFF
|
|
562 show_debugstate2:
|
|
563 decf EEDATA,F
|
|
564 tstfsz EEDATA
|
|
565 bra show_decotype3
|
|
566 DISPLAYTEXT .130 ; ON
|
|
567 return
|