comparison code_part1/OSTC_code_asm_part1/menu_ppO2.asm @ 647:e6ac142e82b0

New Diluent Submenu in Divemode
author heinrichsweikamp
date Sun, 07 Oct 2012 21:31:19 +0200
parents 3b50c9949b84
children 86b49e47b2f5
comparison
equal deleted inserted replaced
646:06ffc99a405f 647:e6ac142e82b0
21 ; written: 08/04/04 21 ; written: 08/04/04
22 ; last updated: 120920 22 ; last updated: 120920
23 ; known bugs: 23 ; known bugs:
24 ; ToDo: 24 ; ToDo:
25 ; 25 ;
26 ; New in 2.52 Diluents stored seperately in EEPROM Bank1 26 ; New in 2.52 Diluents stored seperately in EEPROM Bank0
27 ; EEPROM BANK1 Byte96-97: 27 ; EEPROM BANK0 Byte96-97:
28 ; Diluent 1 (%O2,%He) 28 ; Diluent 1 (%O2,%He)
29 ; EEPROM BANK1 Byte98-99: 29 ; EEPROM BANK0 Byte98-99:
30 ; Diluent 2 (%O2,%He) 30 ; Diluent 2 (%O2,%He)
31 ; EEPROM BANK1 Byte100-101: 31 ; EEPROM BANK0 Byte100-101:
32 ; Diluent 3 (%O2,%He) 32 ; Diluent 3 (%O2,%He)
33 ; EEPROM BANK1 Byte102-103: 33 ; EEPROM BANK0 Byte102-103:
34 ; Diluent 4 (%O2,%He) 34 ; Diluent 4 (%O2,%He)
35 ; EEPROM BANK1 Byte104-105: 35 ; EEPROM BANK0 Byte104-105:
36 ; Diluent 5 (%O2,%He) 36 ; Diluent 5 (%O2,%He)
37 37
38 38
39 menu_const_ppO2: 39 menu_const_ppO2:
40 movlw d'1' 40 movlw d'1'
97 clrf divemins+0 ; Here: # of Gas * 4 97 clrf divemins+0 ; Here: # of Gas * 4
98 movlw d'5' 98 movlw d'5'
99 movwf waitms_temp ; here: stores row for gas list 99 movwf waitms_temp ; here: stores row for gas list
100 movlw d'94' 100 movlw d'94'
101 movwf wait_temp ; here: stores eeprom address for gas list 101 movwf wait_temp ; here: stores eeprom address for gas list
102 movlw .1
103 movwf EEADRH
104 102
105 menu_diluentsetup_list: 103 menu_diluentsetup_list:
106 WIN_LEFT .20 104 WIN_LEFT .20
107 movlw d'2' 105 movlw d'2'
108 addwf wait_temp,F ; Increase eeprom address for gas list 106 addwf wait_temp,F ; Increase eeprom address for gas list
126 movff WREG,win_top 124 movff WREG,win_top
127 lfsr FSR2,letter 125 lfsr FSR2,letter
128 126
129 incf wait_temp, W ; Gas %O2 127 incf wait_temp, W ; Gas %O2
130 movwf EEADR ; Gas %He - Set address in internal EEPROM 128 movwf EEADR ; Gas %He - Set address in internal EEPROM
131 movlw .1
132 movwf EEADRH
133 call read_eeprom ; Read He value from EEPROM 129 call read_eeprom ; Read He value from EEPROM
134 movff EEDATA,lo ; Move EEDATA -> lo 130 movff EEDATA,lo ; Move EEDATA -> lo
135 movf lo,f ; Move lo -> f 131 movf lo,f ; Move lo -> f
136 movlw d'0' ; Move 0 -> WREG 132 movlw d'0' ; Move 0 -> WREG
137 cpfsgt lo ; He > 0? 133 cpfsgt lo ; He > 0?
138 bra menu_diluentsetup_Nx ; NO check o2 134 bra menu_diluentsetup_Nx ; NO check o2
139 135
140 ; YES Write TX 15/55 136 ; YES Write TX 15/55
141 STRCAT TXT_TX3 137 STRCAT TXT_TX3
142 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM 138 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM
143 movlw .1
144 movwf EEADRH
145 call read_eeprom ; O2 value 139 call read_eeprom ; O2 value
146 movff EEDATA,lo 140 movff EEDATA,lo
147 output_8 141 output_8
148 PUTC '/' 142 PUTC '/'
149 incf EEADR,F ; Gas #hi: %He - Set address in internal EEPROM 143 incf EEADR,F ; Gas #hi: %He - Set address in internal EEPROM
150 movlw .1
151 movwf EEADRH
152 call read_eeprom ; He value 144 call read_eeprom ; He value
153 movff EEDATA,lo 145 movff EEDATA,lo
154 output_8 146 output_8
155 bra menu_diluentsetup_list0 147 bra menu_diluentsetup_list0
156 148
157 ; New v1.44se 149 ; New v1.44se
158 menu_diluentsetup_Nx: 150 menu_diluentsetup_Nx:
159 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM 151 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM
160 movlw .1
161 movwf EEADRH
162 call read_eeprom ; Read O2 value from EEPROM 152 call read_eeprom ; Read O2 value from EEPROM
163 movff EEDATA,lo ; Move EEDATA -> lo 153 movff EEDATA,lo ; Move EEDATA -> lo
164 movf lo,f ; Move lo -> f 154 movf lo,f ; Move lo -> f
165 movlw d'21' ; Move 21 -> WREG 155 movlw d'21' ; Move 21 -> WREG
166 cpfsgt lo ; o2 > 21% 156 cpfsgt lo ; o2 > 21%
200 goto menu_diluentsetup_list 190 goto menu_diluentsetup_list
201 191
202 DISPLAYTEXT .11 ; Exit 192 DISPLAYTEXT .11 ; Exit
203 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! 193 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
204 call PLED_menu_cursor 194 call PLED_menu_cursor
205 clrf EEADRH
206 195
207 menu_diluentsetup_loop: 196 menu_diluentsetup_loop:
208 call check_switches_logbook 197 call check_switches_logbook
209 198
210 btfsc menubit3 199 btfsc menubit3
305 294
306 WIN_LEFT .20 295 WIN_LEFT .20
307 WIN_TOP .35 296 WIN_TOP .35
308 STRCPY TXT_O2_4 297 STRCPY TXT_O2_4
309 movff divemins+0,EEADR 298 movff divemins+0,EEADR
310 movlw .1
311 movwf EEADRH
312 call read_eeprom ; O2 value 299 call read_eeprom ; O2 value
313 movff EEDATA,lo 300 movff EEDATA,lo
314 output_8 301 output_8
315 STRCAT_PRINT "% " 302 STRCAT_PRINT "% "
316 303
322 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG 309 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG
323 mullw d'10' 310 mullw d'10'
324 movff PRODL,xA+0 311 movff PRODL,xA+0
325 movff PRODH,xA+1 ; ppO2 in [0.01bar] * 10 312 movff PRODH,xA+1 ; ppO2 in [0.01bar] * 10
326 movff divemins+0,EEADR 313 movff divemins+0,EEADR
327 movlw .1
328 movwf EEADRH
329 call read_eeprom ; O2 value 314 call read_eeprom ; O2 value
330 movff EEDATA,xB+0 315 movff EEDATA,xB+0
331 clrf xB+1 316 clrf xB+1
332 call div16x16 ; xA/xB=xC with xA as remainder 317 call div16x16 ; xA/xB=xC with xA as remainder
333 movlw d'10' 318 movlw d'10'
343 WIN_LEFT .20 328 WIN_LEFT .20
344 WIN_TOP .65 329 WIN_TOP .65
345 STRCPY TXT_HE4 330 STRCPY TXT_HE4
346 incf divemins+0,W 331 incf divemins+0,W
347 movwf EEADR 332 movwf EEADR
348 movlw .1
349 movwf EEADRH
350 call read_eeprom ; He value 333 call read_eeprom ; He value
351 movff EEDATA,lo 334 movff EEDATA,lo
352 output_8 335 output_8
353 STRCAT_PRINT "% " 336 STRCAT_PRINT "% "
354 337
359 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG 342 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG
360 mullw d'10' 343 mullw d'10'
361 movff PRODL,xA+0 344 movff PRODL,xA+0
362 movff PRODH,xA+1 ; ppO2 in [0.01bar] * 10 345 movff PRODH,xA+1 ; ppO2 in [0.01bar] * 10
363 movff divemins+0,EEADR 346 movff divemins+0,EEADR
364 movlw .1
365 movwf EEADRH
366 call read_eeprom ; O2 value 347 call read_eeprom ; O2 value
367 movff EEDATA,xB+0 348 movff EEDATA,xB+0
368 clrf xB+1 349 clrf xB+1
369 call div16x16 ; xA/xB=xC with xA as remainder 350 call div16x16 ; xA/xB=xC with xA as remainder
370 movlw d'10' 351 movlw d'10'
378 movlw d'0' 359 movlw d'0'
379 addwfc hi,F ; lo:hi holding MOD+10m 360 addwfc hi,F ; lo:hi holding MOD+10m
380 361
381 incf divemins+0,W 362 incf divemins+0,W
382 movwf EEADR 363 movwf EEADR
383 movlw .1
384 movwf EEADRH
385 call read_eeprom ; He value in % -> EEDATA 364 call read_eeprom ; He value in % -> EEDATA
386 movlw d'100' 365 movlw d'100'
387 movwf xA+0 366 movwf xA+0
388 movf EEDATA,W ; He value in % -> EEDATA 367 movf EEDATA,W ; He value in % -> EEDATA
389 subwf xA+0,F ; xA+0 = 100 - He Value in % 368 subwf xA+0,F ; xA+0 = 100 - He Value in %
486 movwf menupos 465 movwf menupos
487 bra menu_diluentgas1 ; return 466 bra menu_diluentgas1 ; return
488 467
489 adjust_o2_diluent: 468 adjust_o2_diluent:
490 movff divemins+0,EEADR ; read current value 469 movff divemins+0,EEADR ; read current value
491 movlw .1
492 movwf EEADRH
493 call read_eeprom ; Low-value 470 call read_eeprom ; Low-value
494 movff EEDATA,lo 471 movff EEDATA,lo
495 472
496 btfsc first_FA ; Minus? 473 btfsc first_FA ; Minus?
497 bra adjust_o2_1_diluent ; yes, minus! 474 bra adjust_o2_1_diluent ; yes, minus!
510 cpfseq lo 487 cpfseq lo
511 bra adjust_o2_2_diluent 488 bra adjust_o2_2_diluent
512 489
513 incf divemins+0,W 490 incf divemins+0,W
514 movwf EEADR 491 movwf EEADR
515 movlw .1
516 movwf EEADRH
517 call read_eeprom ; read He value 492 call read_eeprom ; read He value
518 493
519 movlw d'100' 494 movlw d'100'
520 movwf lo 495 movwf lo
521 movf EEDATA,W ; He value 496 movf EEDATA,W ; He value
522 subwf lo,F ; lo=100% - He% 497 subwf lo,F ; lo=100% - He%
523 498
524 adjust_o2_2_diluent: ; test if O2+He>100... 499 adjust_o2_2_diluent: ; test if O2+He>100...
525 incf divemins+0,W 500 incf divemins+0,W
526 movwf EEADR 501 movwf EEADR
527 movlw .1
528 movwf EEADRH
529 call read_eeprom ; read He value 502 call read_eeprom ; read He value
530 movf EEDATA,W ; He value 503 movf EEDATA,W ; He value
531 addwf lo,W ; add O2 value 504 addwf lo,W ; add O2 value
532 movwf hi ; store in temp 505 movwf hi ; store in temp
533 movlw d'101' 506 movlw d'101'
538 movwf lo 511 movwf lo
539 512
540 adjust_o2_3_diluent: 513 adjust_o2_3_diluent:
541 movff divemins+0,EEADR ; save current value 514 movff divemins+0,EEADR ; save current value
542 movff lo,EEDATA 515 movff lo,EEDATA
543 movlw .1
544 movwf EEADRH
545 call write_eeprom ; Low-value 516 call write_eeprom ; Low-value
546 517
547 movlw d'1' 518 movlw d'1'
548 movwf menupos 519 movwf menupos
549 bra menu_diluentgas1 ; return 520 bra menu_diluentgas1 ; return
550 521
551 adjust_he_diluent: 522 adjust_he_diluent:
552 incf divemins+0,W 523 incf divemins+0,W
553 movwf EEADR ; read current value 524 movwf EEADR ; read current value
554 movlw .1
555 movwf EEADRH
556 call read_eeprom ; Low-value 525 call read_eeprom ; Low-value
557 movff EEDATA,lo 526 movff EEDATA,lo
558 527
559 btfsc first_FA ; Minus? 528 btfsc first_FA ; Minus?
560 bra adjust_he_1_diluent ; yes, minus! 529 bra adjust_he_1_diluent ; yes, minus!
574 clrf lo 543 clrf lo
575 544
576 adjust_he_2_diluent: ; test if O2+He>100... 545 adjust_he_2_diluent: ; test if O2+He>100...
577 incf divemins+0,W 546 incf divemins+0,W
578 movwf EEADR 547 movwf EEADR
579 movlw .1
580 movwf EEADRH
581 call read_eeprom ; read He value 548 call read_eeprom ; read He value
582 movf EEDATA,W ; He value 549 movf EEDATA,W ; He value
583 addwf lo,W ; add O2 value 550 addwf lo,W ; add O2 value
584 movwf hi ; store in temp 551 movwf hi ; store in temp
585 movlw d'101' 552 movlw d'101'
590 557
591 adjust_he_3_diluent: 558 adjust_he_3_diluent:
592 incf divemins+0,W ; save current value 559 incf divemins+0,W ; save current value
593 movwf EEADR 560 movwf EEADR
594 movff lo,EEDATA 561 movff lo,EEDATA
595 movlw .1
596 movwf EEADRH
597 call write_eeprom ; Low-value 562 call write_eeprom ; Low-value
598 563
599 movlw d'2' 564 movlw d'2'
600 movwf menupos 565 movwf menupos
601 bra menu_diluentgas1 ; 566 bra menu_diluentgas1 ;
602 567
603 restore_gas_diluent: 568 restore_gas_diluent:
604 movff divemins+0,EEADR ; save Default value (O2) 569 movff divemins+0,EEADR ; save Default value (O2)
605 movlw .1
606 movwf EEADRH
607 movlw .21 ; Always Air 570 movlw .21 ; Always Air
608 movwf EEDATA 571 movwf EEDATA
609 call write_eeprom 572 call write_eeprom
610 incf EEADR,F ; Point to He 573 incf EEADR,F ; Point to He
611 clrf EEDATA 574 clrf EEDATA
633 lfsr FSR2,letter 596 lfsr FSR2,letter
634 597
635 ;He check 598 ;He check
636 incf divemins+0,W 599 incf divemins+0,W
637 movwf EEADR 600 movwf EEADR
638 movlw .1
639 movwf EEADRH
640 call read_eeprom ; He value 601 call read_eeprom ; He value
641 movff EEDATA,lo ; Move EEData -> lo 602 movff EEDATA,lo ; Move EEData -> lo
642 movf lo,f ; Move lo -> f 603 movf lo,f ; Move lo -> f
643 movlw d'0' ; Move 0 -> WREG 604 movlw d'0' ; Move 0 -> WREG
644 cpfsgt lo ; He > 0? 605 cpfsgt lo ; He > 0?
645 bra diluent_title_bar3 ; NO check o2 606 bra diluent_title_bar3 ; NO check o2
646 607
647 ; YES Write TX 15/55 608 ; YES Write TX 15/55
648 STRCAT TXT_TX3 609 STRCAT TXT_TX3
649 movff divemins+0,EEADR 610 movff divemins+0,EEADR
650 movlw .1
651 movwf EEADRH
652 call read_eeprom ; O2 value 611 call read_eeprom ; O2 value
653 movff EEDATA,lo 612 movff EEDATA,lo
654 output_8 ; Write O2 613 output_8 ; Write O2
655 PUTC '/' 614 PUTC '/'
656 incf divemins+0,W 615 incf divemins+0,W
746 OUTPUTTEXT d'192' ; Dil. 705 OUTPUTTEXT d'192' ; Dil.
747 PUTC ' ' 706 PUTC ' '
748 707
749 movlw d'96' ; = address for O2 ratio 708 movlw d'96' ; = address for O2 ratio
750 movwf EEADR 709 movwf EEADR
751 movlw .1
752 movwf EEADRH
753 call read_eeprom ; Read O2 ratio 710 call read_eeprom ; Read O2 ratio
754 movff EEDATA, lo ; O2 ratio 711 movff EEDATA, lo ; O2 ratio
755 bsf leftbind 712 bsf leftbind
756 output_99 713 output_99
757 PUTC '/' 714 PUTC '/'
758 movlw d'97' ; = address for He ratio 715 movlw d'97' ; = address for He ratio
759 movwf EEADR 716 movwf EEADR
760 movlw .1
761 movwf EEADRH
762 call read_eeprom ; Read He ratio 717 call read_eeprom ; Read He ratio
763 movff EEDATA,lo ; And copy into hold register 718 movff EEDATA,lo ; And copy into hold register
764 clrf EEADRH
765 bsf leftbind 719 bsf leftbind
766 output_99 720 output_99
767 STRCAT_PRINT ")" 721 STRCAT_PRINT ")"
768 722
769 723