Mercurial > public > hwos_code
comparison src/tft_outputs.asm @ 399:db25f2028074
CHANGE: New segmented speed graph in divemode
NEW: Safety Stop can be configured (Start-, End- and reset-depth + length of stop) via PC
author | heinrichsweikamp |
---|---|
date | Tue, 24 Nov 2015 16:22:52 +0100 |
parents | 1f2e35f5a5aa |
children | 08fea401be24 |
comparison
equal
deleted
inserted
replaced
398:1f2e35f5a5aa | 399:db25f2028074 |
---|---|
45 | 45 |
46 TFT_divemask_color_dive: | 46 TFT_divemask_color_dive: |
47 movff opt_dive_color_scheme,WREG ; 0-3 | 47 movff opt_dive_color_scheme,WREG ; 0-3 |
48 incf WREG | 48 incf WREG |
49 dcfsnz WREG | 49 dcfsnz WREG |
50 bra TFT_divemask_colordive0 ;0 | 50 retlw color_scheme_divemode_mask1 ;0 |
51 dcfsnz WREG | 51 dcfsnz WREG |
52 bra TFT_divemask_colordive1 ;1 | 52 retlw color_scheme_divemode_mask2 ;1 |
53 dcfsnz WREG | 53 dcfsnz WREG |
54 bra TFT_divemask_colordive2 ;2 | 54 retlw color_scheme_divemode_mask3 ;2 |
55 dcfsnz WREG | 55 retlw color_scheme_divemode_mask4 ;3 |
56 bra TFT_divemask_colordive3 ;3 | |
57 TFT_divemask_colordive0: | |
58 movlw color_scheme_divemode_mask1 | |
59 return | |
60 TFT_divemask_colordive1: | |
61 movlw color_scheme_divemode_mask2 | |
62 return | |
63 TFT_divemask_colordive2: | |
64 movlw color_scheme_divemode_mask3 | |
65 return | |
66 TFT_divemask_colordive3: | |
67 movlw color_scheme_divemode_mask4 | |
68 return | |
69 | 56 |
70 | 57 |
71 global TFT_attention_color | 58 global TFT_attention_color |
72 TFT_attention_color: | 59 TFT_attention_color: |
73 movlw color_yellow | 60 movlw color_yellow ; TODO |
74 bra TFT_standard_color0 | 61 bra TFT_standard_color0 |
62 TFT_attention_color_dive: | |
63 retlw color_yellow ; TODO | |
75 | 64 |
76 global TFT_warnings_color | 65 global TFT_warnings_color |
77 TFT_warnings_color: | 66 TFT_warnings_color: |
78 movlw color_red ; TODO | 67 movlw color_red ; TODO |
79 bra TFT_standard_color0 | 68 bra TFT_standard_color0 |
69 TFT_warnings_color_dive: | |
70 retlw color_red ; TODO | |
80 | 71 |
81 global TFT_disabled_color | 72 global TFT_disabled_color |
82 TFT_disabled_color: | 73 TFT_disabled_color: |
83 movlw color_grey ; Default to OSTC grey (dark blue) | 74 movlw color_grey ; Default to OSTC grey (dark blue) |
84 btfsc divemode ; in Divemode? | 75 btfsc divemode ; in Divemode? |
86 bra TFT_standard_color0 | 77 bra TFT_standard_color0 |
87 TFT_disabled_color_dive: | 78 TFT_disabled_color_dive: |
88 movff opt_dive_color_scheme,WREG ; 0-3 | 79 movff opt_dive_color_scheme,WREG ; 0-3 |
89 incf WREG | 80 incf WREG |
90 dcfsnz WREG | 81 dcfsnz WREG |
91 bra TFT_disabled_colordive0 ;0 | 82 retlw color_scheme_divemode_dis1 ;0 |
92 dcfsnz WREG | 83 dcfsnz WREG |
93 bra TFT_disabled_colordive1 ;1 | 84 retlw color_scheme_divemode_dis2 ;1 |
94 dcfsnz WREG | 85 dcfsnz WREG |
95 bra TFT_disabled_colordive2 ;2 | 86 retlw color_scheme_divemode_dis3 ;2 |
96 dcfsnz WREG | 87 retlw color_scheme_divemode_dis4 ;3 |
97 bra TFT_disabled_colordive3 ;3 | |
98 TFT_disabled_colordive0: | |
99 movlw color_scheme_divemode_dis1 | |
100 return | |
101 TFT_disabled_colordive1: | |
102 movlw color_scheme_divemode_dis2 | |
103 return | |
104 TFT_disabled_colordive2: | |
105 movlw color_scheme_divemode_dis3 | |
106 return | |
107 TFT_disabled_colordive3: | |
108 movlw color_scheme_divemode_dis4 | |
109 return | |
110 | 88 |
111 global TFT_standard_color | 89 global TFT_standard_color |
112 TFT_standard_color: | 90 TFT_standard_color: |
113 setf WREG ; Default white | 91 setf WREG ; Default white |
114 btfsc divemode ; in Divemode? | 92 btfsc divemode ; in Divemode? |
118 return | 96 return |
119 TFT_standard_color_dive: | 97 TFT_standard_color_dive: |
120 movff opt_dive_color_scheme,WREG ; 0-3 | 98 movff opt_dive_color_scheme,WREG ; 0-3 |
121 incf WREG | 99 incf WREG |
122 dcfsnz WREG | 100 dcfsnz WREG |
123 bra TFT_standard_colordive0 ;0 | 101 retlw color_scheme_divemode_std1 ;0 |
124 dcfsnz WREG | 102 dcfsnz WREG |
125 bra TFT_standard_colordive1 ;1 | 103 retlw color_scheme_divemode_std2 ;1 |
126 dcfsnz WREG | 104 dcfsnz WREG |
127 bra TFT_standard_colordive2 ;2 | 105 retlw color_scheme_divemode_std3 ;2 |
128 dcfsnz WREG | 106 retlw color_scheme_divemode_std4 ;3 |
129 bra TFT_standard_colordive3 ;3 | |
130 TFT_standard_colordive0: | |
131 movlw color_scheme_divemode_std1 | |
132 return | |
133 TFT_standard_colordive1: | |
134 movlw color_scheme_divemode_std2 | |
135 return | |
136 TFT_standard_colordive2: | |
137 movlw color_scheme_divemode_std3 | |
138 return | |
139 TFT_standard_colordive3: | |
140 movlw color_scheme_divemode_std4 | |
141 return | |
142 | 107 |
143 TFT_color_code macro color_code_temp | 108 TFT_color_code macro color_code_temp |
144 movlw color_code_temp | 109 movlw color_code_temp |
145 call TFT_color_code1 | 110 call TFT_color_code1 |
146 endm | 111 endm |
573 | 538 |
574 ;========================================================================= | 539 ;========================================================================= |
575 | 540 |
576 global TFT_display_velocity | 541 global TFT_display_velocity |
577 TFT_display_velocity: ; With divA+0 = m/min, neg_flag_velocity: ascend=1, descend=0 | 542 TFT_display_velocity: ; With divA+0 = m/min, neg_flag_velocity: ascend=1, descend=0 |
578 ; init flags used to store warning/attention | |
579 bcf velocity_warn | |
580 bcf velocity_attn | |
581 | |
582 bcf STATUS,C | 543 bcf STATUS,C |
583 movlw velocity_display_threshold_1 ; lowest threshold for display vertical velocity | 544 movlw velocity_display_threshold_1 ; lowest threshold for display vertical velocity |
584 subwf divA+0,W | 545 subwf divA+0,W |
585 btfss STATUS,C | 546 btfss STATUS,C |
586 bra TFT_velocity_clear ; lower then threshold. Clear text and graph (If active) | 547 bra TFT_velocity_clear ; lower then threshold. Clear text and graph (If active) |
587 | 548 |
588 ; We have something to display | 549 ; We have something to display |
589 bsf display_velocity ; Set flag | 550 bsf display_velocity ; Set flag |
590 ; check if descending: no warning color if descending | 551 ; check if descending: no warning color if descending |
591 call TFT_standard_color | 552 call TFT_standard_color |
592 btfss neg_flag_velocity ; Ignore for descent! | 553 btfsc neg_flag_velocity ; Ignore for descent! |
593 rcall TFT_velocity_set_color | 554 rcall TFT_velocity_set_color ; Set color for text and set threshold for graph |
594 | 555 |
595 rcall TFT_velocity_disp ; Show the text | 556 rcall TFT_velocity_disp ; Show the text |
596 bcf win_invert | |
597 bcf neg_flag | |
598 | 557 |
599 TSTOSS opt_vsigraph ; =1: draw the graphical VSI bar | 558 TSTOSS opt_vsigraph ; =1: draw the graphical VSI bar |
600 bra TFT_display_velocity_done ; No graph | 559 bra TFT_display_velocity_done ; No graph |
601 | 560 |
602 btfsc neg_flag_velocity ; Ignore for descent! | 561 btfsc neg_flag_velocity ; Ignore for descent! |
626 DB .39,.17,.13,.0 | 585 DB .39,.17,.13,.0 |
627 DB .44,.18,.14,.0 | 586 DB .44,.18,.14,.0 |
628 DB .50,.19,.15,.0 | 587 DB .50,.19,.15,.0 |
629 DB .200,.20,.15,.0 | 588 DB .200,.20,.15,.0 |
630 | 589 |
631 TFT_velocity_set_color: ; Set color based on speed table | 590 TFT_velocity_set_color: ; Set color based on speed table or use static thresholds, with divA+0 = m/min |
632 ; check if old/new ascend logic is used | 591 ; check if old/new ascend logic is used |
633 ; TSTOSS opt_vsitextv2 ; 0=standard, 1=dynamic | 592 TSTOSS opt_vsitextv2 ; 0=standard, 1=dynamic |
634 ; bra TFT_velocity_std ; static ascend rate limit | 593 bra TFT_velocity_set_color_static ; static ascend rate limit |
635 | 594 |
636 ; get the actual depth | 595 ; get the actual depth in m |
637 SAFE_2BYTE_COPY rel_pressure, lo ; get the actual depth | 596 SAFE_2BYTE_COPY rel_pressure, lo |
638 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | 597 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] |
639 call convert_mbar_to_feet ; get depth in feet into lo:hi | 598 movff hi,xA+1 |
640 ; ; store current depth (in feet) into sub_a | 599 movff lo,xA+0 |
641 ; movff lo,sub_a+0 | 600 movlw LOW d'100' |
642 ; movff hi,sub_a+1 | 601 movwf xB+0 |
643 ; ; xA will be used to store the warning/attention limits passed to the verification | 602 clrf xB+1 ; Devide/100 -> xC+0 = Depth in m |
644 ; clrf xA+0 | 603 call div16x16 ; xA/xB=xC with xA as remainder |
645 ; clrf xA+1 | 604 ;movf xC+0,W ; Depth in m |
646 ; | 605 |
647 | 606 ; point to speed table |
648 return ; Done. | 607 movlw LOW (TFT_speed_table-.3) |
608 movwf TBLPTRL | |
609 movlw HIGH (TFT_speed_table-.3) | |
610 movwf TBLPTRH | |
611 movlw UPPER (TFT_speed_table-.3) | |
612 movwf TBLPTRU | |
613 | |
614 TFT_velocity_set_color_skip: | |
615 TBLRD*+ ; 3 dummy reads | |
616 TBLRD*+ | |
617 TBLRD*+ | |
618 | |
619 TBLRD*+ ; Get speed threshold | |
620 movf xC+0,W ; Depth in m | |
621 cpfsgt TABLAT ; Threshold > current depth ? | |
622 bra TFT_velocity_set_color_skip ; No | |
623 | |
624 TBLRD*+ ; Get warning speed threshold | |
625 movf TABLAT,W | |
626 movwf divA+1 ; Copy for graph routine | |
627 cpfslt divA+0 ; smaller then actual value (in m/min)? | |
628 bra TFT_warnings_color ; Set Warning color (And return) | |
629 TBLRD*+ ; Get attention speed threshold | |
630 movf TABLAT,W | |
631 cpfslt divA+0 ; smaller then actual value (in m/min)? | |
632 bra TFT_attention_color ; Set Attention color (And return) | |
633 bra TFT_standard_color ; ...and return | |
634 | |
635 TFT_velocity_set_color_static: | |
636 movlw color_code_velocity_warn_high ; in m/min | |
637 movwf divA+1 ; Copy for graph routine | |
638 cpfslt divA+0 ; smaller then actual value (in m/min)? | |
639 bra TFT_warnings_color ; Set Warning color (And return) | |
640 movlw color_code_velocity_attn_high ; in m/min | |
641 cpfslt divA+0 ; smaller then actual value (in m/min)? | |
642 bra TFT_attention_color ; Set Attention color (And return) | |
643 bra TFT_standard_color ; ...and return | |
649 | 644 |
650 TFT_velocity_disp: | 645 TFT_velocity_disp: |
651 WIN_SMALL dm_velocity_text_column, dm_velocity_text_row | 646 WIN_SMALL dm_velocity_text_column, dm_velocity_text_row |
652 TSTOSS opt_units ; 0=Meters, 1=Feets | 647 TSTOSS opt_units ; 0=Meters, 1=Feets |
653 bra TFT_velocity_metric | 648 bra TFT_velocity_metric |
675 movwf POSTINC2 | 670 movwf POSTINC2 |
676 output_99 | 671 output_99 |
677 STRCAT_TEXT_PRINT tVelMetric ; Unit switch | 672 STRCAT_TEXT_PRINT tVelMetric ; Unit switch |
678 return | 673 return |
679 | 674 |
680 TFT_velocity_graph: | 675 TFT_velocity_graph: ; divA+0 = m/min |
681 movlw color_white | 676 ; divA+0 holding the ascend speed in m/min |
682 WIN_BOX_COLOR dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;top, bottom, left, right | 677 movff divA+0,hi ; Copy |
683 return | 678 WIN_BOX_BLACK dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;top, bottom, left, right -> outer frame |
679 rcall TFT_divemask_color_dive ; Color -> WREG | |
680 WIN_FRAME_COLOR dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;inner frame | |
681 rcall TFT_divemask_color_dive ; Color -> WREG | |
682 WIN_FRAME_COLOR dm_velobar_top+.10, dm_velobar_bot-.10, dm_velobar_lft, dm_velobar_rgt ;inner frame | |
683 rcall TFT_divemask_color_dive ; Color -> WREG | |
684 WIN_FRAME_COLOR dm_velobar_top+.20, dm_velobar_bot-.20, dm_velobar_lft, dm_velobar_rgt ;inner frame | |
685 rcall TFT_divemask_color_dive ; Color -> WREG | |
686 WIN_FRAME_COLOR dm_velobar_top+.30, dm_velobar_bot-.30, dm_velobar_lft, dm_velobar_rgt ;inner frame | |
687 | |
688 movff divA+1,xA+0 ; m/min for warning level (upper two blocks) | |
689 clrf xA+1 | |
690 movlw .5 | |
691 movwf xB+0 ; Threshold for color warning (5 color normal + 2 color warning) | |
692 clrf xB+1 | |
693 call div16x16 ;xA/xB=xC with xA as remainder | |
694 ; xC+0 holds stepsize in m/min (e.g. =3 for 15m/min warning treshold) | |
695 movff hi,xA+0 ; Velocity in m/min | |
696 clrf xA+1 | |
697 movff xC+0,xB+0 ; Step size | |
698 clrf xB+1 | |
699 call div16x16 ;xA/xB=xC with xA as remainder | |
700 ; xC+0 now holds amount of segments to show | |
701 | |
702 movff hi,divA+0 ; Copy back for numeric output | |
703 movlw d'7' | |
704 cpfslt xC+0 | |
705 bra DISP_graph_vel_7 | |
706 movlw d'6' | |
707 cpfslt xC+0 | |
708 bra DISP_graph_vel_6 | |
709 movlw d'5' | |
710 cpfslt xC+0 | |
711 bra DISP_graph_vel_5 | |
712 movlw d'4' | |
713 cpfslt xC+0 | |
714 bra DISP_graph_vel_4 | |
715 movlw d'3' | |
716 cpfslt xC+0 | |
717 bra DISP_graph_vel_3 | |
718 movlw d'2' | |
719 cpfslt xC+0 | |
720 bra DISP_graph_vel_2 | |
721 movlw d'1' | |
722 cpfslt xC+0 | |
723 bra DISP_graph_vel_1 | |
724 bra DISP_graph_vel_0 ; Should not happen... | |
725 | |
726 DISP_graph_vel_7: | |
727 rcall TFT_warnings_color_dive ; Color -> WREG | |
728 WIN_BOX_COLOR dm_velobar_top+.2, dm_velobar_top+.8, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right | |
729 DISP_graph_vel_6: | |
730 rcall TFT_warnings_color_dive ; Color -> WREG | |
731 WIN_BOX_COLOR dm_velobar_top+.12, dm_velobar_top+.18, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right | |
732 DISP_graph_vel_5: | |
733 rcall TFT_attention_color_dive ; Color -> WREG | |
734 WIN_BOX_COLOR dm_velobar_top+.22, dm_velobar_top+.28, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right | |
735 DISP_graph_vel_4: | |
736 rcall TFT_standard_color_dive ; Color -> WREG | |
737 WIN_BOX_COLOR dm_velobar_top+.32, dm_velobar_top+.38, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right | |
738 DISP_graph_vel_3: | |
739 rcall TFT_standard_color_dive ; Color -> WREG | |
740 WIN_BOX_COLOR dm_velobar_top+.42, dm_velobar_top+.48, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right | |
741 DISP_graph_vel_2: | |
742 rcall TFT_standard_color_dive ; Color -> WREG | |
743 WIN_BOX_COLOR dm_velobar_top+.52, dm_velobar_top+.58, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right | |
744 DISP_graph_vel_1: | |
745 rcall TFT_standard_color_dive ; Color -> WREG | |
746 WIN_BOX_COLOR dm_velobar_top+.62, dm_velobar_top+.68, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right | |
747 DISP_graph_vel_0: | |
748 return ; Done. | |
684 | 749 |
685 global TFT_velocity_clear | 750 global TFT_velocity_clear |
686 TFT_velocity_clear: | 751 TFT_velocity_clear: |
687 btfss display_velocity ; Velocity was not displayed, do not delete | 752 btfss display_velocity ; Velocity was not displayed, do not delete |
688 return | 753 return |