comparison src/tft_outputs.asm @ 310:453a3d13570f new_screen_layout

VSIbar #2: ascend bar + max-depth title alignment. Debug: bar-frame, zero-line, sim+- 0.1m
author janos_kovacs <kovjanos@gmail.com>
date Mon, 08 Jun 2015 01:36:05 +0200
parents efb53af0d62a
children 4f83470dcece
comparison
equal deleted inserted replaced
309:efb53af0d62a 310:453a3d13570f
536 WIN_TINY dm_mask_divetime_column,dm_mask_divetime_row 536 WIN_TINY dm_mask_divetime_column,dm_mask_divetime_row
537 STRCAT_TEXT_PRINT tDivetime 537 STRCAT_TEXT_PRINT tDivetime
538 endif 538 endif
539 539
540 ; DEBUG !!! 540 ; DEBUG !!!
541 movlw color_dark_red
542 call TFT_set_color
543 WIN_FRAME_COLOR16 dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;top, bottom, left, right
544
541 movlw color_blue 545 movlw color_blue
542 WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right 546 WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right
543 547
544 call TFT_standard_color 548 call TFT_standard_color
545 return 549 return
551 555
552 ;========================================================================= 556 ;=========================================================================
553 557
554 global TFT_display_velocity 558 global TFT_display_velocity
555 TFT_display_velocity: ; With divA+0 = m/min 559 TFT_display_velocity: ; With divA+0 = m/min
556 560 ; init flags used to store warning/attention
561 bcf velocity_warn
562 bcf velocity_attn
563
564 ; check if old/new ascend logic is used
557 TSTOSS opt_vsitextv2 ; 0=standard, 1=dynamic 565 TSTOSS opt_vsitextv2 ; 0=standard, 1=dynamic
558 bra TFT_dispay_velocity_std 566 bra TFT_dispay_velocity_std
559 567
560 ; Input is: 568 ; Input is:
561 ; neg_flag: ascend=1, descend=0 569 ; neg_flag: ascend=1, descend=0
562 ; divA+0: rate in m/min 570 ; divA+0: rate in m/min
563 571
564 movlw velocity_display_threshold_2 ; lowest threshold for display vertical velocity 572 ; check if velocity is below the treshold level
573 movlw velocity_display_threshold_2
565 subwf divA+0,W 574 subwf divA+0,W
566 btfss STATUS,C 575 btfss STATUS,C
567 bra TFT_display_velocity_clear 576 bra TFT_display_velocity_ntr
568 bsf display_velocity 577 bsf display_velocity
569 578
570 ; use a depth-dependent ascent rate warning 579 ; use a depth-dependent ascent rate warning
571 ; depth(ft): <20 >20 >40 >60 >75 >88 >101 >115 >128 >144 >164 580 ; depth(ft): <20 >20 >40 >60 >75 >88 >101 >115 >128 >144 >164
572 ; speed(ft/min): 23 26 29 33 36 43 49 56 59 62 66 581 ; speed(ft/min): 23 26 29 33 36 43 49 56 59 62 66
577 ; w-multip 7 6 5 5 4 3 3 2 2 2 2 586 ; w-multip 7 6 5 5 4 3 3 2 2 2 2
578 ; a-multip 6 5 4 3 3 3 2 2 2 2 2 587 ; a-multip 6 5 4 3 3 3 2 2 2 2 2
579 ; w-offset 1 2 5 0 6 11 5 16 14 12 10 588 ; w-offset 1 2 5 0 6 11 5 16 14 12 10
580 ; a-offset 0 0 2 6 6 0 6 4 2 0 0 589 ; a-offset 0 0 2 6 6 0 6 4 2 0 0
581 590
591 ; retain the neg_flag (descending information)
582 bcf neg_flag_save 592 bcf neg_flag_save
583 btfsc neg_flag 593 btfsc neg_flag
584 bsf neg_flag_save 594 bsf neg_flag_save
585 595
586 ; no warning color if descending 596 ; check if descending: no warning color if descending
587 call TFT_standard_color 597 call TFT_standard_color
588 btfss neg_flag ; Ignore for descent! 598 btfss neg_flag ; Ignore for descent!
589 bra TFT_display_velocity_out 599 bra TFT_display_velocity_out
590 600
591 SAFE_2BYTE_COPY rel_pressure, lo ; get the actual depth 601 SAFE_2BYTE_COPY rel_pressure, lo ; get the actual depth
606 movwf sub_b+0 616 movwf sub_b+0
607 movlw .20 ; store the warn limit to xA+0 617 movlw .20 ; store the warn limit to xA+0
608 movwf xA+0 618 movwf xA+0
609 movlw .15 ; store the attn limit to xA+1 619 movlw .15 ; store the attn limit to xA+1
610 movwf xA+1 620 movwf xA+1
621 ; graphical position helpers
622 movlw .2
623 movwf xC+0
624 movlw .2
625 movwf xC+1
626 movlw .10
627 movwf xC+2
628 movlw .0
629 movwf xC+3
611 ; check if current depth > segment limit 630 ; check if current depth > segment limit
612 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit 631 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
613 btfss neg_flag ; depth lower than segment limit? sLimit>depth? 632 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
614 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment 633 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
615 634
620 movwf sub_b+0 639 movwf sub_b+0
621 movlw .19 ; store the warn limit to xA+0 640 movlw .19 ; store the warn limit to xA+0
622 movwf xA+0 641 movwf xA+0
623 movlw .15 ; store the attn limit to xA+1 642 movlw .15 ; store the attn limit to xA+1
624 movwf xA+1 643 movwf xA+1
644 ; graphical position helpers
645 movlw .2
646 movwf xC+0
647 movlw .2
648 movwf xC+1
649 movlw .12
650 movwf xC+2
651 movlw .0
652 movwf xC+3
625 ; check if current depth > segment limit 653 ; check if current depth > segment limit
626 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit 654 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
627 btfss neg_flag ; depth lower than segment limit? sLimit>depth? 655 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
628 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment 656 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
629 657
634 movwf sub_b+0 662 movwf sub_b+0
635 movlw .18 ; store the warn limit to xA+0 663 movlw .18 ; store the warn limit to xA+0
636 movwf xA+0 664 movwf xA+0
637 movlw .14 ; store the attn limit to xA+1 665 movlw .14 ; store the attn limit to xA+1
638 movwf xA+1 666 movwf xA+1
667 ; graphical position helpers
668 movlw .2
669 movwf xC+0
670 movlw .2
671 movwf xC+1
672 movlw .14
673 movwf xC+2
674 movlw .2
675 movwf xC+3
639 ; check if current depth > segment limit 676 ; check if current depth > segment limit
640 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit 677 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
641 btfss neg_flag ; depth lower than segment limit? sLimit>depth? 678 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
642 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment 679 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
643 680
648 movwf sub_b+0 685 movwf sub_b+0
649 movlw .17 ; store the warn limit to xA+0 686 movlw .17 ; store the warn limit to xA+0
650 movwf xA+0 687 movwf xA+0
651 movlw .13 ; store the attn limit to xA+1 688 movlw .13 ; store the attn limit to xA+1
652 movwf xA+1 689 movwf xA+1
690 ; graphical position helpers
691 movlw .2
692 movwf xC+0
693 movlw .2
694 movwf xC+1
695 movlw .16
696 movwf xC+2
697 movlw .4
698 movwf xC+3
653 ; check if current depth > segment limit 699 ; check if current depth > segment limit
654 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit 700 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
655 btfss neg_flag ; depth lower than segment limit? sLimit>depth? 701 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
656 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment 702 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
657 703
662 movwf sub_b+0 708 movwf sub_b+0
663 movlw .15 ; store the warn limit to xA+0 709 movlw .15 ; store the warn limit to xA+0
664 movwf xA+0 710 movwf xA+0
665 movlw .12 ; store the attn limit to xA+1 711 movlw .12 ; store the attn limit to xA+1
666 movwf xA+1 712 movwf xA+1
713 ; graphical position helpers
714 movlw .3
715 movwf xC+0
716 movlw .2
717 movwf xC+1
718 movlw .5
719 movwf xC+2
720 movlw .6
721 movwf xC+3
667 ; check if current depth > segment limit 722 ; check if current depth > segment limit
668 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit 723 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
669 btfss neg_flag ; depth lower than segment limit? sLimit>depth? 724 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
670 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment 725 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
671 726
676 movwf sub_b+0 731 movwf sub_b+0
677 movlw .13 ; store the warn limit to xA+0 732 movlw .13 ; store the warn limit to xA+0
678 movwf xA+0 733 movwf xA+0
679 movlw .10 ; store the attn limit to xA+1 734 movlw .10 ; store the attn limit to xA+1
680 movwf xA+1 735 movwf xA+1
736 ; graphical position helpers
737 movlw .3
738 movwf xC+0
739 movlw .3
740 movwf xC+1
741 movlw .11
742 movwf xC+2
743 movlw .0
744 movwf xC+3
681 ; check if current depth > segment limit 745 ; check if current depth > segment limit
682 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit 746 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
683 btfss neg_flag ; depth lower than segment limit? sLimit>depth? 747 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
684 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment 748 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
685 749
690 movwf sub_b+0 754 movwf sub_b+0
691 movlw .11 ; store the warn limit to xA+0 755 movlw .11 ; store the warn limit to xA+0
692 movwf xA+0 756 movwf xA+0
693 movlw .8 ; store the attn limit to xA+1 757 movlw .8 ; store the attn limit to xA+1
694 movwf xA+1 758 movwf xA+1
759 ; graphical position helpers
760 movlw .4
761 movwf xC+0
762 movlw .3
763 movwf xC+1
764 movlw .6
765 movwf xC+2
766 movlw .6
767 movwf xC+3
695 ; check if current depth > segment limit 768 ; check if current depth > segment limit
696 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit 769 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
697 btfss neg_flag ; depth lower than segment limit? sLimit>depth? 770 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
698 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment 771 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
699 772
704 movwf sub_b+0 777 movwf sub_b+0
705 movlw .10 ; store the warn limit to xA+0 778 movlw .10 ; store the warn limit to xA+0
706 movwf xA+0 779 movwf xA+0
707 movlw .8 ; store the attn limit to xA+1 780 movlw .8 ; store the attn limit to xA+1
708 movwf xA+1 781 movwf xA+1
782 ; graphical position helpers
783 movlw .5
784 movwf xC+0
785 movlw .3
786 movwf xC+1
787 movlw .0
788 movwf xC+2
789 movlw .6
790 movwf xC+3
709 ; check if current depth > segment limit 791 ; check if current depth > segment limit
710 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit 792 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
711 btfss neg_flag ; depth lower than segment limit? sLimit>depth? 793 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
712 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment 794 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
713 795
718 movwf sub_b+0 800 movwf sub_b+0
719 movlw .9 ; store the warn limit to xA+0 801 movlw .9 ; store the warn limit to xA+0
720 movwf xA+0 802 movwf xA+0
721 movlw .7 ; store the attn limit to xA+1 803 movlw .7 ; store the attn limit to xA+1
722 movwf xA+1 804 movwf xA+1
805 ; graphical position helpers
806 movlw .5
807 movwf xC+0
808 movlw .4
809 movwf xC+1
810 movlw .5
811 movwf xC+2
812 movlw .2
813 movwf xC+3
723 ; check if current depth > segment limit 814 ; check if current depth > segment limit
724 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit 815 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
725 btfss neg_flag ; depth lower than segment limit? sLimit>depth? 816 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
726 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment 817 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
727 818
732 movwf sub_b+0 823 movwf sub_b+0
733 movlw .8 ; store the warn limit to xA+0 824 movlw .8 ; store the warn limit to xA+0
734 movwf xA+0 825 movwf xA+0
735 movlw .6 ; store the attn limit to xA+1 826 movlw .6 ; store the attn limit to xA+1
736 movwf xA+1 827 movwf xA+1
828 ; graphical position helpers
829 movlw .6
830 movwf xC+0
831 movlw .5
832 movwf xC+1
833 movlw .2
834 movwf xC+2
835 movlw .0
836 movwf xC+3
737 ; check if current depth > segment limit 837 ; check if current depth > segment limit
738 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit 838 call subU16 ; sub_c = sub_a - sub_b; depth - sLimit
739 btfss neg_flag ; depth lower than segment limit? sLimit>depth? 839 btfss neg_flag ; depth lower than segment limit? sLimit>depth?
740 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment 840 bra TFT_velocity_check ; no, depth>=sLimit, do the check for this segment
741 841
744 ; store the warn limit to xA : <20ft=23; <6m=7 844 ; store the warn limit to xA : <20ft=23; <6m=7
745 movlw .7 845 movlw .7
746 movwf xA+0 846 movwf xA+0
747 movlw .5 847 movlw .5
748 movwf xA+1 848 movwf xA+1
849 ; graphical position helpers
850 movlw .7
851 movwf xC+0
852 movlw .6
853 movwf xC+1
854 movlw .1
855 movwf xC+2
856 movlw .0
857 movwf xC+3
749 ;bra TFT_velocity_check ; depth < 20ft / 6m 858 ;bra TFT_velocity_check ; depth < 20ft / 6m
750 859
751 TFT_velocity_check: 860 TFT_velocity_check:
752 ; move current ascent rate to lo 861 ; move current ascent rate to lo
753 clrf hi 862 clrf hi
772 bra TFT_display_velocity_out 881 bra TFT_display_velocity_out
773 882
774 TFT_velocity_warn: 883 TFT_velocity_warn:
775 call TFT_warnings_color ; Set to warning color 884 call TFT_warnings_color ; Set to warning color
776 bsf win_invert 885 bsf win_invert
886 bsf velocity_warn
777 bra TFT_display_velocity_out 887 bra TFT_display_velocity_out
778 888
779 TFT_velocity_attn: 889 TFT_velocity_attn:
780 call TFT_attention_color ; Set to attention color 890 call TFT_attention_color ; Set to attention color
891 bsf velocity_attn
781 ;bra TFT_display_velocity_out 892 ;bra TFT_display_velocity_out
782 893
783 TFT_display_velocity_out: 894 TFT_display_velocity_out:
784 ; retain neg_flag value - restore 895 ; retain neg_flag value - restore
785 bcf neg_flag 896 bcf neg_flag
821 output_16 932 output_16
822 bcf leftbind 933 bcf leftbind
823 STRCAT_TEXT_PRINT tVelImperial ; Unit switch 934 STRCAT_TEXT_PRINT tVelImperial ; Unit switch
824 call TFT_standard_color 935 call TFT_standard_color
825 bcf win_invert 936 bcf win_invert
937 call TFT_display_VSIbar
826 return 938 return
827 939
828 TFT_display_velocity_metric: 940 TFT_display_velocity_metric:
829 movff divA+0,lo ; divA+0 = m/min 941 movff divA+0,lo ; divA+0 = m/min
830 movlw '-' 942 movlw '-'
833 movwf POSTINC2 945 movwf POSTINC2
834 output_99 946 output_99
835 STRCAT_TEXT_PRINT tVelMetric ; Unit switch 947 STRCAT_TEXT_PRINT tVelMetric ; Unit switch
836 call TFT_standard_color 948 call TFT_standard_color
837 bcf win_invert 949 bcf win_invert
950 call TFT_display_VSIbar
951 return
952
953 TFT_display_VSIbar:
954 ; use another logic when descending
955 btfss neg_flag
956 bra TFT_dispay_VSIbar_desc
957 btfsc velocity_warn
958 bra TFT_display_VSIbar_warn
959 btfsc velocity_attn
960 bra TFT_display_VSIbar_attn
961 ; all ok, use attn's values
962 movff xC+1,sub_b+0 ; multiplier
963 movff xC+3,sub_b+1 ; offset
964 bra TFT_display_VSIbar_com
965
966 TFT_display_VSIbar_warn:
967 ; save multiplier and offset out from the xC
968 movff xC+0,sub_b+0 ; multiplier
969 movff xC+2,sub_b+1 ; offset
970 bra TFT_display_VSIbar_com
971
972 TFT_display_VSIbar_attn:
973 ; save multiplier and offset out from the xC
974 movff xC+1,sub_b+0 ; multiplier
975 movff xC+3,sub_b+1 ; offset
976 ;bra TFT_display_VSIbar_com
977
978 TFT_display_VSIbar_com:
979 ; multiply
980 movff divA+0,xA+0
981 clrf xA+1
982 movff sub_b+0,xB+0
983 clrf xB+1
984 call mult16x16 ; xA*xB=xC
985 movlw .1
986 cpfslt xC+3
987 bra TFT_display_VSIbar_max
988 cpfslt xC+2
989 bra TFT_display_VSIbar_max
990 cpfslt xC+1
991 bra TFT_display_VSIbar_max
992 ; add offset
993 movff sub_b+1,WREG
994 addwf xC+0,1
995 btfsc STATUS,C
996 bra TFT_display_VSIbar_max
997 ; check if out-of-range
998 movff xC+0,divB
999 movlw .60
1000 cpfsgt divB
1001 bra TFT_display_VSIbar_draw
1002
1003 TFT_display_VSIbar_max:
1004 movlw .60
1005 movff WREG,divB
1006
1007 TFT_display_VSIbar_draw:
1008 ; calculate top&height for the bar and mask
1009 ; 1. Bar: top=(bar_top+60-divB); height=divB
1010 movlw dm_velobar_top+.1
1011 movff WREG,sub_a+0 ; !!!!!! bar position must fit into lo !!
1012 movlw .60
1013 addwf sub_a+0,1
1014 clrf sub_a+1
1015 movff divB,sub_b+0
1016 clrf sub_b+1
1017 call subU16
1018
1019 movff sub_c+0,win_top
1020 movff divB,win_height
1021 movlw dm_velobar_width
1022 movff WREG,win_width
1023 movff WREG,win_bargraph
1024 movlw dm_velobar_lft+.1
1025 movff WREG,win_leftx2
1026 movlw color_green
1027 call TFT_set_color
1028 btfsc velocity_attn
1029 call TFT_attention_color
1030 btfsc velocity_warn
1031 call TFT_warnings_color
1032 call TFT_box
1033
1034 ;clear the rest
1035 movlw .60
1036 cpfslt divB
1037 return ; divB !< 60 - the graph uses the full bar, no need to clear
1038
1039 ; 2. Mask: top=bar_top; height=60-divB
1040 movlw .60
1041 movff WREG,sub_a+0
1042 clrf sub_a+1
1043 movff divB,sub_b+0
1044 clrf sub_b+1
1045 call subU16 ; sub_c = sub_a - sub_b
1046
1047 movlw dm_velobar_top+.1
1048 movff WREG,win_top
1049 movff sub_c+0,win_height
1050 movlw dm_velobar_width
1051 movff WREG,win_width
1052 movff WREG,win_bargraph
1053 movlw dm_velobar_lft+.1
1054 movff WREG,win_leftx2
1055 movlw color_black
1056 call TFT_set_color
1057 call TFT_box
1058 return
1059
1060 TFT_dispay_VSIbar_desc:
1061 ; clear the ascend part of the bar
1062 call TFT_display_VSIbar_clr
1063 ; TODO
1064 return
1065
1066 TFT_display_VSIbar_clr: ; clears the ascend part of hte bar
1067 WIN_BOX_BLACK dm_velobar_top+.1,dm_velobar_top+.59,dm_velobar_lft+.1,dm_velobar_rgt-.1
1068 movlw color_blue
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 return
1071
1072 TFT_display_velocity_ntr: ; velocity under treshold
1073 call TFT_display_velocity_clear
1074 ; use another logic when descending
1075 btfss neg_flag
1076 bra TFT_dispay_VSIbar_desc
1077 movlw .7
1078 movwf xC+0
1079 movlw .6
1080 movwf xC+1
1081 movlw .1
1082 movwf xC+2
1083 movlw .0
1084 movwf xC+3
1085 call TFT_display_VSIbar
838 return 1086 return
839 1087
840 global TFT_display_velocity_clear 1088 global TFT_display_velocity_clear
841 TFT_display_velocity_clear: 1089 TFT_display_velocity_clear:
842 btfss display_velocity ; Velocity was not displayed, do not delete 1090 btfss display_velocity ; Velocity was not displayed, do not delete