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