comparison src/tft_outputs.asm @ 398:1f2e35f5a5aa

BUGFIX: Make sure SP1 is always selected on start in Auto-SP mode CHANGE: Show velocity from 5m/min or more (Ascend or descent) Work on new speed graph
author heinrichsweikamp
date Mon, 23 Nov 2015 16:13:25 +0100
parents 642e927520eb
children db25f2028074
comparison
equal deleted inserted replaced
397:56f3c7026762 398:1f2e35f5a5aa
572 return 572 return
573 573
574 ;========================================================================= 574 ;=========================================================================
575 575
576 global TFT_display_velocity 576 global TFT_display_velocity
577 TFT_display_velocity: ; With divA+0 = m/min 577 TFT_display_velocity: ; With divA+0 = m/min, neg_flag_velocity: ascend=1, descend=0
578 ; Input is:
579 ; neg_flag_velocity: ascend=1, descend=0
580 ; divA+0: rate in m/min
581 ; init flags used to store warning/attention 578 ; init flags used to store warning/attention
582 bcf velocity_warn 579 bcf velocity_warn
583 bcf velocity_attn 580 bcf velocity_attn
584 ; check if old/new ascend logic is used 581
585 TSTOSS opt_vsitextv2 ; 0=standard, 1=dynamic 582 bcf STATUS,C
586 bra TFT_velocity_std ; static ascend rate limit 583 movlw velocity_display_threshold_1 ; lowest threshold for display vertical velocity
587 ; initialize the multiplier/offset values, also required for the
588 ; below-the-treshold bar
589 movlw .7
590 movwf xC+0
591 movlw .6
592 movwf xC+1
593 movlw .1
594 movwf xC+2
595 clrf xC+3
596 ; check if velocity is below the treshold level
597 bcf STATUS,C
598 movlw velocity_display_threshold_2
599 subwf divA+0,W 584 subwf divA+0,W
600 btfss STATUS,C 585 btfss STATUS,C
601 bra TFT_velocity_ntr ; ascend/descend rare is below limit 586 bra TFT_velocity_clear ; lower then threshold. Clear text and graph (If active)
602 bsf display_velocity 587
603 588 ; We have something to display
589 bsf display_velocity ; Set flag
590 ; check if descending: no warning color if descending
591 call TFT_standard_color
592 btfss neg_flag_velocity ; Ignore for descent!
593 rcall TFT_velocity_set_color
594
595 rcall TFT_velocity_disp ; Show the text
596 bcf win_invert
597 bcf neg_flag
598
599 TSTOSS opt_vsigraph ; =1: draw the graphical VSI bar
600 bra TFT_display_velocity_done ; No graph
601
602 btfsc neg_flag_velocity ; Ignore for descent!
603 rcall TFT_velocity_graph ; Show the graph
604 btfss neg_flag_velocity ; Ignore for descent!
605 rcall TFT_velocity_clear_graph ; Clear the graph for descent
606
607 TFT_display_velocity_done:
608 bra TFT_standard_color ; and return!
609
610 TFT_speed_table:
604 ; use a depth-dependent ascent rate warning 611 ; use a depth-dependent ascent rate warning
605 ; depth(ft): <20 >20 >40 >60 >75 >88 >101 >115 >128 >144 >164 612 ; depth(ft): <20 >20 >40 >60 >75 >88 >101 >115 >128 >144 >164
606 ; speed(ft/min): 23 26 29 33 36 43 49 56 59 62 66 613 ; speed(ft/min): 23 26 29 33 36 43 49 56 59 62 66
607 ; depth(m): <=6 >6 >12 >18 >23 >27 >31 >35 >39 >44 >50 614 ; depth(m): <=6 >6 >12 >18 >23 >27 >31 >35 >39 >44 >50
608 ; speed(m/min): 7 8 9 10 11 13 15 17 18 19 20 (warning) 615 ; speed(m/min): 7 8 9 10 11 13 15 17 18 19 20 (warning)
609 ; speed(m/min): 5 6 7 8 8 10 12 13 14 15 15 (attention) 616 ; speed(m/min): 5 6 7 8 8 10 12 13 14 15 15 (attention)
610 ; 617
611 ; use different multipliers and offsets for the different ascend limits for 618 ; <xx m, warning speed, attention speed, unused
612 ; a smoother bar 619 DB .6,.7,.5,.0
613 ; w-multip 7 6 5 5 4 3 3 2 2 2 2 620 DB .12,.8,.6,.0
614 ; a-multip 6 5 4 3 3 3 2 2 2 2 2 621 DB .18,.9,.7,.0
615 ; w-offset 1 2 5 0 6 11 5 16 14 12 10 622 DB .23,.10,.8,.0
616 ; a-offset 0 0 2 6 6 0 6 4 2 0 0 623 DB .27,.11,.8,.0
617 624 DB .31,.13,.10,.0
618 ; check if descending: no warning color if descending 625 DB .35,.15,.12,.0
619 call TFT_standard_color 626 DB .39,.17,.13,.0
620 btfss neg_flag_velocity ; Ignore for descent! 627 DB .44,.18,.14,.0
621 bra TFT_velocity_disp 628 DB .50,.19,.15,.0
629 DB .200,.20,.15,.0
630
631 TFT_velocity_set_color: ; Set color based on speed table
632 ; check if old/new ascend logic is used
633 ; TSTOSS opt_vsitextv2 ; 0=standard, 1=dynamic
634 ; bra TFT_velocity_std ; static ascend rate limit
635
622 ; get the actual depth 636 ; get the actual depth
623 SAFE_2BYTE_COPY rel_pressure, lo ; get the actual depth 637 SAFE_2BYTE_COPY rel_pressure, lo ; get the actual depth
624 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] 638 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
625 call convert_mbar_to_feet ; get depth in feet 639 call convert_mbar_to_feet ; get depth in feet into lo:hi
626 ; store current depth (in feet) into sub_a 640 ; ; store current depth (in feet) into sub_a
627 movff lo,sub_a+0 641 ; movff lo,sub_a+0
628 movff hi,sub_a+1 642 ; movff hi,sub_a+1
629 ; xA will be used to store the warning/attention limits passed to the verification 643 ; ; xA will be used to store the warning/attention limits passed to the verification
630 clrf xA+0 644 ; clrf xA+0
631 clrf xA+1 645 ; clrf xA+1
632 646 ;
633 ;TFT_display_velocity_asc_164: 647
634 ; store segment limit into sub_b 648 return ; Done.
635 clrf sub_b+1
636 movlw LOW d'164'
637 movwf sub_b+0
638 movlw .20 ; store the warn limit to xA+0
639 movwf xA+0
640 movlw .15 ; store the attn limit to xA+1
641 movwf xA+1
642 ; graphical position helpers
643 movlw .2
644 movwf xC+0
645 movlw .2
646 movwf xC+1
647 movlw .10
648 movwf xC+2
649 clrf xC+3
650 ; check if current depth > segment limit
651 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
652 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
653 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
654
655 ;TFT_display_velocity_asc_144:
656 ; store segment limit into sub_b
657 clrf sub_b+1
658 movlw LOW d'144'
659 movwf sub_b+0
660 movlw .19 ; store the warn limit to xA+0
661 movwf xA+0
662 movlw .15 ; store the attn limit to xA+1
663 movwf xA+1
664 ; graphical position helpers
665 movlw .2
666 movwf xC+0
667 movlw .2
668 movwf xC+1
669 movlw .12
670 movwf xC+2
671 clrf xC+3
672 ; check if current depth > segment limit
673 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
674 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
675 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
676
677 ;TFT_display_velocity_asc_128:
678 ; store segment limit into sub_b
679 clrf sub_b+1
680 movlw LOW d'128'
681 movwf sub_b+0
682 movlw .18 ; store the warn limit to xA+0
683 movwf xA+0
684 movlw .14 ; store the attn limit to xA+1
685 movwf xA+1
686 ; graphical position helpers
687 movlw .2
688 movwf xC+0
689 movlw .2
690 movwf xC+1
691 movlw .14
692 movwf xC+2
693 movlw .2
694 movwf xC+3
695 ; check if current depth > segment limit
696 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
697 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
698 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
699
700 ;TFT_display_velocity_asc_115:
701 ; store segment limit into sub_b
702 clrf sub_b+1
703 movlw LOW d'115'
704 movwf sub_b+0
705 movlw .17 ; store the warn limit to xA+0
706 movwf xA+0
707 movlw .13 ; store the attn limit to xA+1
708 movwf xA+1
709 ; graphical position helpers
710 movlw .2
711 movwf xC+0
712 movlw .2
713 movwf xC+1
714 movlw .16
715 movwf xC+2
716 movlw .4
717 movwf xC+3
718 ; check if current depth > segment limit
719 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
720 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
721 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
722
723 ;TFT_display_velocity_asc_101:
724 ; store segment limit into sub_b
725 clrf sub_b+1
726 movlw LOW d'101'
727 movwf sub_b+0
728 movlw .15 ; store the warn limit to xA+0
729 movwf xA+0
730 movlw .12 ; store the attn limit to xA+1
731 movwf xA+1
732 ; graphical position helpers
733 movlw .3
734 movwf xC+0
735 movlw .2
736 movwf xC+1
737 movlw .5
738 movwf xC+2
739 movlw .6
740 movwf xC+3
741 ; check if current depth > segment limit
742 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
743 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
744 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
745
746 ;TFT_display_velocity_asc_88:
747 ; store segment limit into sub_b
748 clrf sub_b+1
749 movlw LOW d'88'
750 movwf sub_b+0
751 movlw .13 ; store the warn limit to xA+0
752 movwf xA+0
753 movlw .10 ; store the attn limit to xA+1
754 movwf xA+1
755 ; graphical position helpers
756 movlw .3
757 movwf xC+0
758 movlw .3
759 movwf xC+1
760 movlw .11
761 movwf xC+2
762 clrf xC+3
763 ; check if current depth > segment limit
764 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
765 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
766 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
767
768 ;TFT_display_velocity_asc_75:
769 ; store segment limit into sub_b
770 clrf sub_b+1
771 movlw LOW d'75'
772 movwf sub_b+0
773 movlw .11 ; store the warn limit to xA+0
774 movwf xA+0
775 movlw .8 ; store the attn limit to xA+1
776 movwf xA+1
777 ; graphical position helpers
778 movlw .4
779 movwf xC+0
780 movlw .3
781 movwf xC+1
782 movlw .6
783 movwf xC+2
784 movlw .6
785 movwf xC+3
786 ; check if current depth > segment limit
787 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
788 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
789 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
790
791 ;TFT_display_velocity_asc_60:
792 ; store segment limit into sub_b
793 clrf sub_b+1
794 movlw LOW d'60'
795 movwf sub_b+0
796 movlw .10 ; store the warn limit to xA+0
797 movwf xA+0
798 movlw .8 ; store the attn limit to xA+1
799 movwf xA+1
800 ; graphical position helpers
801 movlw .5
802 movwf xC+0
803 movlw .3
804 movwf xC+1
805 clrf xC+2
806 movlw .6
807 movwf xC+3
808 ; check if current depth > segment limit
809 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
810 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
811 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
812
813 ;TFT_display_velocity_asc_40:
814 ; store segment limit into sub_b
815 clrf sub_b+1
816 movlw LOW d'40'
817 movwf sub_b+0
818 movlw .9 ; store the warn limit to xA+0
819 movwf xA+0
820 movlw .7 ; store the attn limit to xA+1
821 movwf xA+1
822 ; graphical position helpers
823 movlw .5
824 movwf xC+0
825 movlw .4
826 movwf xC+1
827 movlw .5
828 movwf xC+2
829 movlw .2
830 movwf xC+3
831 ; check if current depth > segment limit
832 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
833 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
834 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
835
836 ;TFT_display_velocity_asc_20:
837 ; store segment limit into sub_b
838 clrf sub_b+1
839 movlw LOW d'20'
840 movwf sub_b+0
841 movlw .8 ; store the warn limit to xA+0
842 movwf xA+0
843 movlw .6 ; store the attn limit to xA+1
844 movwf xA+1
845 ; graphical position helpers
846 movlw .6
847 movwf xC+0
848 movlw .5
849 movwf xC+1
850 movlw .2
851 movwf xC+2
852 clrf xC+3
853 ; check if current depth > segment limit
854 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
855 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
856 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
857
858 ;TFT_display_velocity_asc_n6:
859 ; no more steps, check the smallest rate
860 ; store the warn limit to xA : <20ft=23; <6m=7
861 movlw .7
862 movwf xA+0
863 movlw .5
864 movwf xA+1
865 ; graphical position helpers
866 movlw .7
867 movwf xC+0
868 movlw .6
869 movwf xC+1
870 movlw .1
871 movwf xC+2
872 clrf xC+3
873 ;bra TFT_velocity_check ; depth < 20ft / 6m
874
875 TFT_velocity_check:
876 ; move current ascent rate to lo
877 clrf hi
878 movff divA+0,lo
879 ; Velocity warn [m/min] - we receive it from xA+0
880 bcf STATUS,C
881 movff xA+0,WREG
882 ; compare the values
883 subwf lo,W ; subtract W from lo,
884 btfsc STATUS,C ; Check if C (carry flag) is set. Cleared if the larger number is subtracted from smaller one
885 bra TFT_velocity_warn ; Skip if no carry flag otherwise set to warning color
886 ; not eq or gt warning trashold, lets check if it reach the attention level
887 ; Velocity attn [m/min] - we receive it from xA+1
888 bcf STATUS,C
889 movff xA+1,WREG
890 ; compare the values
891 subwf lo,W ; subtract W from lo,
892 btfsc STATUS,C ; Check if C (carry flag) is set. Cleared if the larger number is subtracted from smaller one
893 bra TFT_velocity_attn ; Skip if no carry flag otherwise set to warning color
894 ;bra TFT_velocity_def
895
896 TFT_velocity_def:
897 call TFT_standard_color
898 bra TFT_velocity_disp
899
900 TFT_velocity_warn:
901 call TFT_warnings_color ; Set to warning color
902 bsf win_invert
903 bsf velocity_warn
904 bra TFT_velocity_disp
905
906 TFT_velocity_attn:
907 call TFT_attention_color ; Set to attention color
908 bsf velocity_attn
909 bra TFT_velocity_disp
910
911 TFT_velocity_std:
912 ; initialize the multiplier/offset values for the graphical bar
913 movlw .5
914 movwf xC+0
915 movlw .3
916 movwf xC+1
917 clrf xC+2
918 movlw .6
919 movwf xC+3
920
921 bcf STATUS,C
922 movlw velocity_display_threshold_1 ; lowest threshold for display vertical velocity
923 subwf divA+0,W
924 btfss STATUS,C
925 bra TFT_velocity_ntr ; under treshold, clear text and display VSIbar
926 bsf display_velocity
927
928 call TFT_standard_color
929 btfss neg_flag_velocity ; Ignore for descent!
930 bra TFT_velocity_disp ; Skip check!
931 bcf STATUS,C
932 movff divA+0,lo
933 movlw color_code_velocity_warn_high ; Velocity warn [m/min]
934 subwf lo,W
935 btfsc STATUS,C
936 bra TFT_velocity_std_warn
937 bcf STATUS,C
938 movff divA+0,lo
939 movlw color_code_velocity_attn_high ; Velocity attn [m/min]
940 subwf lo,W
941 btfsc STATUS,C
942 bra TFT_velocity_std_attn
943 bra TFT_velocity_disp
944
945 TFT_velocity_std_warn:
946 call TFT_warnings_color ; Set to warning color
947 bsf velocity_warn
948 bra TFT_velocity_disp
949
950 TFT_velocity_std_attn:
951 call TFT_attention_color ; Set to attention color
952 bsf velocity_attn
953 ;bra TFT_velocity_disp
954 649
955 TFT_velocity_disp: 650 TFT_velocity_disp:
956 WIN_SMALL dm_velocity_text_column, dm_velocity_text_row 651 WIN_SMALL dm_velocity_text_column, dm_velocity_text_row
957 TSTOSS opt_units ; 0=Meters, 1=Feets 652 TSTOSS opt_units ; 0=Meters, 1=Feets
958 bra TFT_velocity_metric 653 bra TFT_velocity_metric
968 movwf POSTINC2 663 movwf POSTINC2
969 bsf leftbind 664 bsf leftbind
970 output_16 665 output_16
971 bcf leftbind 666 bcf leftbind
972 STRCAT_TEXT_PRINT tVelImperial ; Unit switch 667 STRCAT_TEXT_PRINT tVelImperial ; Unit switch
973 bcf win_invert
974 bcf neg_flag
975 call TFT_velocity_VSIbar
976 call TFT_standard_color
977 return 668 return
978 669
979 TFT_velocity_metric: 670 TFT_velocity_metric:
980 movff divA+0,lo ; divA+0 = m/min 671 movff divA+0,lo ; divA+0 = m/min
981 movlw '-' 672 movlw '-'
982 btfsc neg_flag_velocity 673 btfsc neg_flag_velocity
983 movlw '+' 674 movlw '+'
984 movwf POSTINC2 675 movwf POSTINC2
985 output_99 676 output_99
986 STRCAT_TEXT_PRINT tVelMetric ; Unit switch 677 STRCAT_TEXT_PRINT tVelMetric ; Unit switch
987 bcf win_invert 678 return
988 bcf neg_flag 679
989 call TFT_velocity_VSIbar 680 TFT_velocity_graph:
990 call TFT_standard_color 681 movlw color_white
991 return 682 WIN_BOX_COLOR dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;top, bottom, left, right
992 683 return
993 TFT_velocity_VSIbar:
994 TSTOSS opt_vsigraph ; 0=skip, 1=draw
995 return
996
997 ; use another logic when descending
998 btfss neg_flag_velocity
999 bra TFT_velocity_VSIbar_desc
1000 call TFT_velocity_VSIbar_desc_clr
1001
1002 btfsc velocity_warn
1003 bra TFT_velocity_VSIbar_warn
1004 ; if all ok or attention, use attn's values
1005 movff xC+1,sub_b+0 ; multiplier
1006 movff xC+3,sub_b+1 ; offset
1007 bra TFT_velocity_VSIbar_com
1008
1009 TFT_velocity_VSIbar_warn:
1010 ; save multiplier and offset out from the xC
1011 movff xC+0,sub_b+0 ; multiplier
1012 movff xC+2,sub_b+1 ; offset
1013 ;bra TFT_velocity_VSIbar_com
1014
1015 TFT_velocity_VSIbar_com:
1016 clrf divB
1017
1018 movlw .0
1019 cpfsgt divA+0
1020 bra TFT_velocity_VSIbar_clr
1021
1022 ; multiply
1023 movff divA+0,xA+0
1024 clrf xA+1
1025 movff sub_b+0,xB+0
1026 clrf xB+1
1027 call mult16x16 ; xA*xB=xC
1028 movlw .1
1029 cpfslt xC+3
1030 bra TFT_velocity_VSIbar_max
1031 movlw .1
1032 cpfslt xC+2
1033 bra TFT_velocity_VSIbar_max
1034 movlw .1
1035 cpfslt xC+1
1036 bra TFT_velocity_VSIbar_max
1037 movlw .60
1038 cpfslt xC+0
1039 bra TFT_velocity_VSIbar_max
1040 ; add offset
1041 bcf STATUS,C
1042 movff sub_b+1,WREG
1043 addwf xC+0,1
1044 btfsc STATUS,C
1045 bra TFT_velocity_VSIbar_max
1046 ; check if out-of-range
1047 movff xC+0,divB
1048 movlw .60
1049 cpfsgt divB
1050 bra TFT_velocity_VSIbar_draw
1051
1052 TFT_velocity_VSIbar_max:
1053 movlw .60
1054 movff WREG,divB
1055
1056 TFT_velocity_VSIbar_draw:
1057 ; calculate top&height for the bar and mask
1058 ; 1. Bar: top=(bar_top+60-divB); height=divB
1059 movlw dm_velobar_top+.1
1060 movff WREG,sub_a+0 ; !!!!!! bar position must fit into lo !!
1061 movlw .60
1062 addwf sub_a+0,1
1063 clrf sub_a+1
1064 movff divB,sub_b+0
1065 clrf sub_b+1
1066 call subU16
1067
1068 movlw color_white
1069 WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right
1070
1071 movff sub_c+0,win_top
1072 movff divB,win_height
1073 movlw dm_velobar_width-.2
1074 movff WREG,win_width
1075 movff WREG,win_bargraph
1076 movlw dm_velobar_lft+.2
1077 movff WREG,win_leftx2
1078 movlw color_green
1079 call TFT_set_color
1080 btfsc velocity_attn
1081 call TFT_attention_color
1082 btfsc velocity_warn
1083 call TFT_warnings_color
1084 call TFT_box
1085
1086 ;clear the rest
1087 movlw .60
1088 cpfslt divB
1089 return ; divB !< 60 - the graph uses the full bar, no need to clear
1090
1091 ; 2. Mask: top=bar_top; height=60-divB
1092 movlw .60
1093 movff WREG,sub_a+0
1094 clrf sub_a+1
1095 movff divB,sub_b+0
1096 clrf sub_b+1
1097 call subU16 ; sub_c = sub_a - sub_b
1098
1099 movlw dm_velobar_top+.1
1100 movff WREG,win_top
1101 movff sub_c+0,win_height
1102 movlw dm_velobar_width
1103 movff WREG,win_width
1104 movff WREG,win_bargraph
1105 movlw dm_velobar_lft+.1
1106 movff WREG,win_leftx2
1107 movlw color_black
1108 call TFT_set_color
1109 call TFT_box
1110 return
1111
1112 TFT_velocity_VSIbar_desc:
1113 ; clear the ascend part of the bar
1114 call TFT_velocity_VSIbar_clr
1115
1116 TSTOSS opt_vsigraph ; 0=skip, 1=draw
1117 return
1118
1119 ; divA+0=0 is descend, clear everything if it's actually zero
1120 movlw .0
1121 cpfsgt divA+0
1122 bra TFT_velocity_VSIbar_desc_clr
1123
1124 clrf divB
1125 ; Desc uses a single multiplier/offset value: *1 / +3
1126 movlw .1
1127 movff WREG,sub_b+0 ; multiplier
1128 movlw .3
1129 movff WREG,sub_b+1 ; offset
1130 ; multiply
1131 movff divA+0,xA+0
1132 clrf xA+1
1133 movff sub_b+0,xB+0
1134 clrf xB+1
1135 call mult16x16 ; xA*xB=xC
1136 movlw .1
1137 cpfslt xC+3
1138 bra TFT_velocity_VSIbar_desc_max
1139 movlw .1
1140 cpfslt xC+2
1141 bra TFT_velocity_VSIbar_desc_max
1142 movlw .1
1143 cpfslt xC+1
1144 bra TFT_velocity_VSIbar_desc_max
1145 movlw .22
1146 cpfslt xC+1
1147 bra TFT_velocity_VSIbar_desc_max
1148 ; add offset
1149 bcf STATUS,C
1150 movff sub_b+1,WREG
1151 addwf xC+0,1
1152 btfsc STATUS,C
1153 bra TFT_velocity_VSIbar_desc_max
1154 ; check if out-of-range
1155 movff xC+0,divB
1156 movlw .22
1157 cpfsgt divB
1158 bra TFT_velocity_VSIbar_desc_draw
1159
1160 TFT_velocity_VSIbar_desc_max:
1161 movlw .22
1162 movff WREG,divB
1163
1164 TFT_velocity_VSIbar_desc_draw:
1165 ; calculate top&height for the bar and mask
1166 ; 1. Bar: top=(bar_top+63); height=divB
1167 movlw dm_velobar_top+.1
1168 movff WREG,sub_a+0
1169 movlw .62
1170 addwf sub_a+0,1
1171
1172 movlw color_white
1173 WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right
1174
1175 movff sub_a+0,win_top
1176 movff divB,win_height
1177 movlw dm_velobar_width-.2
1178 movff WREG,win_width
1179 movff WREG,win_bargraph
1180 movlw dm_velobar_lft+.2
1181 movff WREG,win_leftx2
1182 movlw color_green
1183 call TFT_set_color
1184 call TFT_box
1185
1186 ;clear the rest
1187 movlw .22
1188 cpfslt divB
1189 return ; divB !< 22 - the graph uses the full bar, no need to clear
1190
1191 ; 2. Mask: top=(bar_top+63+divB); height=(23-divB)
1192 movlw .24
1193 movff WREG,sub_a+0
1194 clrf sub_a+1
1195 movff divB,sub_b+0
1196 clrf sub_b+1
1197 call subU16 ; sub_c = sub_a - sub_b
1198
1199 movlw dm_velobar_top
1200 movff WREG,sub_a+0
1201 movlw .61
1202 addwf sub_a+0,1
1203 movff divB,WREG
1204 addwf sub_a+0,1
1205
1206 movff sub_a+0,win_top
1207 movff sub_c+0,win_height
1208 movlw dm_velobar_width
1209 movff WREG,win_width
1210 movff WREG,win_bargraph
1211 movlw dm_velobar_lft+.1
1212 movff WREG,win_leftx2
1213 movlw color_black
1214 call TFT_set_color
1215 call TFT_box
1216 return
1217
1218 TFT_velocity_VSIbar_clr: ; clears the ascend part of the bar
1219 TSTOSS opt_vsigraph ; 0=skip, 1=draw
1220 return
1221 WIN_BOX_BLACK dm_velobar_top+.1,dm_velobar_top+.63,dm_velobar_lft+.1,dm_velobar_rgt-.1
1222 if dm_offset == 0
1223 movlw color_dark_red
1224 WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right
1225 endif
1226 return
1227
1228 TFT_velocity_VSIbar_desc_clr: ; clears the descend part of the bar
1229 TSTOSS opt_vsigraph ; 0=skip, 1=draw
1230 return
1231 WIN_BOX_BLACK dm_velobar_top+.61,dm_velobar_bot-.1,dm_velobar_lft+.1,dm_velobar_rgt-.1
1232 if dm_offset == 0
1233 movlw color_dark_red
1234 WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right
1235 endif
1236 return
1237
1238 TFT_velocity_ntr: ; velocity under treshold
1239 call TFT_velocity_clear
1240 ; use another logic when descending
1241 btfss neg_flag_velocity
1242 bra TFT_velocity_VSIbar_desc
1243 bra TFT_velocity_VSIbar
1244 684
1245 global TFT_velocity_clear 685 global TFT_velocity_clear
1246 TFT_velocity_clear: 686 TFT_velocity_clear:
1247 btfss display_velocity ; Velocity was not displayed, do not delete 687 btfss display_velocity ; Velocity was not displayed, do not delete
1248 return 688 return
1249 bcf display_velocity ; Velocity was displayed, delete velocity now 689 bcf display_velocity ; Velocity was displayed, delete velocity now
1250 ; Clear Text 690 ; Clear Text
1251 WIN_BOX_BLACK dm_velocity_text_row, dm_velocity_text_bot, dm_velocity_text_column, dm_velocity_text_rgt ; top, bottom, left, right 691 WIN_BOX_BLACK dm_velocity_text_row, dm_velocity_text_bot, dm_velocity_text_column, dm_velocity_text_rgt ; top, bottom, left, right
692
693 TSTOSS opt_vsigraph ; =1: draw the graphical VSI bar
694 return ; No graph to clear
695 TFT_velocity_clear_graph:
696 ; Clear Graph
697 WIN_BOX_BLACK dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;top, bottom, left, right
1252 return 698 return
1253 699
1254 ;========================================================================= 700 ;=========================================================================
1255 701
1256 global TFT_clear_decoarea 702 global TFT_clear_decoarea