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
|
|
48 bcf switch_left
|
|
49 bcf switch_right
|
|
50
|
|
51 menu_loop:
|
|
52 call check_switches_menu
|
|
53
|
|
54 btfsc menubit2
|
|
55 bra do_menu ; call submenu
|
|
56
|
|
57 btfss menubit
|
|
58 goto restart ; exit menu, restart
|
|
59
|
|
60 btfsc onesecupdate
|
|
61 call timeout_surfmode
|
|
62
|
|
63 btfsc onesecupdate
|
|
64 call set_dive_modes
|
|
65
|
|
66 btfsc onesecupdate
|
|
67 call test_charger ; check if charger IC is active
|
|
68
|
|
69 btfsc onesecupdate
|
|
70 call get_battery_voltage ; get battery voltage
|
|
71
|
|
72 bcf onesecupdate ; End of one second tasks
|
|
73
|
|
74 btfsc sleepmode
|
|
75 goto restart
|
|
76
|
|
77 btfsc divemode
|
|
78 goto restart ; exit menu, restart and enter divemode
|
|
79
|
|
80 bra menu_loop
|
|
81
|
|
82 check_switches_menu: ; checks switches
|
|
83 btfss switch_right
|
|
84 bra check_switches_menu2
|
|
85 bsf menubit3
|
|
86 incf menupos,F
|
|
87 movlw d'6'
|
|
88 cpfsgt menupos
|
|
89 bra refresh_cursor
|
|
90 movlw d'1'
|
|
91 movwf menupos
|
|
92 bra refresh_cursor
|
|
93 check_switches_menu2:
|
|
94 btfsc switch_left
|
|
95 bsf menubit2 ; Enter!
|
|
96 return
|
|
97
|
|
98
|
|
99 do_menu: ; calls submenu
|
|
100 dcfsnz menupos,F
|
|
101 goto menu_logbook
|
|
102 dcfsnz menupos,F
|
|
103 goto menu_gassetup
|
|
104 dcfsnz menupos,F
|
|
105 goto menu_reset
|
|
106 dcfsnz menupos,F
|
|
107 goto setup_menu
|
|
108 dcfsnz menupos,F
|
|
109 goto more_menu
|
|
110 dcfsnz menupos,F
|
|
111 goto restart ; exit...
|
|
112
|
|
113 refresh_cursor:
|
|
114 clrf timeout_counter2
|
|
115 btfsc cursor
|
|
116 call PLED_menu_cursor
|
|
117 bcf switch_right
|
|
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
|
12
|
362 movlw d'4' ; 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
|
|
403 bra setup_menu ; spare
|
|
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
|
12
|
410 show_license:
|
|
411 call startup_screen1 ;1/2
|
|
412 call startup_screen2 ;1/2
|
|
413 movlw d'3'
|
|
414 movwf menupos
|
|
415 bcf switch_right
|
|
416 bra more_setup_menu2 ; return to "more menu" loop
|
|
417
|
0
|
418 toggle_salinity:
|
|
419 ; Toggles between 1.00 and 1.04
|
|
420 read_int_eeprom d'26' ; Read Salinity from EEPROM
|
|
421 incf EEDATA,F ; Increase value
|
|
422
|
|
423 movlw d'99' ; 99% ?
|
|
424 cpfsgt EEDATA ; Salinity lower limit
|
|
425 bra toggle_salinity_reset ; Out of limit, reset value to 1.00
|
|
426 movlw d'105' ; 105% ?
|
|
427 cpfslt EEDATA ; Salinity higher limit
|
|
428 bra toggle_salinity_reset ; Out of limit, reset value to 1.00
|
|
429
|
|
430 toggle_salinity2:
|
|
431 write_int_eeprom d'26' ; Store salinity
|
|
432 movlw d'3'
|
|
433 movwf menupos
|
|
434 bcf switch_right
|
|
435 bra setup_menu3a ; return to manu loop
|
|
436
|
|
437 toggle_salinity_reset:
|
|
438 movlw d'100'
|
|
439 movwf EEDATA
|
|
440 bra toggle_salinity2 ; back
|
|
441
|
|
442 show_salinity_value:
|
|
443 read_int_eeprom d'26' ; Read Salinity from EEPROM
|
|
444 movlw d'99' ; 99% ?
|
|
445 cpfsgt EEDATA ; Salinity lower limit
|
|
446 rcall toggle_salinity_reset2 ; Reset before display!
|
|
447 movlw d'105' ; 105% ?
|
|
448 cpfslt EEDATA ; Salinity higher limit
|
|
449 rcall toggle_salinity_reset2 ; Reset before display!
|
|
450 WIN_TOP .95
|
183
|
451 WIN_LEFT .90 ; +7 for spanish
|
0
|
452 WIN_FONT FT_SMALL
|
|
453 lfsr FSR2,letter
|
|
454 movff EEDATA,lo
|
|
455 clrf hi
|
|
456 bsf leftbind
|
|
457 output_16dp d'3'
|
|
458 bcf leftbind
|
123
|
459 STRCAT_PRINT "kg/l"
|
0
|
460 return
|
|
461
|
|
462 toggle_salinity_reset2:
|
|
463 movlw d'100'
|
|
464 movwf EEDATA
|
|
465 write_int_eeprom d'26' ; Store salinity
|
|
466 return
|
|
467
|
|
468 toggle_datemode:
|
|
469 ; Toggles setting for
|
|
470 ; MM/DD/YY =0, Default
|
|
471 ; DD/MM/YY =1
|
|
472 ; YY/MM/DD =2
|
|
473 read_int_eeprom d'91' ; Read date format
|
|
474 incf EEDATA,F
|
|
475 movlw d'2'
|
|
476 cpfsgt EEDATA
|
|
477 bra toggle_datemode1
|
|
478 clrf EEDATA
|
|
479 toggle_datemode1:
|
|
480 write_int_eeprom d'91' ; Store date format
|
|
481 movlw d'1'
|
|
482 movwf menupos
|
|
483 bcf switch_right
|
|
484 bra more_setup_menu3a ; return to manu loop
|
|
485
|
|
486 show_dateformat:
|
|
487 read_int_eeprom d'91' ; Read date format (0=MMDDYY, 1=DDMMYY, 2=YYMMDD)
|
|
488 tstfsz EEDATA
|
|
489 bra show_dateformat2
|
|
490 DISPLAYTEXTH .259 ; MM/DD/YY = 0
|
|
491 return
|
|
492 show_dateformat2:
|
|
493 decfsz EEDATA,F
|
|
494 bra show_dateformat3
|
|
495 DISPLAYTEXTH .260 ; DD/MM/YY = 1
|
|
496 return
|
|
497 show_dateformat3:
|
|
498 DISPLAYTEXTH .261 ; YY/MM/DD = 2
|
|
499 return
|
|
500
|
|
501 toggle_debugmode:
|
|
502 read_int_eeprom d'39' ; Read status
|
|
503 incf EEDATA,F
|
|
504 movlw d'1'
|
|
505 cpfsgt EEDATA
|
|
506 bra toggle_debugmode1
|
|
507 clrf EEDATA
|
|
508 toggle_debugmode1:
|
|
509 write_int_eeprom d'39' ; Store status
|
|
510 bsf debug_mode ; set flag
|
|
511 movlw d'1'
|
|
512 cpfseq EEDATA
|
|
513 bcf debug_mode ; clear flag
|
|
514 movlw d'2'
|
|
515 movwf menupos
|
|
516 bcf switch_right
|
|
517 bra more_setup_menu3a ; return to manu loop
|
|
518
|
|
519 show_debugstate:
|
|
520 read_int_eeprom d'39'
|
|
521 tstfsz EEDATA
|
|
522 bra show_debugstate2
|
|
523 DISPLAYTEXT .131 ; OFF
|
|
524 show_debugstate2:
|
|
525 decf EEDATA,F
|
|
526 tstfsz EEDATA
|
|
527 bra show_decotype3
|
|
528 DISPLAYTEXT .130 ; ON
|
|
529 return
|