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