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 ; Gas Setup menu
|
|
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
|
|
21 ; written: 10/08/07
|
|
22 ; last updated: 080906
|
|
23 ; known bugs:
|
|
24 ; ToDo:
|
|
25
|
|
26 menu_gassetup:
|
|
27 movlw d'1'
|
|
28 movwf menupos
|
|
29
|
|
30 menu_gassetup_prelist:
|
35
|
31 call gassetup_sort_gaslist ; Sorts Gaslist according to change depth
|
|
32
|
0
|
33 call PLED_ClearScreen
|
|
34 clrf timeout_counter2
|
|
35 bcf sleepmode
|
|
36 bcf menubit2
|
|
37 bcf menubit3
|
|
38 call PLED_topline_box
|
|
39 WIN_INVERT .1 ; Init new Wordprocessor
|
|
40 DISPLAYTEXT .106 ; Gas List
|
|
41 WIN_INVERT .0 ; Init new Wordprocessor
|
|
42 clrf decodata+0 ; Here: # of gas 0-4
|
|
43 clrf divemins+0 ; Here: # of Gas * 4
|
|
44 movlw d'5'
|
|
45 movwf waitms_temp ; here: stores row for gas list
|
|
46 movlw d'2'
|
|
47 movwf wait_temp ; here: stores eeprom address for gas list
|
|
48
|
|
49 ; Changed v1.44se
|
|
50 menu_gassetup_list:
|
|
51 WIN_LEFT .20
|
|
52 movlw d'4'
|
|
53 addwf wait_temp,F ; Increase eeprom address for gas list
|
|
54 movlw d'30'
|
|
55 addwf waitms_temp,F ; Increase row
|
|
56 movf waitms_temp,W ; Load row into WREG
|
|
57 movff WREG,win_top
|
|
58 lfsr FSR2,letter
|
|
59 movlw 'G'
|
|
60 movwf POSTINC2
|
|
61 movff decodata+0,lo
|
|
62 incf lo,F
|
|
63 bsf leftbind
|
|
64 output_99
|
|
65 movlw ':'
|
|
66 movwf POSTINC2
|
|
67
|
|
68 call menu_gassetup_grey_inactive ; Sets Greyvalue for inactive gases
|
|
69 call word_processor
|
|
70 WIN_LEFT .40
|
|
71 movf waitms_temp,W ; Load row into WREG
|
|
72 movff WREG,win_top
|
|
73 lfsr FSR2,letter
|
|
74
|
|
75 movlw d'33'
|
|
76 movwf EEADR
|
|
77 call read_eeprom ; Get current startgas 1-5 # into EEDATA
|
|
78 decf EEDATA,W ; 0-4
|
|
79 cpfseq decodata+0 ; =current displayed gas #?
|
|
80 bra menu_gassetup_Tx ; no, do not display *
|
|
81 movlw '*' ; display *
|
|
82 movwf POSTINC2
|
|
83
|
|
84 ; New v1.44se
|
|
85 menu_gassetup_Tx:
|
|
86 call menu_gassetup_grey_inactive ; Sets Greyvalue for inactive gases
|
|
87 call word_processor
|
|
88
|
|
89 WIN_LEFT .48
|
|
90 movf waitms_temp,W ; Load row into WREG
|
|
91 movff WREG,win_top
|
|
92 lfsr FSR2,letter
|
|
93
|
|
94 movff wait_temp, EEADR ; Gas %He - Set address in internal EEPROM
|
|
95 incf EEADR,F ; Gas %He - Set address in internal EEPROM
|
|
96 call read_eeprom ; Read He value from EEPROM
|
|
97 movff EEDATA,lo ; Move EEDATA -> lo
|
|
98 movf lo,f ; Move lo -> f
|
|
99 movlw d'0' ; Move 0 -> WREG
|
|
100 cpfsgt lo ; He > 0?
|
|
101 bra menu_gassetup_Nx ; NO check o2
|
|
102
|
|
103 ; YES Write TX 15/55
|
|
104 call gassetup_write_Tx
|
|
105 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM
|
|
106 call read_eeprom ; O2 value
|
|
107 movff EEDATA,lo
|
|
108 output_8
|
|
109 movlw '/'
|
|
110 movwf POSTINC2
|
|
111 incf EEADR,F ; Gas #hi: %He - Set address in internal EEPROM
|
|
112 call read_eeprom ; He value
|
|
113 movff EEDATA,lo
|
|
114 output_8
|
|
115 bra menu_gassetup_list0
|
|
116
|
|
117 ; New v1.44se
|
|
118 menu_gassetup_Nx:
|
|
119 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM
|
|
120 call read_eeprom ; Read O2 value from EEPROM
|
|
121 movff EEDATA,lo ; Move EEDATA -> lo
|
|
122 movf lo,f ; Move lo -> f
|
|
123 movlw d'21' ; Move 21 -> WREG
|
|
124 cpfsgt lo ; o2 > 21%
|
|
125 bra menu_gassetup_Air ; NO AIR
|
|
126 movlw d'100' ; Move 100 -> WREG
|
|
127 cpfslt lo ; o2 < 100%
|
|
128 bra menu_gassetup_O2 ; NO write O2
|
|
129
|
|
130 ; YES Write NX 32
|
|
131 call gassetup_write_Nx
|
|
132 output_8
|
|
133 bra menu_gassetup_list0
|
|
134
|
|
135 ; New v1.44se
|
|
136 menu_gassetup_O2:
|
|
137 movlw 'O'
|
|
138 movwf POSTINC2
|
|
139 movlw '2'
|
|
140 movwf POSTINC2
|
|
141 movlw ' '
|
|
142 movwf POSTINC2
|
|
143 output_8
|
|
144 bra menu_gassetup_list0
|
|
145
|
|
146 ; New v1.44se
|
|
147 menu_gassetup_Air:
|
|
148 cpfseq lo ; o2 = 21%
|
|
149 call menu_gassetup_Err
|
|
150
|
|
151 movlw 'A'
|
|
152 movwf POSTINC2
|
|
153 movlw 'I'
|
|
154 movwf POSTINC2
|
|
155 movlw 'R'
|
|
156 movwf POSTINC2
|
|
157 movlw ' '
|
|
158 movwf POSTINC2
|
|
159 output_8
|
|
160 bra menu_gassetup_list0
|
|
161
|
|
162 ; New v1.44se
|
|
163 menu_gassetup_Err:
|
|
164 movlw 'E'
|
|
165 movwf POSTINC2
|
|
166 movlw 'R'
|
|
167 movwf POSTINC2
|
|
168 movlw 'R'
|
|
169 movwf POSTINC2
|
|
170 movlw ' '
|
|
171 movwf POSTINC2
|
|
172 output_8
|
|
173
|
|
174 ; Changed v1.44se
|
|
175 menu_gassetup_list0:
|
|
176 call menu_gassetup_grey_inactive ; Sets Greyvalue for inactive gases
|
|
177 call word_processor
|
|
178
|
|
179 WIN_LEFT .105
|
|
180 movf waitms_temp,W ; Load row into WREG
|
|
181 movff WREG,win_top
|
|
182 lfsr FSR2,letter
|
|
183
|
|
184 movlw ' '
|
|
185 movwf POSTINC2
|
|
186 movlw 'i'
|
|
187 movwf POSTINC2
|
|
188 movlw 'n'
|
|
189 movwf POSTINC2
|
|
190 movlw ' '
|
|
191 movwf POSTINC2
|
|
192 movf decodata+0,W ; read current value
|
|
193 addlw d'28' ; offset in memory
|
|
194 movwf EEADR
|
|
195 call read_eeprom ; Low-value
|
|
196 movff EEDATA,lo
|
|
197 output_8
|
|
198 movlw 'm'
|
|
199 movwf POSTINC2
|
|
200 call menu_gassetup_grey_inactive ; Sets Greyvalue for inactive gases
|
|
201 call word_processor
|
|
202
|
3
|
203 call PLED_standard_color
|
0
|
204
|
|
205 incf decodata+0,F
|
|
206 movlw d'5'
|
|
207 cpfseq decodata+0
|
|
208 goto menu_gassetup_list
|
|
209
|
|
210 DISPLAYTEXT .11 ; Exit
|
|
211 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
212 call PLED_menu_cursor
|
|
213
|
|
214 gassetup_list_loop:
|
|
215 call check_switches_logbook
|
|
216
|
|
217 btfsc menubit3
|
|
218 bra gassetup_list2 ; move cursor
|
|
219
|
|
220 btfsc menubit2
|
|
221 bra do_gassetup_list; call gas-specific submenu
|
|
222
|
|
223 btfsc divemode
|
|
224 goto restart ; dive started!
|
|
225
|
|
226 btfsc onesecupdate
|
|
227 call timeout_surfmode
|
|
228
|
|
229 btfsc onesecupdate
|
|
230 call set_dive_modes
|
|
231
|
|
232 bcf onesecupdate ; 1 sec. functions done
|
|
233
|
|
234 btfsc sleepmode
|
|
235 bra exit_gassetup_list
|
|
236
|
|
237 bra gassetup_list_loop
|
|
238
|
|
239 gassetup_list2:
|
|
240 incf menupos,F
|
|
241 movlw d'7'
|
|
242 cpfseq menupos ; =7?
|
|
243 bra gassetup_list3 ; No
|
|
244 movlw d'1'
|
|
245 movwf menupos
|
|
246
|
|
247 gassetup_list3:
|
|
248 clrf timeout_counter2
|
|
249 call PLED_menu_cursor
|
|
250
|
|
251 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
252
|
|
253 bcf menubit3 ; clear flag
|
|
254 bra gassetup_list_loop
|
|
255
|
|
256 exit_gassetup_list: ; exit...
|
|
257 movlw d'2'
|
|
258 movwf menupos
|
|
259 goto menu2
|
|
260
|
|
261 do_gassetup_list:
|
|
262 dcfsnz menupos,F
|
|
263 bra gassetup_list_edit_gas1
|
|
264 dcfsnz menupos,F
|
|
265 bra gassetup_list_edit_gas2
|
|
266 dcfsnz menupos,F
|
|
267 bra gassetup_list_edit_gas3
|
|
268 dcfsnz menupos,F
|
|
269 bra gassetup_list_edit_gas4
|
|
270 dcfsnz menupos,F
|
|
271 bra gassetup_list_edit_gas5
|
|
272 bra exit_gassetup_list ; Exit List
|
|
273
|
|
274 gassetup_list_edit_gas1:
|
|
275 movlw d'0'
|
|
276 movwf decodata+0
|
|
277 movlw d'0'
|
|
278 movwf divemins+0
|
|
279 bra menu_gassetup_page1
|
|
280
|
|
281 gassetup_list_edit_gas2:
|
|
282 movlw d'1'
|
|
283 movwf decodata+0
|
|
284 movlw d'4'
|
|
285 movwf divemins+0
|
|
286 bra menu_gassetup_page1
|
|
287
|
|
288 gassetup_list_edit_gas3:
|
|
289 movlw d'2'
|
|
290 movwf decodata+0
|
|
291 movlw d'8'
|
|
292 movwf divemins+0
|
|
293 bra menu_gassetup_page1
|
|
294
|
|
295 gassetup_list_edit_gas4:
|
|
296 movlw d'3'
|
|
297 movwf decodata+0
|
|
298 movlw d'12'
|
|
299 movwf divemins+0
|
|
300 bra menu_gassetup_page1
|
|
301
|
|
302 gassetup_list_edit_gas5:
|
|
303 movlw d'4'
|
|
304 movwf decodata+0
|
|
305 movlw d'16'
|
|
306 movwf divemins+0
|
|
307 bra menu_gassetup_page1
|
|
308
|
|
309 menu_gassetup_page1:
|
|
310 movlw d'1'
|
|
311 movwf menupos
|
|
312 bcf gas_setup_page2 ; Page 1 of gassetup
|
|
313 bcf menubit4
|
|
314 bcf cursor
|
|
315 bcf sleepmode
|
|
316 bcf first_FA ; Here: =1: -, =0: +
|
|
317
|
|
318 menu_gassetup0:
|
|
319 call PLED_ClearScreen
|
|
320 DISPLAYTEXT .30 ; More...
|
|
321 DISPLAYTEXT .11 ; Exit
|
|
322
|
|
323 menu_gassetup1:
|
|
324 clrf timeout_counter2
|
|
325 bcf menubit2
|
|
326 bcf menubit3
|
|
327
|
|
328 rcall gassetup_title_bar2 ; Displays the title bar with the current Gas info
|
|
329
|
|
330 WIN_TOP .65
|
|
331 WIN_LEFT .20
|
|
332 lfsr FSR2,letter
|
|
333 movlw 'O'
|
|
334 movwf POSTINC2
|
|
335 movlw '2'
|
|
336 movwf POSTINC2
|
|
337 movlw ':'
|
|
338 movwf POSTINC2
|
|
339 movlw ' '
|
|
340 movwf POSTINC2
|
|
341
|
|
342 movf divemins+0,W
|
|
343 addlw 0x06
|
|
344 movwf EEADR
|
|
345 call read_eeprom ; O2 value
|
|
346 movff EEDATA,lo
|
|
347 output_8
|
|
348 movlw '%'
|
|
349 movwf POSTINC2
|
|
350 movlw ' '
|
|
351 movwf POSTINC2
|
|
352 movlw '('
|
|
353 movwf POSTINC2
|
|
354 movlw 'M'
|
|
355 movwf POSTINC2
|
|
356 movlw 'O'
|
|
357 movwf POSTINC2
|
|
358 movlw 'D'
|
|
359 movwf POSTINC2
|
|
360 movlw ':'
|
|
361 movwf POSTINC2
|
|
362
|
|
363 ; Show MOD in m
|
|
364 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG
|
|
365 mullw d'10'
|
|
366 movff PRODL,xA+0
|
|
367 movff PRODH,xA+1 ; ppO2 in [0.01Bar] * 10
|
|
368
|
|
369 movf divemins+0,W
|
|
370 addlw 0x06
|
|
371 movwf EEADR
|
|
372 call read_eeprom ; O2 value
|
|
373 movff EEDATA,xB+0
|
|
374 clrf xB+1
|
|
375 call div16x16 ;xA/xB=xC with xA as remainder
|
|
376 movlw d'10'
|
|
377 subwf xC+0,F ; Subtract 10m...
|
|
378 movff xC+0,lo
|
|
379 movlw d'0'
|
|
380 subwfb xC+1,F
|
|
381 movff xC+1,hi
|
|
382 output_16
|
|
383 movlw 'm'
|
|
384 movwf POSTINC2
|
|
385 movlw ')'
|
|
386 movwf POSTINC2
|
|
387 movlw ' '
|
|
388 movwf POSTINC2
|
|
389 movlw ' '
|
|
390 movwf POSTINC2
|
|
391 call word_processor
|
|
392
|
|
393 WIN_TOP .95
|
|
394 lfsr FSR2,letter
|
|
395 movlw 'H'
|
|
396 movwf POSTINC2
|
|
397 movlw 'e'
|
|
398 movwf POSTINC2
|
|
399 movlw ':'
|
|
400 movwf POSTINC2
|
|
401 movlw ' '
|
|
402 movwf POSTINC2
|
|
403 movf divemins+0,W
|
|
404 addlw 0x07
|
|
405 movwf EEADR
|
|
406 call read_eeprom ; He value
|
|
407 movff EEDATA,lo
|
|
408 output_8
|
|
409 movlw '%'
|
|
410 movwf POSTINC2
|
|
411 movlw ' '
|
|
412 movwf POSTINC2
|
|
413 movlw ' '
|
|
414 movwf POSTINC2
|
|
415 call word_processor
|
|
416
|
|
417 WIN_TOP .125
|
|
418 lfsr FSR2,letter
|
|
419 movlw '+'
|
|
420 movwf POSTINC2
|
|
421 movlw '/'
|
|
422 movwf POSTINC2
|
|
423 movlw '-'
|
|
424 movwf POSTINC2
|
|
425 movlw ':'
|
|
426 movwf POSTINC2
|
|
427 movlw ' '
|
|
428 movwf POSTINC2
|
|
429 movlw '+'
|
|
430 btfsc first_FA
|
|
431 movlw '-'
|
|
432 movwf POSTINC2
|
|
433 call word_processor
|
|
434
|
|
435 WIN_TOP .155
|
|
436 lfsr FSR2,letter
|
|
437 OUTPUTTEXT .89 ; Default:
|
|
438 movf divemins+0,W
|
|
439 addlw 0x04
|
|
440 movwf EEADR
|
|
441 call read_eeprom ; Default O2 value
|
|
442 movff EEDATA,lo
|
|
443 output_8
|
|
444 movlw '/'
|
|
445 movwf POSTINC2
|
|
446 movf divemins+0,W
|
|
447 addlw 0x05
|
|
448 movwf EEADR
|
|
449 call read_eeprom ; Default He value
|
|
450 movff EEDATA,lo
|
|
451 output_8
|
|
452 movlw ' '
|
|
453 movwf POSTINC2
|
|
454 movlw ' '
|
|
455 movwf POSTINC2
|
|
456 call word_processor
|
|
457
|
|
458 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
459 call PLED_menu_cursor
|
|
460
|
|
461 gassetup_loop:
|
|
462 call check_switches_logbook
|
|
463
|
|
464 btfsc menubit3
|
|
465 bra gassetup2 ; move cursor
|
|
466
|
|
467 btfsc menubit2
|
|
468 bra do_gassetup ; call submenu
|
|
469
|
|
470 btfsc divemode
|
|
471 goto restart ; dive started!
|
|
472
|
|
473 btfsc onesecupdate
|
|
474 call timeout_surfmode
|
|
475
|
|
476 btfsc onesecupdate
|
|
477 call set_dive_modes
|
|
478
|
|
479 bcf onesecupdate ; 1 sec. functions done
|
|
480
|
|
481 btfsc sleepmode
|
|
482 bra exit_gassetup
|
|
483
|
|
484 bra gassetup_loop
|
|
485
|
|
486 gassetup2:
|
|
487 incf menupos,F
|
|
488 movlw d'7'
|
|
489 cpfseq menupos ; =7?
|
|
490 bra gassetup3 ; No
|
|
491 movlw d'1'
|
|
492 movwf menupos
|
|
493
|
|
494 gassetup3:
|
|
495
|
|
496 clrf timeout_counter2
|
|
497 call PLED_menu_cursor
|
|
498
|
|
499 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
500
|
|
501 bcf menubit3 ; clear flag
|
|
502 bra gassetup_loop
|
|
503
|
|
504 do_gassetup:
|
|
505 dcfsnz menupos,F
|
|
506 bra next_gas_page
|
|
507 dcfsnz menupos,F
|
|
508 bra adjust_o2
|
|
509 dcfsnz menupos,F
|
|
510 bra adjust_he
|
|
511 dcfsnz menupos,F
|
|
512 bra toggle_plus_minus_gassetup
|
|
513 dcfsnz menupos,F
|
|
514 bra restore_gas
|
|
515 exit_gassetup: ; exit...
|
|
516 movff decodata+0,menupos
|
|
517 incf menupos,F
|
|
518 bra menu_gassetup_prelist
|
|
519
|
|
520 toggle_plus_minus_gassetup:
|
|
521 btg first_FA
|
|
522 movlw d'4'
|
|
523 movwf menupos
|
|
524 bra menu_gassetup1 ; return
|
|
525
|
|
526 next_gas:
|
|
527 movlw d'1'
|
|
528 movwf menupos
|
|
529 bra menu_gassetup0 ; incl. clear screen
|
|
530
|
|
531 adjust_o2:
|
|
532 movf divemins+0,W ; read current value
|
|
533 addlw 0x06
|
|
534 movwf EEADR
|
|
535 call read_eeprom ; Low-value
|
|
536 movff EEDATA,lo
|
|
537
|
|
538 btfsc first_FA ; Minus?
|
|
539 bra adjust_o2_1 ; yes, minus!
|
|
540
|
|
541 incf lo,F ; increase O2
|
|
542 movlw d'101'
|
|
543 cpfseq lo
|
|
544 bra adjust_o2_2
|
|
545 movlw d'4' ; LOWER O2 Limit
|
|
546 movwf lo
|
|
547 bra adjust_o2_2
|
|
548
|
|
549 adjust_o2_1:
|
|
550 decf lo,F ; decrease O2
|
|
551 movlw d'3'
|
|
552 cpfseq lo
|
|
553 bra adjust_o2_2
|
|
554
|
|
555 movf divemins+0,W
|
|
556 addlw 0x07
|
|
557 movwf EEADR
|
|
558 call read_eeprom ; read He value
|
|
559
|
|
560 movlw d'100'
|
|
561 movwf lo
|
|
562 movf EEDATA,W ; He value
|
|
563 subwf lo,F ; lo=100% - He%
|
|
564
|
|
565 adjust_o2_2: ; test if O2+He>100...
|
|
566 movf divemins+0,W
|
|
567 addlw 0x07
|
|
568 movwf EEADR
|
|
569 call read_eeprom ; read He value
|
|
570 movf EEDATA,W ; He value
|
|
571 addwf lo,W ; add O2 value
|
|
572 movwf hi ; store in temp
|
|
573 movlw d'101'
|
|
574 cpfseq hi ; O2 and He > 100?
|
|
575 bra adjust_o2_3 ; No!
|
|
576
|
|
577 movlw d'4' ; LOWER O2 Limit
|
|
578 movwf lo
|
|
579
|
|
580 adjust_o2_3:
|
|
581 movf divemins+0,W ; save current value
|
|
582 addlw 0x06
|
|
583 movwf EEADR
|
|
584 movff lo,EEDATA
|
|
585 call write_eeprom ; Low-value
|
|
586
|
|
587 movlw d'2'
|
|
588 movwf menupos
|
|
589 bra menu_gassetup1
|
|
590
|
|
591 adjust_he:
|
|
592 movf divemins+0,W ; read current value
|
|
593 addlw 0x07
|
|
594 movwf EEADR
|
|
595 call read_eeprom ; Low-value
|
|
596 movff EEDATA,lo
|
|
597
|
|
598 btfsc first_FA ; Minus?
|
|
599 bra adjust_he_1 ; yes, minus!
|
|
600
|
|
601 incf lo,F
|
|
602 movlw d'92' ; He limited to (useless) 90%
|
|
603 cpfseq lo
|
|
604 bra adjust_he_2
|
|
605 clrf lo
|
|
606 bra adjust_he_2
|
|
607
|
|
608 adjust_he_1:
|
|
609 decf lo,F ; decrease He
|
|
610 movlw d'255'
|
|
611 cpfseq lo
|
|
612 bra adjust_he_2
|
|
613 clrf lo
|
|
614
|
|
615 adjust_he_2: ; test if O2+He>100...
|
|
616 movf divemins+0,W
|
|
617 addlw 0x06
|
|
618 movwf EEADR
|
|
619 call read_eeprom ; read He value
|
|
620 movf EEDATA,W ; He value
|
|
621 addwf lo,W ; add O2 value
|
|
622 movwf hi ; store in temp
|
|
623 movlw d'101'
|
|
624 cpfseq hi ; O2 and He > 100?
|
|
625 bra adjust_he_3 ; No!
|
|
626 ; clrf lo ; Yes, clear He to zero
|
|
627 decf lo,F ; reduce He again = unchanged after operation
|
|
628
|
|
629 adjust_he_3:
|
|
630 movf divemins+0,W ; save current value
|
|
631 addlw 0x07
|
|
632 movwf EEADR
|
|
633 movff lo,EEDATA
|
|
634 call write_eeprom ; Low-value
|
|
635
|
|
636 movlw d'3'
|
|
637 movwf menupos
|
|
638 bra menu_gassetup1 ;
|
|
639
|
|
640 restore_gas:
|
|
641 movf divemins+0,W ; read Default value
|
|
642 addlw 0x04
|
|
643 movwf EEADR
|
|
644 call read_eeprom ; Low-value
|
|
645 movff EEDATA,lo
|
|
646 movf divemins+0,W
|
|
647 addlw 0x05
|
|
648 movwf EEADR
|
|
649 call read_eeprom ; High-value
|
|
650 movff EEDATA,hi
|
|
651
|
|
652 movf divemins+0,W ; save Default value
|
|
653 addlw 0x06
|
|
654 movwf EEADR
|
|
655 movff lo,EEDATA
|
|
656 call write_eeprom ; Low-value
|
|
657 movf divemins+0,W
|
|
658 addlw 0x07
|
|
659 movwf EEADR
|
|
660 movff hi,EEDATA
|
|
661 call write_eeprom ; High-value
|
|
662
|
|
663 movlw d'5'
|
|
664 movwf menupos
|
|
665 bra menu_gassetup1 ;
|
|
666
|
|
667
|
|
668 next_gas_page:
|
|
669 call PLED_ClearScreen
|
|
670 movlw d'1'
|
|
671 movwf menupos
|
|
672 DISPLAYTEXT .109 ; Back
|
|
673
|
|
674 DISPLAYTEXT .11 ; Exit
|
|
675
|
|
676 next_gas_page1:
|
|
677 clrf timeout_counter2
|
|
678 bcf menubit2
|
|
679 bcf menubit3
|
|
680
|
|
681 rcall gassetup_title_bar2 ; Displays the title bar with the current Gas info
|
|
682 rcall gassetup_show_ppO2 ; Display the ppO2 of the change depth with the current gas
|
|
683
|
|
684 WIN_TOP .65
|
|
685 WIN_LEFT .20
|
|
686 lfsr FSR2,letter
|
|
687 OUTPUTTEXT .105 ; "Active Gas? "
|
|
688 read_int_eeprom d'27' ; read flag register
|
|
689
|
|
690 ; hi contains active gas flags in BIT0:4 ....
|
|
691
|
|
692 movff decodata+0,lo ; Gas 0-4
|
|
693 incf lo,F ; Gas 1-5
|
|
694
|
|
695 active_gas_display:
|
|
696 rrcf EEDATA ; roll flags into carry
|
|
697 decfsz lo,F ; max. 5 times...
|
|
698 bra active_gas_display
|
|
699
|
|
700 btfss STATUS,C ; test carry
|
|
701 bra active_gas_display_no
|
|
702
|
|
703 OUTPUTTEXT .96 ; Yes
|
|
704 bra active_gas_display_end
|
|
705
|
|
706 active_gas_display_no:
|
|
707 movlw ' ' ; three spaces instead of "Yes"
|
|
708 movwf POSTINC2
|
|
709 movlw ' '
|
|
710 movwf POSTINC2
|
|
711 movlw ' '
|
|
712 movwf POSTINC2
|
|
713
|
|
714 active_gas_display_end:
|
|
715 call word_processor
|
|
716
|
|
717 WIN_TOP .95
|
|
718 WIN_LEFT .20
|
|
719 lfsr FSR2,letter
|
|
720 OUTPUTTEXT .88 ; First Gas?
|
|
721 movlw ' '
|
|
722 movwf POSTINC2
|
|
723
|
|
724 movlw d'33'
|
|
725 movwf EEADR
|
|
726 call read_eeprom ; Get current startgas 1-5 # into EEDATA
|
|
727 decf EEDATA,W ; 0-4
|
|
728 cpfseq decodata+0 ; =current displayed gas #?
|
|
729 bra menu_firstgas0 ; no, display three spaces
|
|
730
|
|
731 OUTPUTTEXT .96 ; Yes
|
|
732 bra menu_firstgas1
|
|
733
|
|
734 menu_firstgas0:
|
|
735 movlw ' '
|
|
736 movwf POSTINC2
|
|
737 movlw ' '
|
|
738 movwf POSTINC2
|
|
739 movlw ' '
|
|
740 movwf POSTINC2
|
|
741
|
|
742 menu_firstgas1:
|
|
743 call word_processor
|
|
744
|
|
745 WIN_TOP .125
|
|
746 WIN_LEFT .20
|
|
747 lfsr FSR2,letter
|
|
748 OUTPUTTEXT .107 ; Change+
|
|
749 call word_processor
|
|
750
|
|
751 WIN_TOP .155
|
|
752 WIN_LEFT .20
|
|
753 lfsr FSR2,letter
|
|
754 OUTPUTTEXT .108 ; Change-
|
|
755 call word_processor
|
|
756
|
|
757 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
758 call PLED_menu_cursor
|
|
759
|
|
760 next_gas_page_loop:
|
|
761 call check_switches_logbook
|
|
762
|
|
763 btfsc menubit3
|
|
764 bra next_gas_page2 ; move cursor
|
|
765
|
|
766 btfsc menubit2
|
|
767 bra do_next_gas_page ; call submenu
|
|
768
|
|
769 btfsc divemode
|
|
770 goto restart ; dive started!
|
|
771
|
|
772 btfsc onesecupdate
|
|
773 call timeout_surfmode
|
|
774
|
|
775 btfsc onesecupdate
|
|
776 call set_dive_modes
|
|
777
|
|
778 bcf onesecupdate ; 1 sec. functions done
|
|
779
|
|
780 btfsc sleepmode
|
|
781 bra exit_gassetup
|
|
782
|
|
783 bra next_gas_page_loop
|
|
784
|
|
785 next_gas_page2:
|
|
786 incf menupos,F
|
|
787
|
|
788 movlw d'7'
|
|
789 cpfseq menupos ; =7?
|
|
790 bra next_gas_page3 ; No
|
|
791 movlw d'1'
|
|
792 movwf menupos
|
|
793
|
|
794 next_gas_page3:
|
|
795 clrf timeout_counter2
|
|
796 call PLED_menu_cursor
|
|
797
|
|
798 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
799
|
|
800 bcf menubit3 ; clear flag
|
|
801 bra next_gas_page_loop
|
|
802
|
|
803 do_next_gas_page:
|
|
804 dcfsnz menupos,F
|
|
805 bra next_gas
|
|
806 dcfsnz menupos,F
|
|
807 bra toggle_active_gas
|
|
808 dcfsnz menupos,F
|
|
809 bra make_first_gas
|
|
810 dcfsnz menupos,F
|
|
811 bra change_gas_depth_plus
|
|
812 dcfsnz menupos,F
|
|
813 bra change_gas_depth_minus
|
|
814 bra exit_gassetup ; Exit menu
|
|
815
|
|
816 make_first_gas:
|
|
817 movff decodata+0,EEDATA ; current gas (0-4) into EEDATA
|
|
818 incf EEDATA,F ; current gas (1-5) into EEDATA
|
|
819 movlw d'33'
|
|
820 movwf EEADR
|
|
821 call write_eeprom ; store in internal EEPROM
|
|
822 movlw d'3'
|
|
823 movwf menupos
|
|
824 bra next_gas_page1
|
|
825
|
|
826 toggle_active_gas:
|
|
827 read_int_eeprom d'27' ; read flag register
|
|
828 movff decodata+0,lo ; selected gas 0-4
|
|
829 incf lo,F
|
|
830 dcfsnz lo,F
|
|
831 btg EEDATA,0
|
|
832 dcfsnz lo,F
|
|
833 btg EEDATA,1
|
|
834 dcfsnz lo,F
|
|
835 btg EEDATA,2
|
|
836 dcfsnz lo,F
|
|
837 btg EEDATA,3
|
|
838 dcfsnz lo,F
|
|
839 btg EEDATA,4
|
|
840 write_int_eeprom d'27' ; write flag register
|
|
841 movlw d'2'
|
|
842 movwf menupos
|
|
843 bra next_gas_page1
|
|
844
|
|
845 change_gas_depth_plus:
|
|
846 movf decodata+0,W ; read current value
|
|
847 addlw d'28' ; offset in memory
|
|
848 movwf EEADR
|
|
849 call read_eeprom ; Low-value
|
|
850 movff EEDATA,lo
|
|
851
|
|
852 incf lo,F ; increase depth
|
|
853 movlw d'100' ; Change depth limit + 1
|
|
854 cpfseq lo
|
|
855 bra change_gas_depth_plus2
|
|
856 movlw d'99' ; Change depth limit
|
|
857 movwf lo
|
|
858 change_gas_depth_plus2:
|
|
859 movff lo,EEDATA ; write result
|
|
860 call write_eeprom ; save result in EEPROM
|
|
861
|
|
862 movlw d'4'
|
|
863 movwf menupos
|
|
864 bra next_gas_page1
|
|
865
|
|
866
|
|
867 change_gas_depth_minus:
|
|
868 movf decodata+0,W ; read current value
|
|
869 addlw d'28' ; offset in memory
|
|
870 movwf EEADR
|
|
871 call read_eeprom ; Low-value
|
|
872 movff EEDATA,lo
|
|
873
|
|
874 decf lo,F ; decrease depth
|
|
875 movlw d'255'
|
|
876 cpfseq lo
|
|
877 bra change_gas_depth_minus2
|
|
878 movlw d'0'
|
|
879 movwf lo
|
|
880
|
|
881 change_gas_depth_minus2:
|
|
882 movff lo,EEDATA ; write result
|
|
883 call write_eeprom ; save result in EEPROM
|
|
884
|
|
885 movlw d'5'
|
|
886 movwf menupos
|
|
887 bra next_gas_page1
|
|
888
|
|
889 ; Changed v1.44se
|
|
890 gassetup_title_bar2:
|
|
891 call PLED_topline_box
|
|
892 WIN_INVERT .1 ; Init new Wordprocessor
|
|
893 WIN_TOP .2
|
|
894 WIN_LEFT .0
|
|
895 lfsr FSR2,letter
|
|
896 OUTPUTTEXT .95 ; Gas#
|
|
897 movff decodata+0,lo
|
|
898 incf lo,F
|
|
899 bsf leftbind
|
|
900 output_99
|
|
901 movlw ':'
|
|
902 movwf POSTINC2
|
|
903 movlw ' '
|
|
904 movwf POSTINC2
|
|
905 call word_processor
|
|
906
|
|
907 WIN_TOP .2
|
|
908 WIN_LEFT .50
|
|
909 lfsr FSR2,letter
|
|
910
|
|
911 ;He check
|
|
912 movf divemins+0,W
|
|
913 addlw 0x07
|
|
914 movwf EEADR
|
|
915 call read_eeprom ; He value
|
|
916 movff EEDATA,lo ; Move EEData -> lo
|
|
917 movf lo,f ; Move lo -> f
|
|
918 movlw d'0' ; Move 0 -> WREG
|
|
919 cpfsgt lo ; He > 0?
|
|
920 bra gassetup_title_bar3 ; NO check o2
|
|
921
|
|
922 ; YES Write TX 15/55
|
|
923 call gassetup_write_Tx ; Write TX
|
|
924 movf divemins+0,W
|
|
925 addlw 0x06
|
|
926 movwf EEADR
|
|
927 call read_eeprom ; O2 value
|
|
928 movff EEDATA,lo
|
|
929 output_8 ; Write O2
|
|
930 movlw '/'
|
|
931 movwf POSTINC2
|
|
932 movf divemins+0,W
|
|
933 addlw 0x07
|
|
934 movwf EEADR
|
|
935 call read_eeprom ; He value
|
|
936 movff EEDATA,lo
|
|
937 output_8 ; Write He
|
|
938 bra gassetup_title_bar7
|
|
939
|
|
940 ; New v1.44se
|
|
941 gassetup_title_bar3: ; O2 Check
|
|
942 movf divemins+0,W
|
|
943 addlw 0x06
|
|
944 movwf EEADR
|
|
945 call read_eeprom ; O2 value
|
|
946 movff EEDATA,lo
|
|
947 movf lo,f ; Move lo -> f
|
|
948 movlw d'21' ; Move 21 -> WREG
|
|
949 cpfseq lo ; o2 = 21
|
|
950 cpfsgt lo ; o2 > 21%
|
|
951 bra gassetup_title_bar5 ; NO AIR
|
|
952 movlw d'100' ; Move 100 -> WREG
|
|
953 cpfslt lo ; o2 < 100%
|
|
954 bra gassetup_title_bar4 ; NO write O2
|
|
955
|
|
956 ; YES Write NX 32
|
|
957 call gassetup_write_Nx
|
|
958 output_8
|
|
959 bra gassetup_title_bar7
|
|
960
|
|
961 ; New v1.44se
|
|
962 gassetup_title_bar4:
|
|
963 movlw 'O'
|
|
964 movwf POSTINC2
|
|
965 movlw '2'
|
|
966 movwf POSTINC2
|
|
967 movlw ' '
|
|
968 movwf POSTINC2
|
|
969 output_8
|
|
970 bra gassetup_title_bar7
|
|
971
|
|
972 ; New v1.44se
|
|
973 gassetup_title_bar5:
|
|
974 cpfseq lo ; o2 = 21%
|
|
975 bra gassetup_title_bar6
|
|
976
|
|
977 movlw 'A'
|
|
978 movwf POSTINC2
|
|
979 movlw 'I'
|
|
980 movwf POSTINC2
|
|
981 movlw 'R'
|
|
982 movwf POSTINC2
|
|
983 movlw ' '
|
|
984 movwf POSTINC2
|
|
985 output_8
|
|
986 bra gassetup_title_bar7
|
|
987
|
|
988 ; New v1.44se
|
|
989 gassetup_title_bar6: ; ERROR
|
|
990 movlw 'E'
|
|
991 movwf POSTINC2
|
|
992 movlw 'R'
|
|
993 movwf POSTINC2
|
|
994 movlw 'R'
|
|
995 movwf POSTINC2
|
|
996 movlw ' '
|
|
997 movwf POSTINC2
|
|
998 output_8
|
|
999 bra gassetup_title_bar7
|
|
1000
|
|
1001 gassetup_title_bar7:
|
|
1002 movlw ' '
|
|
1003 movwf POSTINC2
|
|
1004 movlw 'i'
|
|
1005 movwf POSTINC2
|
|
1006 movlw 'n'
|
|
1007 movwf POSTINC2
|
|
1008 movlw ' '
|
|
1009 movwf POSTINC2
|
|
1010 movf decodata+0,W ; read current value
|
|
1011 addlw d'28' ; offset in memory
|
|
1012 movwf EEADR
|
|
1013 call read_eeprom ; Low-value
|
|
1014 movff EEDATA,lo
|
|
1015 output_8
|
|
1016 movlw 'm'
|
|
1017 movwf POSTINC2
|
|
1018 movlw ' '
|
|
1019 movwf POSTINC2
|
|
1020
|
|
1021 call word_processor
|
|
1022 WIN_INVERT .0 ; Init new Wordprocessor
|
|
1023 return
|
|
1024
|
|
1025 ; New v1.44se
|
|
1026 gassetup_write_Nx:
|
|
1027 movlw 'N'
|
|
1028 movwf POSTINC2
|
|
1029 movlw 'X'
|
|
1030 movwf POSTINC2
|
|
1031 movlw ' '
|
|
1032 movwf POSTINC2
|
|
1033 return
|
|
1034
|
|
1035 ; New v1.44se
|
|
1036 gassetup_write_Tx:
|
|
1037 movlw 'T'
|
|
1038 movwf POSTINC2
|
|
1039 movlw 'X'
|
|
1040 movwf POSTINC2
|
|
1041 movlw ' '
|
|
1042 movwf POSTINC2
|
|
1043 return
|
|
1044
|
|
1045 ; New v1.44se
|
|
1046 menu_gassetup_grey_inactive:
|
|
1047 ; Set Greyvalue to lower value when gas is inactive
|
|
1048 read_int_eeprom d'27' ; read flag register
|
|
1049 movff decodata+0,lo ; copy gas number 0-4
|
|
1050 incf lo,F ; 1-5
|
|
1051 menu_gassetup_list1:
|
|
1052 rrcf EEDATA ; roll flags into carry
|
|
1053 decfsz lo,F ; max. 5 times...
|
|
1054 bra menu_gassetup_list1
|
3
|
1055
|
0
|
1056 btfss STATUS,C ; test carry
|
3
|
1057 bra menu_gassetup_list1_grey
|
|
1058
|
|
1059 GETCUSTOM8 d'35' ;movlw color_white
|
|
1060 call PLED_set_color ; grey out inactive gases!
|
|
1061 return
|
|
1062
|
|
1063 menu_gassetup_list1_grey:
|
0
|
1064 movlw color_grey
|
|
1065 call PLED_set_color ; grey out inactive gases!
|
|
1066 return
|
|
1067
|
|
1068 gassetup_show_ppO2:
|
|
1069 movf divemins+0,W
|
|
1070 addlw 0x06
|
|
1071 movwf EEADR
|
|
1072 call read_eeprom ; O2 value
|
|
1073 movff EEDATA,hi
|
|
1074
|
|
1075 movf decodata+0,W ; read current value
|
|
1076 addlw d'28' ; offset in memory
|
|
1077 movwf EEADR
|
|
1078 call read_eeprom ; Change depth in m
|
|
1079 movff EEDATA,lo
|
|
1080 movlw d'10'
|
|
1081 addwf lo,F ; Depth+10m=lo
|
|
1082 movf hi,W
|
|
1083 mulwf lo ; (Depth+10m)*O2
|
|
1084 movff PRODL,xA+0
|
|
1085 movff PRODH,xA+1
|
|
1086 movlw d'10'
|
|
1087 movwf xB+0
|
|
1088 clrf xB+1
|
|
1089 call div16x16 ;xA/xB=xC with xA as remainder
|
|
1090 movff xC+0,lo ; ((Depth+10m)*O2)/10 = [0.01Bar] ppO2
|
|
1091 movff xC+1,hi
|
|
1092
|
|
1093 WIN_LEFT .55
|
|
1094 WIN_TOP .35
|
|
1095 lfsr FSR2,letter
|
|
1096 movlw '('
|
|
1097 movwf POSTINC2
|
|
1098 movlw 'p'
|
|
1099 movwf POSTINC2
|
|
1100 movlw 'p'
|
|
1101 movwf POSTINC2
|
|
1102 movlw 'O'
|
|
1103 movwf POSTINC2
|
|
1104 movlw '2'
|
|
1105 movwf POSTINC2
|
|
1106 movlw ':'
|
|
1107 movwf POSTINC2
|
|
1108 output_16dp d'3'
|
|
1109 movlw 'B'
|
|
1110 movwf POSTINC2
|
|
1111 movlw 'a'
|
|
1112 movwf POSTINC2
|
|
1113 movlw 'r'
|
|
1114 movwf POSTINC2
|
|
1115 movlw ')'
|
|
1116 movwf POSTINC2
|
|
1117 movlw ' '
|
|
1118 movwf POSTINC2
|
|
1119 call word_processor
|
35
|
1120 return
|
|
1121
|
|
1122
|
|
1123 gassetup_sort_gaslist: ; Sorts Gaslist according to change depth
|
|
1124 ; EEPROM Locations of Gaslist
|
|
1125 ; Gas1:
|
|
1126 ; O2 Default:4
|
|
1127 ; He Default:5
|
|
1128 ; O2 Current:6
|
|
1129 ; He Current:7
|
|
1130 ; Change: 28
|
|
1131 ; Active: 27,0
|
|
1132
|
|
1133 ; Gas2:
|
|
1134 ; O2 Default:8
|
|
1135 ; He Default:9
|
|
1136 ; O2 Current:10
|
|
1137 ; He Current:11
|
|
1138 ; Change: 29
|
|
1139 ; Active: 27,1
|
|
1140
|
|
1141 ; Gas3:
|
|
1142 ; O2 Default:12
|
|
1143 ; He Default:13
|
|
1144 ; O2 Current:14
|
|
1145 ; He Current:15
|
|
1146 ; Change: 30
|
|
1147 ; Active: 27,2
|
|
1148
|
|
1149 ; Gas4:
|
|
1150 ; O2 Default:16
|
|
1151 ; He Default:17
|
|
1152 ; O2 Current:18
|
|
1153 ; He Current:19
|
|
1154 ; Change: 31
|
|
1155 ; Active: 27,3
|
|
1156
|
|
1157 ; Gas5:
|
|
1158 ; O2 Default:20
|
|
1159 ; He Default:21
|
|
1160 ; O2 Current:22
|
|
1161 ; He Current:23
|
|
1162 ; Change: 32
|
|
1163 ; Active: 27,4
|
|
1164
|
|
1165 ; First Gas: 33 (1-5)
|
|
1166
|
0
|
1167 return |