comparison code_part1/OSTC_code_asm_part1/menu_logbook.asm @ 243:38cccd304970

more information in logbook: Gaslist, Salinity, Gradient Factors and Average depth displayed in Logbook
author heinrichsweikamp
date Wed, 23 Mar 2011 21:34:11 +0100
parents cdba979821ee
children 976260083540
comparison
equal deleted inserted replaced
242:ba5309c01dd7 243:38cccd304970
134 btfss logbook_profile_view ; Display profile (search routine is used in profileview, too) 134 btfss logbook_profile_view ; Display profile (search routine is used in profileview, too)
135 bra menu_logbook_display_loop ; No, display overwiev list 135 bra menu_logbook_display_loop ; No, display overwiev list
136 136
137 movf divesecs,W ; divenumber that is searched 137 movf divesecs,W ; divenumber that is searched
138 cpfseq divenumber ; current divenumber 138 cpfseq divenumber ; current divenumber
139 bra next_logbook ; No match, continue search 139 goto next_logbook ; No match, continue search
140 bra display_profile2 140 bra display_profile2
141 141
142 142
143 menu_logbook_display_loop: 143 menu_logbook_display_loop:
144 btfsc all_dives_shown ; All dives displayed? 144 btfsc all_dives_shown ; All dives displayed?
145 bra menu_logbook_display_loop2 ; Yes, but display first page again. 145 bra menu_logbook_display_loop2 ; Yes, but display first page again.
146 146
147 rcall display_listdive ; display short header for list on current list position 147 call display_listdive ; display short header for list on current list position
148 148
149 movlw d'5' 149 movlw d'5'
150 cpfseq menupos ; first dive on list (top place)? 150 cpfseq menupos ; first dive on list (top place)?
151 bra menu_logbook_display_loop1 ; no, so skip saving of address 151 bra menu_logbook_display_loop1 ; no, so skip saving of address
152 152
166 movlw d'0' 166 movlw d'0'
167 subwfb max_pressure+1,F 167 subwfb max_pressure+1,F
168 168
169 menu_logbook_display_loop1: 169 menu_logbook_display_loop1:
170 decfsz menupos,F ; List full? 170 decfsz menupos,F ; List full?
171 bra next_logbook ; no, search another dive for our current logbook page 171 goto next_logbook ; no, search another dive for our current logbook page
172 172
173 menu_logbook_display_loop2: 173 menu_logbook_display_loop2:
174 btfss logbook_page_not_empty ; Was there one dive at all? 174 btfss logbook_page_not_empty ; Was there one dive at all?
175 bra menu_logbook ; Yes, so reload the first page 175 bra menu_logbook ; Yes, so reload the first page
176 176
200 200
201 menu_logbook_loop: 201 menu_logbook_loop:
202 call check_switches_logbook 202 call check_switches_logbook
203 203
204 btfsc menubit3 ; SET/MENU? 204 btfsc menubit3 ; SET/MENU?
205 bra next_logbook3 ; adjust cursor or create new page 205 goto next_logbook3 ; adjust cursor or create new page
206 206
207 btfsc menubit2 ; ENTER? 207 btfsc menubit2 ; ENTER?
208 bra display_profile_or_exit ; view details/profile or exit logbook 208 bra display_profile_or_exit ; view details/profile or exit logbook
209 209
210 btfsc onesecupdate 210 btfsc onesecupdate
219 goto menu ; Yes 219 goto menu ; Yes
220 220
221 btfsc divemode 221 btfsc divemode
222 goto restart ; Enter Divemode if required 222 goto restart ; Enter Divemode if required
223 223
224 bra menu_logbook_loop ; Wait for something to do 224 goto menu_logbook_loop ; Wait for something to do
225 225
226 display_profile_or_exit: 226 display_profile_or_exit:
227 bcf menubit2 ; debounce 227 bcf menubit2 ; debounce
228 movlw d'6' ; exit? 228 movlw d'6' ; exit?
229 cpfseq menupos 229 cpfseq menupos
461 movff hi,lo ; Minutes 461 movff hi,lo ; Minutes
462 output_99x 462 output_99x
463 bcf leftbind 463 bcf leftbind
464 call word_processor ; display 3rd page of details 464 call word_processor ; display 3rd page of details
465 465
466 movff eeprom_address+0,avr_rel_pressure+0
467 movff eeprom_address+1,avr_rel_pressure+1 ; Pointer to Gaslist (For Page 2)
468
466 incf_eeprom_address d'18' ; Skip 18Bytes in EEPROM (faster) 469 incf_eeprom_address d'18' ; Skip 18Bytes in EEPROM (faster)
467 470 ; 18bytes gases, battery, firmware number
468 ; Do not remove comments below!
469 ; call I2CREAD2 ; Skip Gas1 current O2
470 ; call I2CREAD2 ; Skip Gas1 current HE
471 ; call I2CREAD2 ; Skip Gas2 current O2
472 ; call I2CREAD2 ; Skip Gas2 current HE
473 ; call I2CREAD2 ; Skip Gas3 current O2
474 ; call I2CREAD2 ; Skip Gas3 current HE
475 ; call I2CREAD2 ; Skip Gas4 current O2
476 ; call I2CREAD2 ; Skip Gas4 current HE
477 ; call I2CREAD2 ; Skip Gas5 current O2
478 ; call I2CREAD2 ; Skip Gas5 current HE
479 ; call I2CREAD2 ; Skip Gas6 current O2
480 ; call I2CREAD2 ; Skip Gas6 current HE
481 ; call I2CREAD2 ; Skip Start Gas
482 ; call I2CREAD2 ; Skip Firmware x
483 ; call I2CREAD2 ; Skip Firmware y
484 ; call I2CREAD2 ; Skip battery
485 ; call I2CREAD2 ; Skip battery
486 ; call I2CREAD2 ; Skip Sampling rate
487
488 call I2CREAD2 ; Read divisor 471 call I2CREAD2 ; Read divisor
489 movff SSPBUF,divisor_temperature ; Store divisor 472 movff SSPBUF,divisor_temperature ; Store divisor
490 bcf divisor_temperature,4 ; Clear information length 473 bcf divisor_temperature,4 ; Clear information length
491 bcf divisor_temperature,5 474 bcf divisor_temperature,5
492 bcf divisor_temperature,6 475 bcf divisor_temperature,6
506 movff SSPBUF,divisor_ppo2 ; Store divisor 489 movff SSPBUF,divisor_ppo2 ; Store divisor
507 call I2CREAD2 ; Read divisor 490 call I2CREAD2 ; Read divisor
508 movff SSPBUF,divisor_deco_debug ; Store divisor 491 movff SSPBUF,divisor_deco_debug ; Store divisor
509 call I2CREAD2 ; Read divisor 492 call I2CREAD2 ; Read divisor
510 movff SSPBUF,divisor_nuy2 ; Store divisor 493 movff SSPBUF,divisor_nuy2 ; Store divisor
511 call I2CREAD2 ; Read Salinity 494 incf_eeprom_address d'2' ; Skip 2Bytes in EEPROM (faster)
512 call I2CREAD2 ; Skip GF_HI (Upper nibble), GF_LO (Lower nibble) 495 ; 2 bytes salinity, GF
513 496
514 display_profile2d: 497 display_profile2d:
515 ; Start Profile display 498 ; Start Profile display
499
500 clrf average_depth_hold_total+0
501 clrf average_depth_hold_total+1
502 clrf average_depth_hold_total+2
503 clrf average_depth_hold_total+3 ; Track average depth here...
504
516 ; Write 0m X-Line.. 505 ; Write 0m X-Line..
517 movlw color_grey 506 movlw color_grey
518 call PLED_set_color ; Make this configurable? 507 call PLED_set_color ; Make this configurable?
519 508
520 movlw d'75' 509 movlw d'75'
591 incf profile_temp2+0,F ; Zero, Increase! 580 incf profile_temp2+0,F ; Zero, Increase!
592 581
593 profile_display_loop2: 582 profile_display_loop2:
594 rcall profile_view_get_depth ; reads depth, ignores temp and profile data -> hi, lo 583 rcall profile_view_get_depth ; reads depth, ignores temp and profile data -> hi, lo
595 584
585 movf lo,w
586 addwf average_depth_hold_total+0,F
587 movf hi,w
588 addwfc average_depth_hold_total+1,F
589 movlw d'0'
590 addwfc average_depth_hold_total+2,F
591 addwfc average_depth_hold_total+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar
592
596 btfsc second_FD ; end-of profile reached? 593 btfsc second_FD ; end-of profile reached?
597 bra profile_display_loop_done ; Yes, skip all remaining pixels 594 bra profile_display_loop_done ; Yes, skip all remaining pixels
598 595
599 movff sim_pressure+0,xB+0 ; devide pressure in mbar/quant for row offsett 596 movff sim_pressure+0,xB+0 ; devide pressure in mbar/quant for row offsett
600 movff sim_pressure+1,xB+1 597 movff sim_pressure+1,xB+1
626 623
627 decfsz ignore_digits,F ; counts x-pixels to zero 624 decfsz ignore_digits,F ; counts x-pixels to zero
628 bra profile_display_loop ; Not ready yet 625 bra profile_display_loop ; Not ready yet
629 ; Done. 626 ; Done.
630 profile_display_loop_done: 627 profile_display_loop_done:
628 movlw d'159'
629 subfwb ignore_digits,W ; keep number of X-pixels (For average depth display on Page 3)
630 movwf average_divesecs+0 ; Store here for compatibility
631
631 bcf sleepmode ; clear some flags 632 bcf sleepmode ; clear some flags
632 bcf menubit2 633 bcf menubit2
633 bcf menubit3 634 bcf menubit3
634 bcf switch_right 635 bcf switch_right
635 bcf switch_left 636 bcf switch_left
636 clrf timeout_counter2 637 clrf timeout_counter2
637 638
638 display_profile_loop: 639 display_profile_loop:
639 call check_switches_logbook 640 call check_switches_logbook
640
641 btfsc menubit2 ; SET/MENU? 641 btfsc menubit2 ; SET/MENU?
642 bra exit_profileview ; back to list 642 bra exit_profileview ; back to list
643 643 btfsc menubit3 ; ENTER?
644 bra profileview_page2 ; Switch to Page2 of profile view
645 btfsc onesecupdate
646 call timeout_surfmode ; timeout
647 btfsc onesecupdate
648 call set_dive_modes ; check, if divemode must be entered
649 bcf onesecupdate ; one second update
650 btfsc sleepmode ; Timeout?
651 bra exit_profileview ; back to list
652 btfsc divemode
653 goto restart ; Enter Divemode if required
654 bra display_profile_loop ; wait for something to do
655
656
657 profileview_page2:
658 WIN_BOX_BLACK .0, .74, .0, .159 ;top, bottom, left, right
659
660 movff avr_rel_pressure+0,eeprom_address+0
661 movff avr_rel_pressure+1,eeprom_address+1 ; Pointer to Gaslist
662
663 call PLED_standard_color
664 bsf leftbind
665 WIN_TOP .0
666 WIN_LEFT .0
667 STRCPY "G1:"
668 call I2CREAD2 ; Gas1 current O2
669 movff SSPBUF,lo
670 output_99x
671 PUTC '/'
672 call I2CREAD2 ; Gas1 current HE
673 movff SSPBUF,lo
674 output_8
675 call word_processor ; Display Gas information
676
677 WIN_TOP .25
678 STRCPY "G2:"
679 call I2CREAD2 ; Gas2 current O2
680 movff SSPBUF,lo
681 output_8
682 PUTC '/'
683 call I2CREAD2 ; Gas2 current HE
684 movff SSPBUF,lo
685 output_8
686 call word_processor ; Display Gas information
687
688 WIN_TOP .50
689 STRCPY "G3:"
690 call I2CREAD2 ; Gas3 current O2
691 movff SSPBUF,lo
692 output_8
693 PUTC '/'
694 call I2CREAD2 ; Gas3 current HE
695 movff SSPBUF,lo
696 output_8
697 call word_processor ; Display Gas information
698
699 WIN_TOP .0
700 WIN_LEFT .60
701 STRCPY "G4:"
702 call I2CREAD2 ; Gas4 current O2
703 movff SSPBUF,lo
704 output_8
705 PUTC '/'
706 call I2CREAD2 ; Gas4 current HE
707 movff SSPBUF,lo
708 output_8
709 call word_processor ; Display Gas information
710
711 WIN_TOP .25
712 STRCPY "G5:"
713 call I2CREAD2 ; Gas5 current O2
714 movff SSPBUF,lo
715 output_8
716 PUTC '/'
717 call I2CREAD2 ; Gas5 current HE
718 movff SSPBUF,lo
719 output_8
720 call word_processor ; Display Gas information
721
722 WIN_TOP .50
723 STRCPY "G6:"
724 call I2CREAD2 ; Gas6 current O2
725 movff SSPBUF,lo
726 output_8
727 PUTC '/'
728 call I2CREAD2 ; Gas6 current HE
729 movff SSPBUF,lo
730 output_8
731 call word_processor ; Display Gas information
732
733 WIN_TOP .0
734 WIN_LEFT .120
735 STRCPY "1st:"
736 call I2CREAD2 ; Start Gas
737 movff SSPBUF,lo
738 output_8
739 call word_processor ; Display Gas information
740
741 WIN_TOP .25
742 STRCPY "V"
743 call I2CREAD2 ; Firmware x
744 movff SSPBUF,lo
745 output_8
746 PUTC '.'
747 call I2CREAD2 ; Firmware y
748 movff SSPBUF,lo
749 output_8
750 call word_processor ; Display Gas information
751 bcf leftbind ; Clear flag
752
753 WIN_TOP .50
754 lfsr FSR2,letter
755 call I2CREAD2 ; Battery lo
756 movff SSPBUF,lo
757 call I2CREAD2 ; Battery hi
758 movff SSPBUF,hi
759 movlw d'1'
760 movwf ignore_digits
761 bsf ignore_digit5 ; do not display mV
762 bsf leftbind
763 output_16dp d'2' ; e.g. 3.45V
764 bcf leftbind
765 STRCAT_PRINT "V"
766
767 bcf leftbind ; Clear flag
768
769 ; call I2CREAD2 ; Skip Sampling rate
770
771 bcf menubit2
772 bcf menubit3
773 bcf switch_right
774 bcf switch_left
775 clrf timeout_counter2
776 display_profile2_loop:
777 call check_switches_logbook
778 btfsc menubit2 ; SET/MENU?
779 bra exit_profileview ; back to list
780 btfsc menubit3 ; ENTER?
781 bra profileview_page3 ; Switch to Page3 of profile view
782 btfsc onesecupdate
783 call timeout_surfmode ; timeout
784 btfsc onesecupdate
785 call set_dive_modes ; check, if divemode must be entered
786 bcf onesecupdate ; one second update
787 btfsc sleepmode ; Timeout?
788 bra exit_profileview ; back to list
789 btfsc divemode
790 goto restart ; Enter Divemode if required
791 bra display_profile2_loop ; wait for something to do
792
793 profileview_page3:
794 WIN_BOX_BLACK .0, .74, .0, .159 ;top, bottom, left, right
795
796 call PLED_standard_color
797
798 movff avr_rel_pressure+0,eeprom_address+0
799 movff avr_rel_pressure+1,eeprom_address+1 ; Pointer to Gaslist
800
801 incf_eeprom_address d'24' ; Point to "Salinity"
802 bsf leftbind
803 WIN_TOP .0
804 WIN_LEFT .0
805 call I2CREAD2 ; read Salinity
806 lfsr FSR2,letter
807 movff SSPBUF,lo
808 clrf hi
809 output_16dp d'3'
810 STRCAT_PRINT "kg/l"
811
812 call I2CREAD2 ; Skip GF_HI (Upper nibble), GF_LO (Lower nibble)
813 movff SSPBUF,lo
814 movlw b'11110000' ; mask GF hi
815 andwf lo,F
816 WIN_TOP .25
817 STRCPY "GF_hi:"
818 output_8
819 call word_processor ; Display Gas information
820
821 movff SSPBUF,lo
822 movlw b'00001111' ; mask GF lo
823 andwf lo,F
824 WIN_TOP .50
825 STRCPY "GF_lo:"
826 output_8
827 call word_processor ; Display Gas information
828
829 WIN_TOP .0
830 WIN_LEFT .65
831 movff average_divesecs+0,xB+0
832 clrf xB+1 ; Number of x-pixels displayed
833 movff average_depth_hold_total+0,xC+0
834 movff average_depth_hold_total+1,xC+1
835 movff average_depth_hold_total+2,xC+2
836 movff average_depth_hold_total+3,xC+3
837 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
838 STRCPY "Avr:"
839 movff xC+0,lo
840 movff xC+1,hi
841 output_16dp d'3' ; Average depth (Re-calculated from the drawn profile - not 100% exact!)
842 STRCAT_PRINT "m"
843
844 ; WIN_TOP .25
845 ; WIN_LEFT .65
846 ; lfsr FSR2,letter
847 ; movff average_divesecs+0,lo
848 ; output_8
849 ; call word_processor
850
851 bcf menubit2
852 bcf menubit3
853 bcf switch_right
854 bcf switch_left
855 clrf timeout_counter2
856 display_profile3_loop:
857 call check_switches_logbook
858 btfsc menubit2 ; SET/MENU?
859 bra exit_profileview ; back to list
644 btfsc menubit3 ; ENTER? 860 btfsc menubit3 ; ENTER?
645 bra exit_profileview ; back to list 861 bra exit_profileview ; back to list
646 ; bra profileview_menu ; Switch to the Profileview menu
647
648 btfsc onesecupdate 862 btfsc onesecupdate
649 call timeout_surfmode ; timeout 863 call timeout_surfmode ; timeout
650
651 btfsc onesecupdate 864 btfsc onesecupdate
652 call set_dive_modes ; check, if divemode must be entered 865 call set_dive_modes ; check, if divemode must be entered
653
654 bcf onesecupdate ; one second update 866 bcf onesecupdate ; one second update
655
656 btfsc sleepmode ; Timeout? 867 btfsc sleepmode ; Timeout?
657 bra exit_profileview ; back to list 868 bra exit_profileview ; back to list
658
659 btfsc divemode 869 btfsc divemode
660 goto restart ; Enter Divemode if required 870 goto restart ; Enter Divemode if required
661 871 bra display_profile3_loop ; wait for something to do
662 bra display_profile_loop ; wait for something to do 872
873
663 874
664 profile_display_fill: ; In this column between this row (xC+0) and the last row (apnoe_mins), keep xC+0!! 875 profile_display_fill: ; In this column between this row (xC+0) and the last row (apnoe_mins), keep xC+0!!
665 ; First, check if xC+0>apnoe_mins or xC+0<aponoe_mins 876 ; First, check if xC+0>apnoe_mins or xC+0<aponoe_mins
666 movf xC+0,W 877 movf xC+0,W
667 cpfseq apnoe_mins ; xC+0 = apone_mins? 878 cpfseq apnoe_mins ; xC+0 = apone_mins?
750 clrf menupos3 ; here: used row on current page 961 clrf menupos3 ; here: used row on current page
751 movlw d'5' 962 movlw d'5'
752 movwf menupos ; here: active row on current page 963 movwf menupos ; here: active row on current page
753 incf menupos2,F ; start new page 964 incf menupos2,F ; start new page
754 call PLED_ClearScreen ; clear details/profile 965 call PLED_ClearScreen ; clear details/profile
755 bra menu_logbook1b ; start search 966 goto menu_logbook1b ; start search
756 967
757 next_logbook2: 968 next_logbook2:
758 btfsc all_dives_shown ; all shown 969 btfsc all_dives_shown ; all shown
759 goto menu_logbook1 ; all reset 970 goto menu_logbook1 ; all reset
760 971
794 clrf timeout_counter2 1005 clrf timeout_counter2
795 call PLED_logbook_cursor 1006 call PLED_logbook_cursor
796 1007
797 bcf switch_right 1008 bcf switch_right
798 bcf menubit3 ; clear flag 1009 bcf menubit3 ; clear flag
799 bra menu_logbook_loop 1010 goto menu_logbook_loop
800 1011
801 display_listdive: 1012 display_listdive:
802 bsf logbook_page_not_empty ; Page not empty 1013 bsf logbook_page_not_empty ; Page not empty
803 incf menupos3,F 1014 incf menupos3,F
804 1015