annotate src/compass_ops.asm @ 627:bf5fee575701

minor cleanup, reset rx circuity
author heinrichsweikamp
date Sun, 30 Jun 2019 23:22:32 +0200
parents c40025d8e750
children cd58f7fc86db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1 ;=============================================================================
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
2 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
3 ; File compass_ops.asm combined next generation V3.03.2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
4 ;
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
5 ; Compass Operations
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
6 ;
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
8 ;=============================================================================
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
9
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
10 #include "hwos.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
11 #include "i2c.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
12 #include "tft_outputs.inc"
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
13 #include "tft.inc"
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
14 #include "strings.inc"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
15 #include "wait.inc"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
16 #include "surfmode.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
17 #include "divemode.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
18 #include "math.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
19 #include "convert.inc"
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
20
0
heinrichsweikamp
parents:
diff changeset
21
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
22 IFDEF _compass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
23
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
24
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
25 ; local flags
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
26 #DEFINE compass_show_cardinal compass_flags,0 ; =1: show the cardinal (N, NE, E, ...)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
27 #DEFINE compass_bearing_eq compass_flags,1 ; =1: bearing is in direction, do not show << or >>
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
28 #DEFINE compass_bearing_lft compass_flags,2 ; =1: bearing is to the left/<<, =0: to the right/>>
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
29 #DEFINE compass_bearing_vis compass_flags,3 ; =1: bearing is visible (either ahead or behind/-180°)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
30 #DEFINE compass_bearing_ahd compass_flags,4 ; =1: bearing is ahead, =0: behind
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
31 ; compass_flags,5 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
32 ; compass_flags,6 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
33 ; compass_flags,7 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
34
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
35
0
heinrichsweikamp
parents:
diff changeset
36 ; Make sure symbols from the .inc are available to the C code:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
37
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
38 ; filtered data - Compass
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
39 global compass_DX_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
40 global compass_DY_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
41 global compass_DZ_f
0
heinrichsweikamp
parents:
diff changeset
42
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
43 ; filtered Data - Accelerometer
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
44 global accel_DX_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
45 global accel_DY_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
46 global accel_DZ_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
47
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
48 ; Calibration Data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
49 global compass_CX_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
50 global compass_CY_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
51 global compass_CZ_f
0
heinrichsweikamp
parents:
diff changeset
52
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
53 ; Temporary Values to pass Q15 Arithmetics around
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
54 global compass_a
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
55 global compass_b
0
heinrichsweikamp
parents:
diff changeset
56
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
57 ; Result
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
58 global compass_heading_new
0
heinrichsweikamp
parents:
diff changeset
59
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
60
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
61 extern compass
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
62 extern compass_reset_calibration
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
63 extern compass_add_calibration
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
64 extern compass_solve_calibration
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
65
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
66 extern option_save_all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
67
337
508d7fb98b34 cleanup menu, add "Auto SP" option (Not working yet), minor layout change in compass menu
heinrichsweikamp
parents: 300
diff changeset
68
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
69 compass_ops code
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
70
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
71 ;=============================================================================
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
72
0
heinrichsweikamp
parents:
diff changeset
73 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
74 ; Filter compass values
heinrichsweikamp
parents:
diff changeset
75 ;
heinrichsweikamp
parents:
diff changeset
76 ; Apply linear filtering to input parameters.
heinrichsweikamp
parents:
diff changeset
77
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
78 ; Apply filtering formula: reg_f += (reg - reg_f) / 4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
79 FILTER16 MACRO reg, reg_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
80 movf reg_f+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
81 subwf reg+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
82 movwf PRODL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
83 movf reg_f+1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
84 subwfb reg+1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
85 rcall filter_16_common
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
86 addwf reg_f+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
87 movf PRODH,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
88 addwfc reg_f+1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
89 ENDM
148
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
90
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
91 filter_16_common:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
92 movwf PRODH
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
93 bcf STATUS,C ; copy sign bit into carry
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
94 btfsc PRODH,7
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
95 bsf STATUS,C
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
96 rrcf PRODH,F ; 16 bit shift right
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
97 rrcf PRODL,F
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
98 bcf STATUS,C ; copy sign bit into carry
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
99 btfsc PRODH,7
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
100 bsf STATUS,C
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
101 rrcf PRODH,F ; 16 bit shift right
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
102 rrcf PRODL,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
103 return
0
heinrichsweikamp
parents:
diff changeset
104
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
105
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
106 global compass_filter
0
heinrichsweikamp
parents:
diff changeset
107 compass_filter:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
108 banksel compass_DX ; select bank common2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
109 FILTER16 compass_DX, compass_DX_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
110 FILTER16 compass_DY, compass_DY_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
111 FILTER16 compass_DZ, compass_DZ_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
112 FILTER16 accel_DX, accel_DX_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
113 FILTER16 accel_DY, accel_DY_f
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
114 FILTER16 accel_DZ, accel_DZ_f
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
115 banksel common ; back to bank common
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
116 return
0
heinrichsweikamp
parents:
diff changeset
117
heinrichsweikamp
parents:
diff changeset
118 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
119
heinrichsweikamp
parents:
diff changeset
120 compass_filter_init:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
121 MOVII compass_DX,compass_DX_f
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
122 MOVII compass_DY,compass_DY_f
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
123 MOVII compass_DZ,compass_DZ_f
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
124
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
125 MOVII accel_DX,accel_DX_f
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
126 MOVII accel_DY,accel_DY_f
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
127 MOVII accel_DZ,accel_DZ_f
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
128 return
0
heinrichsweikamp
parents:
diff changeset
129
heinrichsweikamp
parents:
diff changeset
130 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
131 ; Q15 fractional numbers: a * b / 2**16 (UNSIGNED)
heinrichsweikamp
parents:
diff changeset
132 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
133 ; Uses 16x16->16 multiply, for positive integers, keeping only the most
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
134 ; relevant bits.
0
heinrichsweikamp
parents:
diff changeset
135 ;
heinrichsweikamp
parents:
diff changeset
136 ; Used to multiply two Q15 numbers, in the range 0..1,
heinrichsweikamp
parents:
diff changeset
137 ; represented as 0..32767, that is a / 2**15.
heinrichsweikamp
parents:
diff changeset
138 ;
heinrichsweikamp
parents:
diff changeset
139 ; (a/2**15) * (b/2**15) = a*b / 2**30 = (a*b/2**16) / 2**14.
heinrichsweikamp
parents:
diff changeset
140 ; So to get back a Q15 number, we need a shift-left...
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
141
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
142 global compass_umul ; called from compass.c
0
heinrichsweikamp
parents:
diff changeset
143 compass_umul:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
144 banksel compass_a ; select bank common2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
145 rcall compass_mul_16
0
heinrichsweikamp
parents:
diff changeset
146
heinrichsweikamp
parents:
diff changeset
147 ; The 2x time, by left-shifting inserting the missing bit:
heinrichsweikamp
parents:
diff changeset
148 compass_mul_2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
149 rlcf compass_r+2,F ; missing bit into carry
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
150 rlcf compass_r+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
151 rlcf compass_r+1,F
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
152 MOVII compass_r,PROD ; return value into PROD
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
153 return
0
heinrichsweikamp
parents:
diff changeset
154
heinrichsweikamp
parents:
diff changeset
155 ; The 16x16-> multiply:
heinrichsweikamp
parents:
diff changeset
156 compass_mul_16:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
157 movf compass_a+1,W ; block ah*bh
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
158 mulwf compass_b+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
159 movff PRODL,compass_r+0 ; and copy
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
160 movff PRODH,compass_r+1
0
heinrichsweikamp
parents:
diff changeset
161
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
162 movf compass_a+0,W ; block al*bl
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
163 mulwf compass_b+0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
164 movff PRODH,compass_r+2 ; into fraction byte
0
heinrichsweikamp
parents:
diff changeset
165
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
166 movf compass_a+1,W ; block ah*bl
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
167 mulwf compass_b+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
168 movf PRODL,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
169 addwf compass_r+2,F ; fraction part to carry
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
170 movf PRODH,W ; and add16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
171 addwfc compass_r+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
172 movlw 0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
173 addwfc compass_r+1,F
0
heinrichsweikamp
parents:
diff changeset
174
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
175 movf compass_a+0,W ; block al*bh
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
176 mulwf compass_b+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
177 movf PRODL,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
178 addwf compass_r+2,F ; fraction part to carry
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
179 movf PRODH,W ; and add16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
180 addwfc compass_r+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
181 movlw 0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
182 addwfc compass_r+1,F
0
heinrichsweikamp
parents:
diff changeset
183
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
184 return
0
heinrichsweikamp
parents:
diff changeset
185
heinrichsweikamp
parents:
diff changeset
186 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
187 ; Q15 fractional numbers: a * b / 2**16 (SIGNED)
heinrichsweikamp
parents:
diff changeset
188
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
189 global compass_imul ; called from compass.c
0
heinrichsweikamp
parents:
diff changeset
190 compass_imul:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
191 banksel compass_a ; select bank common2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
192 rcall compass_mul_16
0
heinrichsweikamp
parents:
diff changeset
193
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
194 btfss compass_b+1,7
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
195 bra compass_mul_3
0
heinrichsweikamp
parents:
diff changeset
196
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
197 movf compass_a+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
198 subwf compass_r+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
199 movf compass_a+1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
200 subwfb compass_r+1,F
0
heinrichsweikamp
parents:
diff changeset
201
heinrichsweikamp
parents:
diff changeset
202 compass_mul_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
203 btfss compass_a+1,7
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
204 bra compass_mul_4
0
heinrichsweikamp
parents:
diff changeset
205
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
206 movf compass_b+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
207 subwf compass_r+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
208 movf compass_b+1,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
209 subwfb compass_r+1,F
0
heinrichsweikamp
parents:
diff changeset
210
heinrichsweikamp
parents:
diff changeset
211 compass_mul_4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
212 bcf compass_r+1,6 ; copy bit 7 to 6, so keep it after 2x
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
213 btfsc compass_r+1,7
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
214 bsf compass_r+1,6
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
215 bra compass_mul_2
0
heinrichsweikamp
parents:
diff changeset
216
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
217
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
218 global compass_calibration_loop
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
219 compass_calibration_loop: ; compass calibration
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
220 bsf block_sensor_interrupt ; disable sensor interrupts
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
221 call I2C_sleep_accelerometer ; stop accelerometer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
222 call I2C_sleep_compass ; stop compass
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
223 call TFT_ClearScreen
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
224 ; Mask
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
225 WIN_COLOR color_greenish
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
226 WIN_SMALL .16,.0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
227 STRCPY_TEXT_PRINT tCompassMenu
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
228 btfss switch_right2 ; wait until button is released
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
229 bra $-2
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
230
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
231 call TFT_standard_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
232 ; WIN_SMALL .0,.215
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
233 ; STRCPY_TEXT_PRINT tExit
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
234 WAITMS d'255'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
235 WAITMS d'255'
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
236
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
237 call request_speed_fastest ; request CPU speed change to fastest speed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
238
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
239 movlw .7 ; initialize gain
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
240 movff WREG,opt_compass_gain
428
eccae727702f some cleanup
heinrichsweikamp
parents: 386
diff changeset
241
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
242 movlw .60 ; initialize timeout to 60 seconds
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
243 movwf isr_timeout_reload ; copy WREG to isr_timeout_reload
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
244 bsf reset_timeout ; request ISR to reset the timeout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
245 bcf trigger_timeout ; clear any pending timeout trigger
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
246 compass_calibration_gainset: ; reduce the gain, set bank here!
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
247 banksel opt_compass_gain ; select bank options table
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
248 decf opt_compass_gain,F ; reduce by one
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
249 btfsc STATUS,N ; < 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
250 clrf opt_compass_gain ; YES - keep at zero
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
251 banksel common ; bank to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
252
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
253 call I2C_init_accelerometer
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
254 call I2C_init_compass
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
255
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
256 ; btfsc compass_type ; compass1 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
257 ; bra compass_calibration_loop1 ; YES - skip gain stuff
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
258
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
259 rcall TFT_compass_show_gain ; show the current compass gain
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
260
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
261 WAITMS d'250'
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
262 WAITMS d'250' ; wait for first reading...
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
263
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
264 movlw .60 ; calibration shall run for 60 seconds
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
265 call reset_timeout_time ; set timeout
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
266
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
267 call I2C_RX_compass ; read compass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
268 call I2C_RX_accelerometer ; read accelerometer
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
269
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
270 ; Test all axes for +4096 (Hi byte=16)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
271 banksel compass_DX ; select bank common2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
272 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
273 cpfseq compass_DX+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
274 bra $+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
275 bra compass_calibration_gainset
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
276 cpfseq compass_DY+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
277 bra $+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
278 bra compass_calibration_gainset
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
279 cpfseq compass_DZ+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
280 bra $+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
281 bra compass_calibration_gainset
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
282
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
283 ; Test all axes for -4096 (Hi byte=240)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
284 movlw .240
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
285 cpfseq compass_DX+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
286 bra $+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
287 bra compass_calibration_gainset
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
288 cpfseq compass_DY+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
289 bra $+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
290 bra compass_calibration_gainset
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
291 cpfseq compass_DZ+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
292 bra $+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
293 bra compass_calibration_gainset
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
294 banksel common ; back to bank common
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
295
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
296 compass_calibration_loop1: ; done with gain
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
297 rcall compass_filter_init ; set DX_f values
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
298 call compass_reset_calibration ; reset CX_f values (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
299 banksel common ; back to bank common
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
300
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
301 compass_calibration_loop2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
302 call I2C_RX_compass ; read compass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
303 call I2C_RX_accelerometer ; test accelerometer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
304 rcall compass_filter ; filter compass raw data
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
305
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
306 ; Twice
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
307 call I2C_RX_compass ; read compass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
308 call I2C_RX_accelerometer ; test accelerometer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
309 rcall compass_filter ; filter compass raw data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
310
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
311 ; btfsc compass_type ; compass1?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
312 ; bra compass_calibration_loop3 ; YES - skip gain stuff
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
313
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
314 ; Test all axes for +4096 (Hi byte=16)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
315 banksel compass_DX ; select bank common2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
316 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
317 cpfseq compass_DX+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
318 bra $+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
319 bra compass_calibration_gainset
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
320 cpfseq compass_DY+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
321 bra $+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
322 bra compass_calibration_gainset
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
323 cpfseq compass_DZ+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
324 bra $+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
325 bra compass_calibration_gainset
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
326
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
327 ; Test all axes for -4096 (Hi byte=240)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
328 movlw .240
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
329 cpfseq compass_DX+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
330 bra $+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
331 bra compass_calibration_gainset
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
332 cpfseq compass_DY+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
333 bra $+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
334 bra compass_calibration_gainset
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
335 cpfseq compass_DZ+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
336 bra $+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
337 bra compass_calibration_gainset
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
338 banksel common ; back to bank common
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
339 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
340 ; ; Three
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
341 ; call I2C_RX_compass ; read compass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
342 ; call I2C_RX_accelerometer ; test accelerometer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
343 ; call compass_filter ; filter compass raw data
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
344 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
345 ; ; Four times to get cleaner values
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
346 ; call I2C_RX_compass ; read compass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
347 ; call I2C_RX_accelerometer ; test accelerometer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
348 ; call compass_filter ; filter compass raw data
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
349
428
eccae727702f some cleanup
heinrichsweikamp
parents: 386
diff changeset
350 compass_calibration_loop3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
351 ; and register only one value out of four:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
352 call compass_add_calibration ; check and store new max/min values (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
353 banksel common ; back to bank common
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
354
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
355 rcall TFT_compass_fast ; show values
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
356 btfsc trigger_timeout ; timeout (calibration done)?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
357 bra compass_calibration_exit ; YES - exit
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
358 btfss trigger_full_second ; NO - new second begun?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
359 bra compass_calibration_loop2 ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
360 bcf trigger_full_second ; YES - clear flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
361 rcall TFT_show_timeout_testmode ; - show remaining time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
362 bra compass_calibration_loop2 ; - loop
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
363
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
364 compass_calibration_exit:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
365 bcf block_sensor_interrupt ; re-enable sensor interrupts
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
366
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
367 call compass_solve_calibration ; calculate calibration factors (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
368 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
369
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
370 call request_speed_normal ; request CPU speed change to normal speed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
371
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
372 call option_save_all ; save all settings into EEPROM
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
373 movlw .6
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
374 movff WREG,customview_surfmode ; set to compass view...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
375 goto surfloop ; ...and exit
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
376
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
377
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
378 global TFT_compass_fast
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
379 TFT_compass_fast:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
380 WIN_TINY .20,.50
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
381 STRCPY "X:"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
382 MOVII compass_DX,mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
383 call TFT_convert_signed_16bit ; convert lo:hi into signed-short and add '-' to POSTINC2 if required
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
384 output_16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
385 STRCAT " Y:"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
386 MOVII compass_DY,mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
387 call TFT_convert_signed_16bit ; convert lo:hi into signed-short and add '-' to POSTINC2 if required
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
388 output_16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
389 STRCAT " Z:"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
390 MOVII compass_DZ,mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
391 call TFT_convert_signed_16bit ; convert lo:hi into signed-short and add '-' to POSTINC2 if required
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
392 output_16
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
393 STRCAT_PRINT " "
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
394 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
395
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
396 TFT_show_timeout_testmode:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
397 WIN_TINY .20,.68
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
398 STRCPY "T:"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
399 movff isr_timeout_timer,lo
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
400 bsf leftbind
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
401 output_8 ; display remaining time
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
402 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
403 STRCAT_PRINT "s "
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
404 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
405
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
406 TFT_compass_show_gain: ; show the current compass gain
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
407 ; movff opt_compass_gain,lo ; 0-7 (230 LSB/Gauss to 1370 LSB/Gauss)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
408 ; tstfsz lo
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
409 ; return ; do not show unless gain=0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
410 WIN_TINY .20,.86
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
411 STRCPY_TEXT tCompassGain
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
412 movff opt_compass_gain,lo ; 0-7 (230 LSB/Gauss to 1370 LSB/Gauss)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
413 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
414 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
415 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
416 STRCAT_PRINT ""
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
417 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
418
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
419
382
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 371
diff changeset
420 TFT_surface_compass_bearing:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
421 WIN_SMALL surf_compass_bear_column,surf_compass_bear_row
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
422 MOVII compass_bearing,mpr
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
423 PUTC "("
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
424 bsf leftbind
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
425 output_16dp .2 ; result is "0.000"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
426 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
427 ; rearrange figures to "000"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
428 movff buffer+3,buffer+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
429 movff buffer+4,buffer+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
430 movff buffer+5,buffer+3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
431 lfsr FSR2,buffer+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
432 STRCAT "° "
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
433 rcall tft_compass_cardinal ; add cardinal and ordinal to POSTINC2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
434 STRCAT_PRINT ")"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
435 return
382
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 371
diff changeset
436
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
437
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
438 global TFT_surface_compass_mask
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
439 TFT_surface_compass_mask:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
440 WIN_SMALL surf_compass_mask_column,surf_compass_mask_row
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
441 call TFT_standard_color
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
442 STRCPY_TEXT_PRINT tHeading ; Heading:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
443 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
444
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
445
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
446 global TFT_dive_compass_mask ; draws the white box around the heading tape
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
447 TFT_dive_compass_mask:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
448 WIN_FRAME_STD dm_custom_compass_graph_row, dm_custom_compass_graph_row+dm_custom_compass_graph_height, .0, .159
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
449 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
450
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
451
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
452 global TFT_surface_compass_heading
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
453 TFT_surface_compass_heading:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
454 rcall compass_heading_common
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
455 WIN_STD surf_compass_head_column,surf_compass_head_row
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
456 call TFT_standard_color
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
457 TFT_surface_compass_heading_com: ; show "000° N"
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
458 MOVII compass_heading_new,mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
459 btfss mpr+1,7 ; compass calibrated?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
460 bra TFT_surface_compass_heading_com0 ; YES
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
461 STRCAT_PRINT "---°" ; NO - print "---°"
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
462 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
463 TFT_surface_compass_heading_com0:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
464 ; Shown and actual identical?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
465 movff compass_heading_shown+0,WREG ; get heading shown, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
466 cpfseq mpr+0 ; compare with current heading, equal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
467 bra TFT_surface_compass_heading_com1 ; NO - not equal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
468 movff compass_heading_shown+1,WREG ; get heading shown, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
469 cpfseq mpr+1 ; compare with current heading, equal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
470 bra TFT_surface_compass_heading_com1 ; NO - not equal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
471 bra TFT_surface_compass_heading_com3 ; YES - skip smoothing
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
472
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
473 TFT_surface_compass_heading_com1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
474 MOVII mpr,sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
475 MOVII compass_heading_shown,sub_b
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
476 call subU16
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
477 btfsc neg_flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
478 bra TFT_surface_compass_heading_com2 ; shown > actual
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
479 ; shown < actual
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
480 banksel compass_heading_shown ; select bank common2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
481 INCI compass_heading_shown ; compass_heading_shown++
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
482 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
483 bra TFT_surface_compass_heading_com3
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
484
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
485 TFT_surface_compass_heading_com2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
486 banksel compass_heading_shown ; select bank common2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
487 DECI compass_heading_shown ; compass_heading_shown--
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
488 banksel common ; back to bank common
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
489
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
490 TFT_surface_compass_heading_com3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
491 MOVII compass_heading_shown,mpr
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
492 bsf leftbind
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
493 output_16dp .2 ; result is "0.000"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
494 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
495 ; rearrange figures to "000"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
496 movff buffer+2,buffer+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
497 movff buffer+3,buffer+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
498 movff buffer+4,buffer+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
499 lfsr FSR2,buffer+3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
500 STRCAT "° "
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
501 rcall tft_compass_cardinal ; add cardinal and ordinal to POSTINC2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
502 clrf WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
503 movff WREG,buffer+.7 ; limit to 7 chars
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
504 STRCAT_PRINT ""
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
505 btfsc divemode ; in dive mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
506 return ; YES - done for dive mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
507 ; show bearing on the surface?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
508 btfss compass_bearing_set ; is a bearing set?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
509 return ; NO - return
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
510 btfsc compass_menu ; is the "set bearing" selection shown?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
511 return ; YES - return
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
512 bra TFT_surface_compass_bearing ; NO - show bearing and return
382
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 371
diff changeset
513
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
514
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
515 global TFT_dive_compass_heading
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
516 TFT_dive_compass_heading:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
517 WIN_FONT FT_SMALL ; set font size TODO - needed ???
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
518 rcall compass_heading_common
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
519 ; ; ### for development only, hard-coding the bearing ###
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
520 ; ; 244° : SW - W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
521 ; MOVLI .244,xA ; xA used as temp
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
522 ; MOVII xA,compass_bearing ; compass_bearing is stored in bank isr_backup
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
523
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
524 MOVII compass_heading_shown,xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
525 ; 160° viewing angle: add +360 offset if xA <= 292 for non-negative scale
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
526 MOVLI .292,sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
527 MOVII xA, sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
528 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
529 btfsc neg_flag ; xA > 292 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
530 bra TFT_dive_compass_heading_1 ; YES
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
531 ADDLI .360,xA ; NO - add offset
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
532 TFT_dive_compass_heading_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
533 SUBLI .80,xA ; subtract 80 (left pixel offset from the center)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
534 MOVII xA,xRD ; save result to xRD
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
535 ADDLI .160,xA ; add 160 (display with in pixels)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
536 MOVII xA,xRDr ; save result to xRDr
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
537
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
538 btfss compass_bearing_set ; is a bearing set?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
539 bra TFT_dive_compass_ruler ; NO - skip next calculations
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
540 MOVII xRDr,sub_a ; YES - calculate xRD180 = xRDr - 180
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
541 MOVLI .180,sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
542 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
543 MOVII sub_c,xRD180
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
544
258
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
545 TFT_dive_compass_bearing_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
546 ; calculate bearing position and visibility (ahead or behind)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
547 bcf compass_bearing_vis ; default is not-visible
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
548 bcf compass_bearing_ahd ; default is behind
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
549 MOVII compass_bearing,xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
550 ADDLI .360,xA ; calculate the bearing virtual display offset
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
551 MOVII xA,divA ; save it for reuse for upper/lower turns and ahead/behind checks
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
552
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
553 ; check if bearing is ahead
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
554 MOVII divA,sub_a ; load the bearing offset into sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
555 MOVII xRD, sub_b ; load the display offset back to sub_b
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
556 rcall TFT_dive_compass_bearing_ap
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
557 btfsc compass_bearing_vis ; bearing visible?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
558 bra TFT_dive_compass_bearing_dir ; YES
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
559
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
560 ; check if it's ahead with an upper turn
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
561 MOVII divA,sub_a ; load the bearing offset into sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
562 MOVII xRD, sub_b ; load the display offset back to sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
563 ADDLI .360,sub_b
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
564 rcall TFT_dive_compass_bearing_ap
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
565 btfsc compass_bearing_vis ; bearing visible?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
566 bra TFT_dive_compass_bearing_dir ; YES
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
567
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
568 ; check if it's ahead with a lower turn
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
569 MOVII divA,sub_a ; load the bearing offset into sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
570 ADDLI .360,sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
571 MOVII xRD, sub_b ; load the display offset back to sub_b
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
572 rcall TFT_dive_compass_bearing_ap
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
573 btfsc compass_bearing_vis ; bearing visible?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
574 bra TFT_dive_compass_bearing_dir ; YES
258
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
575
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
576 ; marker is not ahead of us, check if it is behind of us
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
577 ; use the (160 - (xRD180 - xCM)) formula to see if it's on the display
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
578 MOVII xRD180,sub_a ; load the display offset back to sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
579 MOVII divA, sub_b ; load the marker's offset into sub_b
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
580 rcall TFT_dive_compass_bearing_bp
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
581 btfsc compass_bearing_vis ; bearing behind of us?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
582 bra TFT_dive_compass_bearing_dir ; YES
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
583
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
584 ; check if it's behind with the upper turn
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
585 MOVII xRD180,sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
586 MOVII divA, sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
587 ADDLI .360, sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
588 rcall TFT_dive_compass_bearing_bp
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
589 btfsc compass_bearing_vis ; bearing behind of us?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
590 bra TFT_dive_compass_bearing_dir ; YES
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
591
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
592 ; check if it's behind with the lower turn
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
593 MOVII xRD180,sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
594 ADDLI .360, sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
595 MOVII divA, sub_b ; load the marker's offset into sub_b
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
596 rcall TFT_dive_compass_bearing_bp
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
597 bra TFT_dive_compass_bearing_dir
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
598
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
599 TFT_dive_compass_bearing_ap:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
600 ; xCM received in sub_a
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
601 ; xRD received in sub_b
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
602 ; 1/a. check if it's viewable from the left side
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
603 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
604 btfsc neg_flag ; xRD > divA ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
605 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
606 MOVII sub_c,xC ; YES - store the RO=RP-RD for drawing
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
607 ; 1/b. check if it's viewable from the right side
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
608 ADDLI .2,sub_a ; avoid thin mess on the side of the display
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
609 ADDLI .158,sub_b ; load the display offset right side into sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
610 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
611 btfss neg_flag ; xRDr > xA(+2) ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
612 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
613 ; YES - print the bearing lines on the screen
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
614 movff xC+0,xCM
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
615 bsf compass_bearing_vis ; set visible
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
616 bsf compass_bearing_ahd ; set ahead
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
617 return ; done
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
618
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
619 TFT_dive_compass_bearing_bp:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
620 ; use the (160 - (xRD180 - xCM)) formula to see if it's on the display
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
621 ; the marker's offset received in sub_b
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
622 ; the xRD180 display offset received in sub_a
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
623 ; xRD180 - xCM
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
624 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
625 btfsc neg_flag ; CM > xRD180 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
626 return ; NO - not on screen, done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
627 ; YES - check 160 - (X)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
628 MOVLI .158, sub_a ; 158 to avoid thin mess on the side of the display
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
629 MOVII sub_c,sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
630 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
631 btfsc neg_flag ; X > 160 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
632 return ; NO - not on screen, done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
633 ; check if not overflow - this sounds like a double check...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
634 tstfsz sub_c+1 ; high byte = 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
635 return ; NO - sub_c must be > 160 then, done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
636 movlw d'158'
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
637 cpfslt sub_c+0 ; low byte < 158 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
638 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
639 movff sub_c+0,xCM ; YES to both - print the bearing lines on the screen
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
640 bsf compass_bearing_vis
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
641 return ; done
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
642
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
643 TFT_dive_compass_bearing_dir:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
644 ; check if bearing to heading, and calculate the direction
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
645 bcf compass_bearing_eq
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
646 btfss compass_bearing_vis
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
647 bra TFT_dive_compass_bearing_lr
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
648 btfss compass_bearing_ahd
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
649 bra TFT_dive_compass_bearing_lr
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
650 movff xCM,xA+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
651 movlw d'80'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
652 cpfseq xA+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
653 bra TFT_dive_compass_bearing_lr
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
654 bsf compass_bearing_eq
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
655 bra TFT_dive_compass_ruler ; bearing points to heading, no signs are required, go to the ruler
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
656
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
657 TFT_dive_compass_bearing_lr:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
658 ; get the bearing virtual display offset
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
659 MOVII compass_bearing,xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
660 ; xA = xA > 292 ? xA : xA+360
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
661 MOVLI .292,sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
662 MOVII xA, sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
663 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
664 btfsc neg_flag ; xA > 292 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
665 bra TFT_dive_compass_bearing_lr_1 ; YES
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
666 ADDLI .360,xA ; NO - add 360
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
667
258
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
668 TFT_dive_compass_bearing_lr_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
669 ; 1. calculate whether bearing is to left or to right
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
670 bsf compass_bearing_lft ; to the left by default
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
671 ; xC: save center value to compare the direction to front value
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
672 MOVII xA,xC
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
673 ; xB: we need the left side for comparison... left = -180
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
674 MOVII xA, sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
675 MOVLI .180,sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
676 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
677 MOVII sub_c,xB ; xB has the left side of the 180° distance center
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
678 ; xA = xRD > (xC+100) ? RD-280 : xRD+80
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
679 MOVII xC, sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
680 ADDLI .100,sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
681 MOVII xRD, sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
682 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
683 btfsc neg_flag ; xRD > xC + 100 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
684 bra TFT_dive_compass_bearing_lr_2 ; YES - xA = xRD - 280
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
685 ; NO - xA = xRD + 80
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
686 MOVII xRD,xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
687 ADDLI .80,xA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
688 bra TFT_dive_compass_bearing_lr_c
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
689
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
690 TFT_dive_compass_bearing_lr_2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
691 MOVII xRD,sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
692 MOVLI .280,sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
693 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
694 MOVII sub_c,xA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
695 ;bra TFT_dive_compass_bearing_lr_c
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
696
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
697 TFT_dive_compass_bearing_lr_c:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
698 ; xB < xA < xC => right, otherwise left (default)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
699 MOVII xA,sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
700 MOVII xB,sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
701 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
702 btfss neg_flag ; xA > xB ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
703 bra TFT_dive_compass_ruler ; NO - xB >= xA, keep default left
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
704 MOVII xA,sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
705 MOVII xC,sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
706 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
707 btfss neg_flag ; xC > xA ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
708 bra TFT_dive_compass_ruler ; NO - xA >= xC, keep default left
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
709 bcf compass_bearing_lft
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
710
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
711 TFT_dive_compass_ruler:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
712 ; calculate mod15 for the ticks
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
713 MOVII xRD,xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
714 MOVLI .15,xB
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
715 call div16x16 ; xA/xB=xC with xA+0 as remainder
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
716 ; check the remainder
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
717 movlw d'0'
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
718 cpfsgt xA+0 ; mod15 > 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
719 bra TFT_dive_compass_ruler_1 ; NO - RM = 0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
720 ; YES - RM = 15 - RDmod15
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
721 movlw d'15'
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
722 subfwb xA+0,F
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
723 TFT_dive_compass_ruler_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
724 movff xA+0,lo ; xA+0 holds the RM, store it to 'lo'
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
725 clrf hi ; initialize DD to zero, store it to 'hi'
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
726
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
727 TFT_dive_compass_ruler_loop:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
728 ; 1. check if we run out of the display
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
729 movlw d'159' ; looks like 159 works because TFT_box limits the display
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
730 cpfslt lo,1
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
731 bra TFT_dive_compass_ruler_lend ; xRM >= W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
732 ; 2. Clear the tick area from DD to RM - in segments to avoid blinking
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
733 ; don't do a clear if we are at 0 (zero) otherwise it will blink
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
734 ; because of the width underflow
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
735 movlw d'0'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
736 cpfsgt lo,1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
737 bra TFT_dive_compass_ruler_loop_zz
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
738 rcall TFT_dive_compass_clr_ruler
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
739 TFT_dive_compass_ruler_loop_zz:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
740 ; 3. Draw the markers @ RM
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
741 ; we receive RM in lo and DD in hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
742 movlw dm_custom_compass_tick_top_top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
743 movwf win_top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
744 movlw dm_custom_compass_tick_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
745 movwf win_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
746 movlw d'2'
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
747 movwf win_bargraph
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
748 movwf win_width+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
749 clrf win_width+1
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
750 movff lo,win_leftx2 ; 0..159
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
751 call TFT_standard_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
752 call TFT_box
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
753 movlw dm_custom_compass_tick_bot_top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
754 movwf win_top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
755 movlw dm_custom_compass_tick_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
756 movwf win_height
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
757 call TFT_standard_color ; color in WREG is trashed, must be set again!
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
758 call TFT_box
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
759 ; 4. If D<82 and RM>79: means we put something over the center line
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
760 ; redraw the center line
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
761 movlw d'82'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
762 cpfslt hi,1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
763 bra TFT_dive_compass_ruler_loop_zz2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
764 movlw d'79'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
765 cpfsgt lo,1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
766 bra TFT_dive_compass_ruler_loop_zz2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
767 ; enough to print center line as bearing marker is not in the ticker area
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
768 movlw color_yellow
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
769 WIN_BOX_COLOR dm_custom_compass_tick_top_top, dm_custom_compass_tick_bot_bot,.80,.81 ; center line in yellow
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
770 TFT_dive_compass_ruler_loop_zz2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
771 ; 5. set D = RM + 2 : position after the 2px tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
772 movff lo,hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
773 movlw d'2'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
774 addwf hi,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
775 ; 6. set RM = RM + 15 : position to the next tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
776 movlw d'15'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
777 addwf lo,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
778 ; 7. loop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
779 bra TFT_dive_compass_ruler_loop
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
780
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
781 TFT_dive_compass_ruler_lend: ; loop end
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
782 ; 8. clear the rest of the tick area if D<160
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
783 movlw d'160'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
784 cpfslt hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
785 bra TFT_dive_compass_ruler_lend2 ; D >= W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
786 ; 9. position left to end of display to clear the remaining area
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
787 movlw d'159'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
788 movwf lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
789 ; 10. clear it
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
790 rcall TFT_dive_compass_clr_ruler
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
791
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
792 TFT_dive_compass_ruler_lend2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
793 ; done with the compass ruler, put the labels on the screen
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
794 clrf hi ; hi stores the display position
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
795 movff hi,xHI ; bank-safe clear of xHI
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
796 clrf lo ; lo stores the last item's display position
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
797 movff lo,xLO ; bank-safe clear of xLO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
798 MOVLI .219,sub_a ; position of the cardinal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
799 MOVII xRD, sub_b ; get the RD back to sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
800 rcall TFT_dive_compass_label_proc ; check if the cardinal should be on screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
801 btfss compass_show_cardinal ; shall show cardinal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
802 bra dcr_1 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
803 STRCPY_TEXT_PRINT tSW ; YES - print it
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
804 dcr_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
805 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
806 MOVLI .267,sub_a ; position of the cardinal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
807 rcall TFT_dive_compass_label_proc ; check if the cardinal should be on screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
808 btfss compass_show_cardinal ; shall show cardinal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
809 bra dcr_2 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
810 STRCPY_TEXT_PRINT tW ; YES - print it
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
811 dcr_2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
812 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
813 MOVLI .309,sub_a ; position of the cardinal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
814 rcall TFT_dive_compass_label_proc ; check if the cardinal should be on screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
815 btfss compass_show_cardinal ; shall show cardinal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
816 bra dcr_3 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
817 STRCPY_TEXT_PRINT tNW ; YES - print it
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
818 dcr_3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
819 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
820 MOVLI .358,sub_a ; position of the cardinal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
821 rcall TFT_dive_compass_label_proc ; check if the cardinal should be on screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
822 btfss compass_show_cardinal ; shall show cardinal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
823 bra dcr_4 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
824 STRCPY_TEXT_PRINT tN ; YES - print it
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
825 dcr_4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
826 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
827 MOVLI .399,sub_a ; position of the cardinal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
828 rcall TFT_dive_compass_label_proc ; check if the cardinal should be on screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
829 btfss compass_show_cardinal ; shall show cardinal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
830 bra dcr_5 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
831 STRCPY_TEXT_PRINT tNE ; YES - print it
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
832 dcr_5:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
833 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
834 MOVLI .448,sub_a ; position of the cardinal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
835 rcall TFT_dive_compass_label_proc ; check if the cardinal should be on screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
836 btfss compass_show_cardinal ; shall show cardinal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
837 bra dcr_6 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
838 STRCPY_TEXT_PRINT tE ; YES - print it
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
839 dcr_6:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
840 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
841 MOVLI .489,sub_a ; position of the cardinal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
842 rcall TFT_dive_compass_label_proc ; check if the cardinal should be on screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
843 btfss compass_show_cardinal ; shall show cardinal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
844 bra dcr_7 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
845 STRCPY_TEXT_PRINT tSE ; YES - print it
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
846 dcr_7:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
847 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
848 MOVLI .538,sub_a ; position of the cardinal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
849 rcall TFT_dive_compass_label_proc ; check if the cardinal should be on screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
850 btfss compass_show_cardinal ;shall show cardinal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
851 bra dcr_8 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
852 STRCPY_TEXT_PRINT tS ; YES - print it
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
853 dcr_8:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
854 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
855 MOVLI .579,sub_a ; position of the cardinal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
856 rcall TFT_dive_compass_label_proc ; check if the cardinal should be on screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
857 btfss compass_show_cardinal ; shall show cardinal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
858 bra dcr_9 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
859 STRCPY_TEXT_PRINT tSW ; YES - print it
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
860 dcr_9:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
861 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
862 MOVLI .627,sub_a ; position of the cardinal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
863 rcall TFT_dive_compass_label_proc ; check if the cardinal should be on screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
864 btfss compass_show_cardinal ; shall show cardinal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
865 bra dcr_10 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
866 STRCPY_TEXT_PRINT tW ; YES - print it
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
867 dcr_10:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
868 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
869 MOVLI .669,sub_a ; position of the cardinal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
870 rcall TFT_dive_compass_label_proc ; check if the cardinal should be on screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
871 btfss compass_show_cardinal ; shall show cardinal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
872 bra dcr_11 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
873 STRCPY_TEXT_PRINT tNW ; YES - print it
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
874 dcr_11:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
875 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
876 MOVLI .718,sub_a ; position of the cardinal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
877 rcall TFT_dive_compass_label_proc ; check if the cardinal should be on screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
878 btfss compass_show_cardinal ; shall show?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
879 bra dcr_12 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
880 STRCPY_TEXT_PRINT tN ; YES - print it
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
881 dcr_12:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
882 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
883
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
884 TFT_dive_compass_label_end:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
885 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
886 ; restore lo and hi for the final cleanup
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
887 movff xLO,lo ; xLO and xHI are stored in bank isr_backup
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
888 movff xHI,hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
889 ; clear the rest of the SQ area if there are more space
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
890 movlw d'159'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
891 cpfslt hi
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
892 bra TFT_dive_compass_label_end2 ; D >= 160, no more space
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
893 ; position left to end of display to clear the remaining area
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
894 movlw d'158'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
895 movwf lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
896 ; clear it
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
897 rcall TFT_dive_compass_clr_label
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
898 TFT_dive_compass_label_end2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
899 rcall TFT_dive_compass_c_mk ; check if cardinal is on the center line or the marker
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
900 ; do we have bearing set?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
901 btfsc compass_bearing_set ; bearing set?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
902 bra TFT_dive_compass_dir_text ; YES - print the direction (<< or >>)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
903 rcall TFT_dive_compass_dir_lclr ; NO - clear the area (e.g. we had but removed)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
904 rcall TFT_dive_compass_dir_rclr
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
905 bra TFT_dive_compass_text
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
906
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
907 TFT_dive_compass_dir_text:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
908 ; bearing set, but does it point to heading?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
909 btfss compass_bearing_eq
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
910 bra TFT_dive_compass_dir_text_2 ; bearing != heading - go and print the direction
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
911 rcall TFT_dive_compass_dir_lclr ; bearing == heading - no need for direction markers
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
912 rcall TFT_dive_compass_dir_rclr
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
913 bra TFT_dive_compass_text
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
914
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
915 TFT_dive_compass_dir_text_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
916 movlw color_green
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
917 call TFT_set_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
918 btfsc compass_bearing_lft
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
919 bra TFT_dive_compass_dir_ldir ; bearing_lft=1, print the left marker
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
920 ;TFT_dive_compass_text_rdir:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
921 WIN_SMALL dm_custom_compass_rdir_column, dm_custom_compass_head_row-.2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
922 STRCPY_PRINT ">>"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
923 rcall TFT_dive_compass_dir_lclr ; do not forget to clear the left
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
924 bra TFT_dive_compass_text
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
925
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
926 TFT_dive_compass_dir_ldir:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
927 WIN_SMALL dm_custom_compass_ldir_column, dm_custom_compass_head_row-.2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
928 STRCPY_PRINT "<<"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
929 rcall TFT_dive_compass_dir_rclr ; do not forget to clear the right
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
930 ;bra TFT_dive_compass_text
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
931
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
932 TFT_dive_compass_text:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
933 ; Clear some unused space on the right mH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
934 WIN_BOX_BLACK dm_custom_compass_tick_top_bot+.1,dm_custom_compass_tick_bot_top-.1,.158,.159 ; top, bottom, left, right
371
fec5eec4c8b7 fix some display issues with display1
heinrichsweikamp
parents: 370
diff changeset
935
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
936 ; Text output
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
937 call TFT_standard_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
938 WIN_SMALL dm_custom_compass_head_column, dm_custom_compass_head_row
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
939 rcall TFT_surface_compass_heading_com ; show "000° N"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
940 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
941
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
942 TFT_dive_compass_dir_lclr:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
943 WIN_SMALL dm_custom_compass_ldir_column, dm_custom_compass_head_row-.2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
944 STRCPY_PRINT " "
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
945 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
946
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
947 TFT_dive_compass_dir_rclr:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
948 WIN_SMALL dm_custom_compass_rdir_column, dm_custom_compass_head_row-.2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
949 STRCPY_PRINT " "
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
950 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
951
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
952 TFT_dive_compass_label_proc:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
953 movlw d'14'
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
954 movwf up ; cardinal width in px
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
955 bcf compass_show_cardinal
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
956 ; 1/a. check if it's viewable ? sub_a(RP) >= sub_b(RD) ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
957 ; set the carry flag if sub_b(xRD) is equal to or greater than sub_a(xRP):
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
958 MOVII xRD,sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
959 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
960 btfsc neg_flag ; >= 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
961 return ; NO
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
962 ; store the RO=RP-RD for drawing
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
963 MOVII sub_c,xC
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
964
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
965 ; 1/b. check if it's viewable ? sub_a(RP)+up(width) < sub_b(RD)+160
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
966 ; if already above, no need to process the rest of the labels
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
967 movff up,WREG ; take care about the width
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
968 addwf sub_a+0,1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
969 btfsc STATUS, C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
970 incf sub_a+1
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
971
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
972 MOVII xRDr,sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
973 call subU16 ; sub_c = sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
974 btfss neg_flag ; < 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
975 bra TFT_dive_compass_label_end ; NO
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
976
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
977 ; 2. restore RO=RP-RD from 1/a.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
978 movff xC+0,lo
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
979
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
980 ; 3. Clear the segment from DD(hi) to lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
981 ; don't do a clear if we are at 0 (zero) otherwise it will blink
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
982 ; ?because of the width underflow?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
983 movlw d'1'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
984 cpfsgt lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
985 bra TFT_dive_compass_label_proc_p
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
986 rcall TFT_dive_compass_clr_label
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
987 TFT_dive_compass_label_proc_p:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
988 ; 4. print the SQ on the screen
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
989 call TFT_standard_color
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
990 bsf compass_show_cardinal
257
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
991 ;TFT_dive_compass_label_print:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
992 movlw dm_custom_compass_label_row
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
993 movff WREG,win_top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
994 movff lo,win_leftx2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
995 WIN_FONT FT_SMALL
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
996 ; 6. retain the new display positions
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
997 movff lo,hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
998 movff up,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
999 addwf hi,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1000 movff lo,xLO
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1001 movff hi,xHI
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1002 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1003
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1004 TFT_dive_compass_c_mk:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1005 ; Common task to draw center line and marker
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1006 ; until a proper implementation make it simple:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1007 rcall TFT_dive_compass_mk
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1008 movlw color_yellow
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1009 WIN_BOX_COLOR dm_custom_compass_tick_top_top, dm_custom_compass_tick_bot_bot,.80,.81 ; center line in yellow
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1010 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1011
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1012 TFT_dive_compass_mk:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1013 ; draw the bearing on the screen if visible and if we just put something over it
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1014 btfss compass_bearing_set
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1015 return ; bearing_set=0 nothing to display
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1016
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1017 btfss compass_bearing_vis
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1018 return ; bearing set but not visible
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1019
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1020 ; save lo/hi from trashing
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1021 MOVII mpr,xA
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1022
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1023 ; did we just update the marker's position?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1024 ; DD.......DD
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1025 ; CM+2>=DD(old) or CM-2<=DD
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1026 ; ToDo
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1027
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1028 btfss compass_bearing_ahd
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1029 bra TFT_dive_compass_mk_rear
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1030 ;TFT_dive_compass_mk_front:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1031 clrf lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1032 movff xCM,lo
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1033 bsf compass_show_cardinal ; set=green marker
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1034 rcall TFT_dive_compass_mk_print
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1035 bcf compass_show_cardinal
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1036 bra TFT_dive_compass_mk_end
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1037
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1038 TFT_dive_compass_mk_rear:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1039 clrf lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1040 movff xCM,lo
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1041 bcf compass_show_cardinal ; set=red marker
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1042 rcall TFT_dive_compass_mk_print
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1043
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1044 TFT_dive_compass_mk_end:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1045 MOVII xA,mpr
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1046 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1047
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1048 TFT_dive_compass_mk_print:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1049 movlw d'1'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1050 cpfsgt lo
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1051 bra TFT_dive_compass_mk_print_2 ; lo <= 1, skip the first line
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1052 movlw d'2'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1053 subwf lo,0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1054 ; movff WREG,win_leftx2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1055 rcall TFT_dive_compass_mk_print_3
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1056 TFT_dive_compass_mk_print_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1057 ; save hi/lo
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1058 MOVII mpr,divA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1059 ; clear the middle of the bearing marker
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1060 movff lo,hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1061 movlw d'2'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1062 addwf lo,1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1063 rcall TFT_dive_compass_clr_label
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1064 ; restore hi/lo
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1065 MOVII divA,mpr
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1066 ; print a dot on the middle
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1067 movf lo,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1068 rcall TFT_dive_compass_mk_print_dot
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1069 ; finally print the right marker line
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1070 movlw d'2'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1071 addwf lo,0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1072 ; rcall TFT_dive_compass_mk_print_3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1073 ; return
257
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1074 TFT_dive_compass_mk_print_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1075 movwf win_leftx2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1076 movlw dm_custom_compass_label_row
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1077 movwf win_top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1078 movlw dm_custom_compass_label_height-.2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1079 movwf win_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1080 bra TFT_dive_compass_mk_print_4
264
9dbdb060d44c Fix compass ruler's missing bottom ticks; Clear between the bearing marker lines and draw a dot.
janos_kovacs <kovjanos@gmail.com>
parents: 259
diff changeset
1081 TFT_dive_compass_mk_print_dot:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1082 movwf win_leftx2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1083 movlw dm_custom_compass_label_row + .9
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1084 movwf win_top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1085 movlw d'4'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1086 movwf win_height
264
9dbdb060d44c Fix compass ruler's missing bottom ticks; Clear between the bearing marker lines and draw a dot.
janos_kovacs <kovjanos@gmail.com>
parents: 259
diff changeset
1087 TFT_dive_compass_mk_print_4:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1088 movlw .158
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1089 cpfslt win_leftx2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1090 bra TFT_dive_compass_mk_print_5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1091 movlw d'2'
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1092 movwf win_bargraph
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1093 movwf win_width+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1094 clrf win_width+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1095 movlw color_green
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1096 btfss compass_show_cardinal
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1097 movlw color_red
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1098 call TFT_set_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1099 call TFT_box
371
fec5eec4c8b7 fix some display issues with display1
heinrichsweikamp
parents: 370
diff changeset
1100 TFT_dive_compass_mk_print_5:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1101 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1102
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1103 TFT_dive_compass_clr_label:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1104 movlw dm_custom_compass_label_row-.2 ; set top & height
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1105 movwf win_top
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1106 movlw dm_custom_compass_label_height+.2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1107 movwf win_height
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1108 rcall TFT_dive_compass_clear
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1109 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1110
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1111 TFT_dive_compass_clr_ruler:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1112 ; top tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1113 movlw dm_custom_compass_tick_top_top ; set top & height
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1114 movwf win_top
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1115 movlw dm_custom_compass_tick_height
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1116 movwf win_height
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1117 rcall TFT_dive_compass_clear
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1118 ;bottom tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1119 movlw dm_custom_compass_tick_bot_top ; set top & height
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1120 movwf win_top
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1121 movlw dm_custom_compass_tick_height
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1122 movwf win_height
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1123 ; rcall TFT_dive_compass_clear
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1124 ; return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1125 TFT_dive_compass_clear:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1126 ; we receive RM in lo and DD in hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1127 ; calculate width = RM-D
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1128 movf hi,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1129 subwf lo,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1130 bz TFT_dive_compass_clear3 ; do nothing if there is nothing to do
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1131 movwf win_width+0 ; RM-DD
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1132 movwf win_bargraph
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1133 clrf win_width+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1134 movlw .1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1135 cpfsgt win_width+0
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1136 bra TFT_dive_compass_clear3 ; do not clear a single pixel (or less)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1137 movff hi,win_leftx2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1138 movlw color_black
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1139 call TFT_set_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1140 call TFT_box
370
67e631aa5b8c debugging the compass screen
heinrichsweikamp
parents: 337
diff changeset
1141 TFT_dive_compass_clear3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1142 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1143
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1144 tft_compass_cardinal:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1145 btfsc hi,0 ; heading > 255° ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1146 bra tft_compass_cardinal2 ; YES - must be W, NW or N
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1147 ; NO - must be W, SW, S, SE, E, NE or N
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1148 movlw .23
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1149 subwf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1150 btfss STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1151 bra tft_compass_cardinal_N
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1152 movlw .68
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1153 subwf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1154 btfss STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1155 bra tft_compass_cardinal_NE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1156 movlw .113
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1157 subwf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1158 btfss STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1159 bra tft_compass_cardinal_E
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1160 movlw .158
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1161 subwf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1162 btfss STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1163 bra tft_compass_cardinal_SE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1164 movlw .203
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1165 subwf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1166 btfss STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1167 bra tft_compass_cardinal_S
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1168 movlw .248
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1169 subwf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1170 btfss STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1171 bra tft_compass_cardinal_SW
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1172 bra tft_compass_cardinal_W
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1173
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1174 tft_compass_cardinal2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1175 movlw .37
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1176 subwf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1177 btfss STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1178 bra tft_compass_cardinal_W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1179 movlw .82
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1180 subwf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1181 btfss STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1182 bra tft_compass_cardinal_NW
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1183 ; bra tft_compass_cardinal_N
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1184
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1185 tft_compass_cardinal_N:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1186 STRCAT_TEXT tN
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1187 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1188 tft_compass_cardinal_NE:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1189 STRCAT_TEXT tNE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1190 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1191 tft_compass_cardinal_E:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1192 STRCAT_TEXT tE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1193 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1194 tft_compass_cardinal_SE:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1195 STRCAT_TEXT tSE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1196 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1197 tft_compass_cardinal_S:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1198 STRCAT_TEXT tS
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1199 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1200 tft_compass_cardinal_SW:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1201 STRCAT_TEXT tSW
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1202 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1203 tft_compass_cardinal_W:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1204 STRCAT_TEXT tW
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1205 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1206 tft_compass_cardinal_NW:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1207 STRCAT_TEXT tNW
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1208 return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1209
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1210
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1211 compass_heading_common:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1212 btfss compass_enabled ; compass enabled?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1213 bra compass_heading_common3 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1214
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1215 movlw compass_averaging ; number of averaging cycles
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1216 movwf up ; initialize loop counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1217 compass_heading_common1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1218 call I2C_RX_compass ; test compass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1219 call I2C_RX_accelerometer ; test accelerometer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1220 call compass_filter ; filter raw compass + accelerometer readings
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1221 decfsz up,F ; decrement loop counter, done?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1222 bra compass_heading_common1 ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1223
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1224 call compass ; do compass corrections (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1225 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1226
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1227 MOVII compass_heading_old,sub_a ; transfer old heading to sub16 input
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1228 MOVII compass_heading_new,sub_b ; transfer new heading to sub16 input
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1229
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1230 btfsc sub_b+1,7 ; valid compass calibration?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1231 bra compass_heading_common3 ; NO
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1232
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1233 call sub16 ; calculate compass_heading_old - compass_heading_new
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1234 btfss neg_flag ; result < 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1235 bra compass_heading_common2 ; NO - test for threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1236 MOVII compass_heading_new,sub_a ; YES - subtract the other way round
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1237 MOVII compass_heading_old,sub_b ; - ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1238 call sub16 ; - calculate compass_heading_new - compass_heading_old
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1239
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1240 compass_heading_common2:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1241 MOVII compass_heading_new,compass_heading_old ; copy new to old
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1242 movlw compass_fast_treshold ; get threshold for fast
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1243 cpfsgt sub_c+0 ; heading difference > compass_fast_treshold ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1244 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1245 MOVII compass_heading_new,compass_heading_shown ; YES - copy heading
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1246 return ; - done
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1247
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1248 compass_heading_common3:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1249 clrf mpr+0 ; NO - create encoding of 0°
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1250 clrf mpr+1 ; - ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1251 MOVII mpr,compass_heading_shown ; - copy to compass_heading_shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1252 return ; - done
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1253
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 621
diff changeset
1254 ENDIF ; _compass
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1255
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 574
diff changeset
1256 END