annotate src/compass_ops.asm @ 311:778b59f39529

FIX missing extern .C definition.
author jdg@air
date Tue, 09 Jun 2015 02:15:01 +0200
parents 5ad479f2a868
children 508d7fb98b34
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 264
diff changeset
1 #include "hwos.inc"
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
2 #include "i2c.inc"
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
3 #include "tft_outputs.inc"
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
4 #include "isr.inc"
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
5 #include "tft.inc"
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
6 #include "strings.inc"
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
7 #include "wait.inc" ; speed_*
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
8 #include "surfmode.inc"
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
9 #include "divemode.inc"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
10 #include "math.inc"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
11 #include "convert.inc"
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
12
0
heinrichsweikamp
parents:
diff changeset
13
heinrichsweikamp
parents:
diff changeset
14 ; Make sure symbols from the .inc are available to the C code:
heinrichsweikamp
parents:
diff changeset
15 ; Filtered data
heinrichsweikamp
parents:
diff changeset
16 global compass_DX_f, compass_DY_f, compass_DZ_f
heinrichsweikamp
parents:
diff changeset
17 global accel_DX_f, accel_DY_f, accel_DZ_f
heinrichsweikamp
parents:
diff changeset
18
heinrichsweikamp
parents:
diff changeset
19 ; Calibration data
heinrichsweikamp
parents:
diff changeset
20 global compass_CX_f
heinrichsweikamp
parents:
diff changeset
21 global compass_CY_f
heinrichsweikamp
parents:
diff changeset
22 global compass_CZ_f
heinrichsweikamp
parents:
diff changeset
23
heinrichsweikamp
parents:
diff changeset
24 ; Tmp values to pass Q15 arithmetics around
heinrichsweikamp
parents:
diff changeset
25 global compass_a
heinrichsweikamp
parents:
diff changeset
26 global compass_b
heinrichsweikamp
parents:
diff changeset
27
heinrichsweikamp
parents:
diff changeset
28 ; Result
214
a17359244d93 compass changes
heinrichsweikamp
parents: 148
diff changeset
29 global compass_heading; , compass_roll, compass_pitch
0
heinrichsweikamp
parents:
diff changeset
30
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
31 extern compass
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
32 extern compass_reset_calibration
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
33 extern compass_add_calibration
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
34 extern compass_solve_calibration
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
35
282
7d9edd3b8c86 Make a more compact COMPASS calibration code (<7KB), and add more tests.
jDG
parents: 275
diff changeset
36 compass_ops code
0
heinrichsweikamp
parents:
diff changeset
37 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
38 ; Filter compass values
heinrichsweikamp
parents:
diff changeset
39 ;
heinrichsweikamp
parents:
diff changeset
40 ; Apply linear filtering to input parameters.
heinrichsweikamp
parents:
diff changeset
41
heinrichsweikamp
parents:
diff changeset
42 ; Apply filtering formula:
heinrichsweikamp
parents:
diff changeset
43 ; reg_f += (reg - reg_f) / 4
heinrichsweikamp
parents:
diff changeset
44 FILTER16 MACRO reg, reg_f
heinrichsweikamp
parents:
diff changeset
45 movf reg_f+0,W
heinrichsweikamp
parents:
diff changeset
46 subwf reg+0,W
heinrichsweikamp
parents:
diff changeset
47 movwf PRODL
heinrichsweikamp
parents:
diff changeset
48 movf reg_f+1,W
heinrichsweikamp
parents:
diff changeset
49 subwfb reg+1,W
148
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
50 rcall filter_16_common
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
51 addwf reg_f+0,F
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
52 movf PRODH,W
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
53 addwfc reg_f+1,F
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
54 ENDM
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
55
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
56 filter_16_common:
0
heinrichsweikamp
parents:
diff changeset
57 movwf PRODH
heinrichsweikamp
parents:
diff changeset
58
heinrichsweikamp
parents:
diff changeset
59 bcf STATUS,C ; Copy sign bit into carry
heinrichsweikamp
parents:
diff changeset
60 btfsc PRODH,7
heinrichsweikamp
parents:
diff changeset
61 bsf STATUS,C
heinrichsweikamp
parents:
diff changeset
62 rrcf PRODH,F ; 16bit shift right
heinrichsweikamp
parents:
diff changeset
63 rrcf PRODL,F
heinrichsweikamp
parents:
diff changeset
64
heinrichsweikamp
parents:
diff changeset
65 bcf STATUS,C ; Copy sign bit into carry
heinrichsweikamp
parents:
diff changeset
66 btfsc PRODH,7
heinrichsweikamp
parents:
diff changeset
67 bsf STATUS,C
heinrichsweikamp
parents:
diff changeset
68 rrcf PRODH,F ; 16bit shift right
heinrichsweikamp
parents:
diff changeset
69 rrcf PRODL,W
148
022b886eddaf some cleanup
heinrichsweikamp
parents: 147
diff changeset
70 return
0
heinrichsweikamp
parents:
diff changeset
71
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
72 global compass_filter
0
heinrichsweikamp
parents:
diff changeset
73 compass_filter:
heinrichsweikamp
parents:
diff changeset
74 banksel compass_DX
heinrichsweikamp
parents:
diff changeset
75
heinrichsweikamp
parents:
diff changeset
76 FILTER16 compass_DX, compass_DX_f
heinrichsweikamp
parents:
diff changeset
77 FILTER16 compass_DY, compass_DY_f
heinrichsweikamp
parents:
diff changeset
78 FILTER16 compass_DZ, compass_DZ_f
heinrichsweikamp
parents:
diff changeset
79 FILTER16 accel_DX, accel_DX_f
heinrichsweikamp
parents:
diff changeset
80 FILTER16 accel_DY, accel_DY_f
heinrichsweikamp
parents:
diff changeset
81 FILTER16 accel_DZ, accel_DZ_f
heinrichsweikamp
parents:
diff changeset
82 banksel common
heinrichsweikamp
parents:
diff changeset
83 return
heinrichsweikamp
parents:
diff changeset
84
heinrichsweikamp
parents:
diff changeset
85 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
86
heinrichsweikamp
parents:
diff changeset
87 compass_filter_init:
heinrichsweikamp
parents:
diff changeset
88 movff compass_DX+0, compass_DX_f+0
heinrichsweikamp
parents:
diff changeset
89 movff compass_DX+1, compass_DX_f+1
heinrichsweikamp
parents:
diff changeset
90 movff compass_DY+0, compass_DY_f+0
heinrichsweikamp
parents:
diff changeset
91 movff compass_DY+1, compass_DY_f+1
heinrichsweikamp
parents:
diff changeset
92 movff compass_DZ+0, compass_DZ_f+0
heinrichsweikamp
parents:
diff changeset
93 movff compass_DZ+1, compass_DZ_f+1
heinrichsweikamp
parents:
diff changeset
94 movff accel_DX+0, accel_DX_f+0
heinrichsweikamp
parents:
diff changeset
95 movff accel_DX+1, accel_DX_f+1
heinrichsweikamp
parents:
diff changeset
96 movff accel_DY+0, accel_DY_f+0
heinrichsweikamp
parents:
diff changeset
97 movff accel_DY+1, accel_DY_f+1
heinrichsweikamp
parents:
diff changeset
98 movff accel_DZ+0, accel_DZ_f+0
heinrichsweikamp
parents:
diff changeset
99 movff accel_DZ+1, accel_DZ_f+1
heinrichsweikamp
parents:
diff changeset
100 return
heinrichsweikamp
parents:
diff changeset
101
heinrichsweikamp
parents:
diff changeset
102 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
103 ; Q15 fractional numbers: a * b / 2**16 (UNSIGNED)
heinrichsweikamp
parents:
diff changeset
104 ;
heinrichsweikamp
parents:
diff changeset
105 ; Uses 16x16->16 multiply, for positiv integers, keeping only the most
heinrichsweikamp
parents:
diff changeset
106 ; revelant bits.
heinrichsweikamp
parents:
diff changeset
107 ;
heinrichsweikamp
parents:
diff changeset
108 ; Used to multiply two Q15 numbers, in the range 0..1,
heinrichsweikamp
parents:
diff changeset
109 ; represented as 0..32767, that is a / 2**15.
heinrichsweikamp
parents:
diff changeset
110 ;
heinrichsweikamp
parents:
diff changeset
111 ; (a/2**15) * (b/2**15) = a*b / 2**30 = (a*b/2**16) / 2**14.
heinrichsweikamp
parents:
diff changeset
112 ; So to get back a Q15 number, we need a shift-left...
heinrichsweikamp
parents:
diff changeset
113 global compass_umul
heinrichsweikamp
parents:
diff changeset
114 compass_umul:
heinrichsweikamp
parents:
diff changeset
115 rcall compass_mul_16
heinrichsweikamp
parents:
diff changeset
116
heinrichsweikamp
parents:
diff changeset
117 ; The 2x time, by left-shifting inserting the missing bit:
heinrichsweikamp
parents:
diff changeset
118 compass_mul_2:
heinrichsweikamp
parents:
diff changeset
119 rlcf compass_r+2,F ; Missing bit into carry
heinrichsweikamp
parents:
diff changeset
120 rlcf compass_r+0,F
heinrichsweikamp
parents:
diff changeset
121 rlcf compass_r+1,F
heinrichsweikamp
parents:
diff changeset
122 movff compass_r+0,PRODL ; return value into ProdH:L
heinrichsweikamp
parents:
diff changeset
123 movff compass_r+1,PRODH
heinrichsweikamp
parents:
diff changeset
124 return
heinrichsweikamp
parents:
diff changeset
125
heinrichsweikamp
parents:
diff changeset
126 ; The 16x16-> multiply:
heinrichsweikamp
parents:
diff changeset
127 compass_mul_16:
heinrichsweikamp
parents:
diff changeset
128 banksel compass_a
heinrichsweikamp
parents:
diff changeset
129
heinrichsweikamp
parents:
diff changeset
130 movf compass_a+1,W ; Block ah*bh
heinrichsweikamp
parents:
diff changeset
131 mulwf compass_b+1
heinrichsweikamp
parents:
diff changeset
132 movff PRODL,compass_r+0 ; and copy
heinrichsweikamp
parents:
diff changeset
133 movff PRODH,compass_r+1
heinrichsweikamp
parents:
diff changeset
134
heinrichsweikamp
parents:
diff changeset
135 movf compass_a+0,W ; Block al*bl
heinrichsweikamp
parents:
diff changeset
136 mulwf compass_b+0
heinrichsweikamp
parents:
diff changeset
137 movff PRODH,compass_r+2 ; Into fraction byte
heinrichsweikamp
parents:
diff changeset
138
heinrichsweikamp
parents:
diff changeset
139 movf compass_a+1,W ; Block ah*bl
heinrichsweikamp
parents:
diff changeset
140 mulwf compass_b+0
heinrichsweikamp
parents:
diff changeset
141 movf PRODL,W
heinrichsweikamp
parents:
diff changeset
142 addwf compass_r+2,F ; Fraction part to carry.
heinrichsweikamp
parents:
diff changeset
143 movf PRODH,W ; and add16
heinrichsweikamp
parents:
diff changeset
144 addwfc compass_r+0,F
heinrichsweikamp
parents:
diff changeset
145 movlw 0
heinrichsweikamp
parents:
diff changeset
146 addwfc compass_r+1,F
heinrichsweikamp
parents:
diff changeset
147
heinrichsweikamp
parents:
diff changeset
148 movf compass_a+0,W ; Block al*bh
heinrichsweikamp
parents:
diff changeset
149 mulwf compass_b+1
heinrichsweikamp
parents:
diff changeset
150 movf PRODL,W
heinrichsweikamp
parents:
diff changeset
151 addwf compass_r+2,F ; Fraction part to carry.
heinrichsweikamp
parents:
diff changeset
152 movf PRODH,W ; and add16
heinrichsweikamp
parents:
diff changeset
153 addwfc compass_r+0,F
heinrichsweikamp
parents:
diff changeset
154 movlw 0
heinrichsweikamp
parents:
diff changeset
155 addwfc compass_r+1,F
heinrichsweikamp
parents:
diff changeset
156
heinrichsweikamp
parents:
diff changeset
157 return
heinrichsweikamp
parents:
diff changeset
158
heinrichsweikamp
parents:
diff changeset
159 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
160 ; Q15 fractional numbers: a * b / 2**16 (SIGNED)
heinrichsweikamp
parents:
diff changeset
161
heinrichsweikamp
parents:
diff changeset
162 global compass_imul
heinrichsweikamp
parents:
diff changeset
163 compass_imul:
heinrichsweikamp
parents:
diff changeset
164 rcall compass_mul_16
heinrichsweikamp
parents:
diff changeset
165
heinrichsweikamp
parents:
diff changeset
166 btfss compass_b+1,7
heinrichsweikamp
parents:
diff changeset
167 bra compass_mul_3
heinrichsweikamp
parents:
diff changeset
168
heinrichsweikamp
parents:
diff changeset
169 movf compass_a+0,W
heinrichsweikamp
parents:
diff changeset
170 subwf compass_r+0,F
heinrichsweikamp
parents:
diff changeset
171 movf compass_a+1,W
heinrichsweikamp
parents:
diff changeset
172 subwfb compass_r+1,F
heinrichsweikamp
parents:
diff changeset
173
heinrichsweikamp
parents:
diff changeset
174 compass_mul_3:
heinrichsweikamp
parents:
diff changeset
175 btfss compass_a+1,7
heinrichsweikamp
parents:
diff changeset
176 bra compass_mul_4
heinrichsweikamp
parents:
diff changeset
177
heinrichsweikamp
parents:
diff changeset
178 movf compass_b+0,W
heinrichsweikamp
parents:
diff changeset
179 subwf compass_r+0,F
heinrichsweikamp
parents:
diff changeset
180 movf compass_b+1,W
heinrichsweikamp
parents:
diff changeset
181 subwfb compass_r+1,F
heinrichsweikamp
parents:
diff changeset
182
heinrichsweikamp
parents:
diff changeset
183 compass_mul_4:
heinrichsweikamp
parents:
diff changeset
184 bcf compass_r+1,6 ; Copy bit 7 to 6, so keep it after 2x
heinrichsweikamp
parents:
diff changeset
185 btfsc compass_r+1,7
heinrichsweikamp
parents:
diff changeset
186 bsf compass_r+1,6
heinrichsweikamp
parents:
diff changeset
187 bra compass_mul_2
heinrichsweikamp
parents:
diff changeset
188
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
189 global compass_calibration_loop
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
190 compass_calibration_loop: ; Compass calibration
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
191 bsf no_sensor_int ; No Sensor ISR
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
192 call I2C_sleep_accelerometer ; Stop accelerometer
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
193 call I2C_sleep_compass ; Stop compass
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
194 call TFT_ClearScreen
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
195 ; Mask
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
196 WIN_COLOR color_greenish
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
197 WIN_SMALL .16,.0
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
198 STRCPY_TEXT_PRINT tCompassMenu
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
199 btfss switch_right2 ; wait until button is released
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
200 bra $-4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
201
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
202 call TFT_standard_color
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
203 ; WIN_SMALL .0,.215
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
204 ; STRCPY_TEXT_PRINT tExit
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
205 WAITMS d'255'
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
206 WAITMS d'255'
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
207 movlw .7 ; Gain init
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
208 movff WREG,opt_compass_gain
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
209 compass_calibration_gainset: ; Reduce the gain, set bank here!
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
210 banksel opt_compass_gain
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
211 decf opt_compass_gain,F ; Reduce by one
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
212 btfsc STATUS,N ; <0?
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
213 clrf opt_compass_gain ; Yes, keep at zero
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
214
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
215 banksel common
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
216 call I2C_init_accelerometer
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
217 call I2C_init_compass_fast
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
218 rcall TFT_compass_show_gain ; Show the current compass gain
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
219
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
220 WAITMS d'100'
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
221
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
222 clrf timeout_counter2
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
223 clrf timeout_counter3
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
224
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
225 call speed_fastest
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
226 call I2C_RX_compass ; read compass
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
227 call I2C_RX_accelerometer ; read Accelerometer
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
228
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
229 ; Test all axes for +4096 (Hi byte=16)
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
230 banksel compass_DX+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
231 movlw .16
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
232 cpfseq compass_DX+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
233 bra $+4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
234 bra compass_calibration_gainset
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
235 cpfseq compass_DY+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
236 bra $+4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
237 bra compass_calibration_gainset
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
238 cpfseq compass_DZ+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
239 bra $+4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
240 bra compass_calibration_gainset
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
241
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
242 ; Test all axes for -4096 (Hi byte=240)
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
243 movlw .240
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
244 cpfseq compass_DX+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
245 bra $+4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
246 bra compass_calibration_gainset
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
247 cpfseq compass_DY+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
248 bra $+4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
249 bra compass_calibration_gainset
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
250 cpfseq compass_DZ+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
251 bra $+4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
252 bra compass_calibration_gainset
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
253 banksel common
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
254
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
255 rcall compass_filter_init ; set DX_f values
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
256 call compass_reset_calibration ; Reset CX_f values
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
257 banksel common
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
258
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
259 compass_calibration_loop2:
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
260 call I2C_RX_compass ; read compass
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
261 call I2C_RX_accelerometer ; Test Accelerometer
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
262 rcall compass_filter ; Filter compass raw data
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
263 banksel common
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
264
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
265 ; Twice
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
266 call I2C_RX_compass ; read compass
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
267 call I2C_RX_accelerometer ; Test Accelerometer
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
268 rcall compass_filter ; Filter compass raw data
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
269 banksel common
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
270
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
271 ; Test all axes for +4096 (Hi byte=16)
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
272 banksel compass_DX+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
273 movlw .16
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
274 cpfseq compass_DX+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
275 bra $+4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
276 bra compass_calibration_gainset
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
277 cpfseq compass_DY+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
278 bra $+4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
279 bra compass_calibration_gainset
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
280 cpfseq compass_DZ+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
281 bra $+4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
282 bra compass_calibration_gainset
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
283
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
284 ; Test all axes for -4096 (Hi byte=240)
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
285 movlw .240
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
286 cpfseq compass_DX+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
287 bra $+4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
288 bra compass_calibration_gainset
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
289 cpfseq compass_DY+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
290 bra $+4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
291 bra compass_calibration_gainset
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
292 cpfseq compass_DZ+1
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
293 bra $+4
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
294 bra compass_calibration_gainset
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
295 banksel common
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
296 ;
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
297 ; ; Three
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
298 ; call I2C_RX_compass ; read compass
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
299 ; call I2C_RX_accelerometer ; Test Accelerometer
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
300 ; call compass_filter ; Filter compass raw data
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
301 ; banksel common
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
302 ;
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
303 ; ; Four times to get cleaner values
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
304 ; call I2C_RX_compass ; read compass
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
305 ; call I2C_RX_accelerometer ; Test Accelerometer
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
306 ; call compass_filter ; Filter compass raw data
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
307
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
308 ; And register only one value out of four:
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
309 call compass_add_calibration ; check and store new max/min values
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
310 banksel common
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
311
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
312 call TFT_compass_fast ; show values
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
313
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
314 btfsc sleepmode ; Sleepmode active?
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
315 bra compass_calibration_exit ; Yes, exit
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
316
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
317 ; btfsc switch_left ; Button pressed?
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
318 ; bra compass_calibration_exit ; Yes, exit
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
319
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
320 btfss onesecupdate ; do every second tasks?
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
321 bra compass_calibration_loop2 ; no, loop here
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
322
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
323 movlw .60
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
324 call timeout_testmode ; check timeout
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
325 movlw .60
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
326 rcall TFT_show_timeout_testmode ; Show the timeout
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
327
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
328 bcf onesecupdate ; clear flag
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
329
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
330 bra compass_calibration_loop2 ; loop here
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
331
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
332 compass_calibration_exit:
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
333 call compass_solve_calibration
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
334 banksel common
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
335 extern option_save_all
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
336 call option_save_all ; save all settings into EEPROM
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
337 bcf sleepmode ; Clear the flag before exiting to surfacemode
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
338 movlw .6
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
339 movwf customview_surfmode ; Set to compass view...
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
340 goto surfloop ; ...and exit
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
341
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
342 global TFT_compass_fast
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
343 TFT_compass_fast:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
344 WIN_TINY .20,.50
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
345 STRCPY "X:"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
346 movff compass_DX+0,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
347 movff compass_DX+1,hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
348 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
349 output_16
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
350 STRCAT " Y:"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
351 movff compass_DY+0,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
352 movff compass_DY+1,hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
353 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
354 output_16
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
355 STRCAT " Z:"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
356 movff compass_DZ+0,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
357 movff compass_DZ+1,hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
358 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
359 output_16
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
360 STRCAT_PRINT " "
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
361 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
362
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
363 TFT_show_timeout_testmode: ; With timeout in WREG...
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
364 movwf hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
365 WIN_TINY .20,.68
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
366 STRCPY "T:"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
367 movf timeout_counter2,W ; current timeout
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
368 subwf hi,W ; subtract from timeout value
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
369 addlw .1 ; +1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
370 movwf lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
371 bsf leftbind
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
372 output_8 ; Display timeout
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
373 bcf leftbind
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
374 STRCAT_PRINT "s "
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
375 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
376
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
377
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
378 TFT_compass_show_gain: ; Show the current compass gain
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
379 movff opt_compass_gain,lo ; 0-7 (230LSB/Gauss to 1370LSB/Gaus)
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
380 tstfsz lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
381 return ; Do not show unless gain=0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
382 WIN_TINY .20,.86
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
383 STRCPY_TEXT tCompassGain
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
384 movff opt_compass_gain,lo ; 0-7 (230LSB/Gauss to 1370LSB/Gaus)
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
385 bsf leftbind
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
386 output_8
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
387 bcf leftbind
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
388 STRCAT_PRINT "!"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
389 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
390
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
391 global TFT_surface_compass_mask
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
392 TFT_surface_compass_mask:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
393 WIN_SMALL surf_compass_mask_column,surf_compass_mask_row
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
394 call TFT_standard_color
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
395 STRCPY_TEXT_PRINT tHeading ; Heading:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
396 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
397
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
398 global TFT_dive_compass_mask
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
399 TFT_dive_compass_mask:
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
400 WIN_FRAME_STD dm_custom_compass_graph_row, dm_custom_compass_graph_row+dm_custom_compass_graph_height, .0, .159
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
401 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
402
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
403 global TFT_surface_compass_heading
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
404 TFT_surface_compass_heading:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
405 rcall compass_heading_common
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
406 WIN_STD surf_compass_head_column,surf_compass_head_row
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
407 call TFT_standard_color
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
408 TFT_surface_compass_heading_com: ; Show "000° N"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
409 movff compass_heading+0,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
410 movff compass_heading+1,hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
411 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
412
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
413 ; Shown and actual identical?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
414 movff compass_heading_shown+0,WREG
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
415 cpfseq lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
416 bra TFT_surface_compass_heading_com1 ; Not equal
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
417 movff compass_heading_shown+1,WREG
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
418 cpfseq hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
419 bra TFT_surface_compass_heading_com1 ; Not equal
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
420 bra TFT_surface_compass_heading_com3 ; equal, skip smoothing
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
421
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
422 TFT_surface_compass_heading_com1:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
423 movff lo,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
424 movff hi,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
425 movff compass_heading_shown+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
426 movff compass_heading_shown+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
427 call subU16
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
428 btfsc neg_flag
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
429 bra TFT_surface_compass_heading_com2 ; shown > actual
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
430 ; shown < actual
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
431 banksel compass_heading_shown
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
432 infsnz compass_heading_shown+0,F
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
433 incf compass_heading_shown+1,F ; +1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
434 bra TFT_surface_compass_heading_com3
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
435
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
436 TFT_surface_compass_heading_com2:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
437 banksel compass_heading_shown
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
438 movlw d'1'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
439 subwf compass_heading_shown+0,F
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
440 movlw d'0'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
441 subwfb compass_heading_shown+1,F ; -1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
442
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
443 TFT_surface_compass_heading_com3:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
444 banksel common
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
445 movff compass_heading_shown+0,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
446 movff compass_heading_shown+1,hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
447 bsf leftbind
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
448 output_16dp .2 ; Result is "0.000"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
449 bcf leftbind
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
450 ; rearrange figures to "000"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
451 movff buffer+2,buffer+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
452 movff buffer+3,buffer+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
453 movff buffer+4,buffer+2
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
454 lfsr FSR2,buffer+3
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
455 STRCAT "° "
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
456 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
457 clrf WREG
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
458 movff WREG,buffer+.7 ; limit to 7 chars
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
459 STRCAT_PRINT ""
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
460 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
461
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
462 global TFT_dive_compass_heading
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
463 TFT_dive_compass_heading:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
464 rcall compass_heading_common
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
465 ; ; ToDo - these are for development only, hardcoding the bearing position
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
466 ; ; 244° : SW - W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
467 ; movlw low(d'244')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
468 ; movff WREG,compass_bearing+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
469 ; movlw high(d'244')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
470 ; movff WREG,compass_bearing+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
471
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
472 movff compass_heading_shown+0,xA+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
473 movff compass_heading_shown+1,xA+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
474 ; xRD and xRDlft
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
475 ; 1. 160° viewing angle: +360 offset if xA<=292; for non-negative scale
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
476 movlw high(d'292')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
477 movff WREG,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
478 movlw low(d'292')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
479 movff WREG,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
480 movff xA+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
481 movff xA+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
482 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
483 btfsc neg_flag ; xA>292
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
484 bra TFT_dive_compass_heading_1 ;yes
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
485 ; no, xA<=292
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
486 movlw high(d'360')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
487 addwf xA+1,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
488 movlw low(d'360')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
489 addwf xA+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
490 btfsc STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
491 incf xA+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
492 TFT_dive_compass_heading_1:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
493 ; 2. -80: left pixel offset from the center
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
494 movlw low( d'80' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
495 subwf xA+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
496 btfss STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
497 decf xA+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
498 ; 3. save it to xRD
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
499 movff xA+0,xRD+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
500 movff xA+1,xRD+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
501 ; 4. add 160 (display px width)
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
502 movlw high(d'160')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
503 addwf xA+1,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
504 movlw low(d'160')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
505 addwf xA+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
506 btfsc STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
507 incf xA+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
508 ; 5. save it to xRDr
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
509 movff xA+0,xRDr+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
510 movff xA+1,xRDr+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
511
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
512 ; ; Bearing ?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
513 ; ; We can skip this xRD180 calculation if no bearing is set
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
514 ; bcf compass_bearing_set
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
515 ; movff compass_bearing+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
516 ; movff compass_bearing+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
517 ; movlw d'0'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
518 ; cpfseq sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
519 ; bra TFT_dive_compass_bearing ; something set, calculate xRD180
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
520 ; movlw d'0'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
521 ; cpfseq sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
522 ; bra TFT_dive_compass_bearing ; something set, calculate xRD180
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
523 ; bra TFT_dive_compass_ruler ; no value in the bearing, skip calc
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
524 ;
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
525 ;TFT_dive_compass_bearing:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
526 ; bsf compass_bearing_set
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
527
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
528 btfss compass_bearing_set
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
529 bra TFT_dive_compass_ruler ; no value in the bearing, skip calc
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
530
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
531 ; we have bearing set, we will need xRD180 calculated
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
532 ; xRD180 is xRDr-180
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
533 movff xRDr+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
534 movff xRDr+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
535 movlw high(d'180')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
536 movff WREG,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
537 movlw low(d'180')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
538 movff WREG,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
539 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
540 movff sub_c+1,xRD180+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
541 movff sub_c+0,xRD180+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
542
258
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
543 TFT_dive_compass_bearing_1:
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
544 ; calculate bearing position and visibility (ahead or behind)
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
545 bcf compass_bearing_vis ; default is not-visibly
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
546 bcf compass_bearing_ahd ; default is behind
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
547 ; get the bearing virtual display offset, store it to divA
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
548 movff compass_bearing+0,xA+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
549 movff compass_bearing+1,xA+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
550 movlw high(d'360')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
551 addwf xA+1,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
552 movlw low(d'360')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
553 addwf xA+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
554 btfsc STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
555 incf xA+1
258
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
556 ; save it to reuse for upper/lower turns and ahead/behind checks
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
557 movff xA+1,divA+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
558 movff xA+0,divA+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
559
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
560 ; check if it's ahead
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
561 ; load the bearing offset into sub_a
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
562 movff divA+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
563 movff divA+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
564 ; load the display offset back to sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
565 movff xRD+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
566 movff xRD+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
567 rcall TFT_dive_compass_bearing_ap
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
568 ;test if we found it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
569 btfsc compass_bearing_vis
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
570 bra TFT_dive_compass_bearing_dir
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
571
258
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
572 ; check if it's ahead with an upper turn
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
573 ; load the bearing offset into sub_a
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
574 movff divA+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
575 movff divA+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
576 ; load the display offset back to sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
577 movff xRD+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
578 movff xRD+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
579 movlw high(d'360')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
580 addwf sub_b+1,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
581 movlw low(d'360')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
582 addwf sub_b+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
583 btfsc STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
584 incf sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
585 rcall TFT_dive_compass_bearing_ap
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
586 ;test if we found it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
587 btfsc compass_bearing_vis
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
588 bra TFT_dive_compass_bearing_dir
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
589
258
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
590 ; check if it's ahead with a lower turn
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
591 ; load the bearing offset into sub_a
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
592 movff divA+1,sub_a+1
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
593 movff divA+0,sub_a+0
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
594 movlw high(d'360')
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
595 addwf sub_a+1,1
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
596 movlw low(d'360')
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
597 addwf sub_a+0,1
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
598 btfsc STATUS,C
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
599 incf sub_a+1
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
600 ; load the display offset back to sub_b
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
601 movff xRD+0,sub_b+0
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
602 movff xRD+1,sub_b+1
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
603 rcall TFT_dive_compass_bearing_ap
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
604 ;test if we found it
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
605 btfsc compass_bearing_vis
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
606 bra TFT_dive_compass_bearing_dir
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
607
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
608 ; marker is not ahead of us, check if it's behind us
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
609 ; use the (160 - (xRD180 - xCM)) formula to see if it's on the display
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
610 ; load the display offset back to sub_a
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
611 movff xRD180+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
612 movff xRD180+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
613 ; load the marker's offset into sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
614 movff divA+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
615 movff divA+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
616 rcall TFT_dive_compass_bearing_bp
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
617 ;test if we found it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
618 btfsc compass_bearing_vis
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
619 bra TFT_dive_compass_bearing_dir
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
620
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
621 ;check if it's behind with the lower turn
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
622 movff xRD180+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
623 movff xRD180+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
624 movlw high(d'360')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
625 addwf sub_a+1,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
626 movlw low(d'360')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
627 addwf sub_a+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
628 btfsc STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
629 incf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
630 ; load the marker's offset into sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
631 movff divA+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
632 movff divA+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
633 rcall TFT_dive_compass_bearing_bp
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
634 ;test if we found it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
635 btfsc compass_bearing_vis
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
636 bra TFT_dive_compass_bearing_dir
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
637
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
638 ; check if it's behind with the upper turn
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
639 movff divA+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
640 movff divA+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
641 movlw high(d'360')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
642 addwf sub_b+1,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
643 movlw low(d'360')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
644 addwf sub_b+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
645 btfsc STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
646 incf sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
647 rcall TFT_dive_compass_bearing_bp
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
648 bra TFT_dive_compass_bearing_dir
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
649
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
650 TFT_dive_compass_bearing_ap:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
651 ; xCM received in sub_a
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
652 ; xRD received in sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
653 ; 1/a. check if it's viewable from the left side
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
654 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
655 btfsc neg_flag ; xRD>divA
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
656 return ;no,
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
657 ; yes, store the RO=RP-RD for drawing
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
658 movff sub_c+0,xC+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
659 movff sub_c+1,xC+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
660 ; 1/b. check if it's viewable from the right side?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
661 movlw d'2' ; avoid thin mess on the side of the display
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
662 addwf sub_a+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
663 btfsc STATUS, C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
664 incf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
665 ; load the display offset right side into sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
666 movlw high(d'160')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
667 addwf sub_b+1,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
668 movlw low(d'160')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
669 addwf sub_b+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
670 btfsc STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
671 incf sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
672 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
673 btfss neg_flag ; xRDr>xA(+2)
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
674 return ; no,
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
675 ; print the bearing lines on the screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
676 movff xC+0,xCM
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
677 bsf compass_bearing_vis ; set visible
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
678 bsf compass_bearing_ahd ; set ahead
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
679 return ; done,
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
680
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
681 TFT_dive_compass_bearing_bp:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
682 ; use the (160 - (xRD180 - xCM)) formula to see if it's on the display
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
683 ; the marker's offset received in sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
684 ; the xRD180 display offset received in sub_a
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
685 ; xRD180 - xCM
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
686 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
687 btfsc neg_flag ; CM>xRD180
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
688 return ; no, not on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
689 ; 160 - (X)
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
690 movlw high(d'160')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
691 movff WREG,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
692 movlw low(d'160')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
693 movff WREG,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
694 movff sub_c+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
695 movff sub_c+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
696 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
697 btfsc neg_flag ; X>160
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
698 return ; no, not on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
699 ; check if not overflow - this sounds a double check...
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
700 movlw d'1'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
701 cpfslt sub_c+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
702 return ; high set, >160
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
703 movlw d'160'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
704 cpfslt sub_c+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
705 return ; low >160
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
706 ; print the bearing lines on the screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
707 movff sub_c+0,xCM
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
708 bsf compass_bearing_vis
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
709 return ; done
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_bearing_dir:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
712 ; check if bearing to heading, and calculate the direction
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
713 bcf compass_bearing_eq
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
714 btfss compass_bearing_vis
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
715 bra TFT_dive_compass_bearing_lr
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
716 btfss compass_bearing_ahd
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
717 bra TFT_dive_compass_bearing_lr
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
718 movff xCM,xA+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
719 movlw d'80'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
720 cpfseq xA+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
721 bra TFT_dive_compass_bearing_lr
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
722 bsf compass_bearing_eq
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
723 bra TFT_dive_compass_ruler ; bearing points to heading, no signs are required, go to the ruler
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
724
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
725 TFT_dive_compass_bearing_lr:
258
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
726 ; get the bearing virtual display offset
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
727 movff compass_bearing+0,xA+0
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
728 movff compass_bearing+1,xA+1
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
729 ; divA =IF (U10>292;U10;U10+360)
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
730 movlw high(d'292')
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
731 movff WREG,sub_a+1
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
732 movlw low(d'292')
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
733 movff WREG,sub_a+0
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
734 movff xA+1,sub_b+1
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
735 movff xA+0,sub_b+0
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
736 call subU16 ; sub_c = sub_a - sub_b
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
737 btfsc neg_flag ; xA>292
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
738 bra TFT_dive_compass_bearing_lr_1 ;yes
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
739 ; no, xA<=292
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
740 movlw high(d'360')
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
741 addwf xA+1,1
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
742 movlw low(d'360')
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
743 addwf xA+0,1
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
744 btfsc STATUS,C
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
745 incf xA+1
da9074180bff patch for bearing issue
heinrichsweikamp
parents: 257
diff changeset
746 TFT_dive_compass_bearing_lr_1:
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
747 ; 1. calculate whether bearing is to left or to right
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
748 bsf compass_bearing_lft ; to the left by default
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
749 ; xC: save center value to compare the direction to front value
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
750 movff xA+1,xC+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
751 movff xA+0,xC+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
752 ; xB: we need the left side for comparism... left = -180
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
753 movff xA+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
754 movff xA+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
755 movlw high(d'180')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
756 movff WREG,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
757 movlw low(d'180')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
758 movff WREG,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
759 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
760 movff sub_c+1,xB+1 ; xB has the left side of the 180° distance center
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
761 movff sub_c+0,xB+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
762 ; xA = IF(xRD>(xC+100);xRD-280;xRD+80)
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
763 movff xC+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
764 movff xC+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
765 movlw d'100'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
766 addwf sub_a+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
767 btfsc STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
768 incf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
769 movff xRD+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
770 movff xRD+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
771 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
772 btfsc neg_flag ; xRD>xC+100
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
773 bra TFT_dive_compass_bearing_lr_2 ; yes, xA=xRD-280
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
774 ; no, xA = xRD+80
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
775 movff xRD+1,xA+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
776 movff xRD+0,xA+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
777 movlw d'80'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
778 addwf xA+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
779 btfsc STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
780 incf xA+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
781 bra TFT_dive_compass_bearing_lr_c
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
782
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
783 TFT_dive_compass_bearing_lr_2:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
784 ; xA=xRD-280
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
785 movff xRD+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
786 movff xRD+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
787 movlw high(d'280')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
788 movff WREG,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
789 movlw low(d'280')
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
790 movff WREG,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
791 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
792 movff sub_c+1,xA+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
793 movff sub_c+0,xA+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
794 ;bra TFT_dive_compass_bearing_lr_c
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
795
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
796 TFT_dive_compass_bearing_lr_c:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
797 ; xB < xA < xC => right, otherwise left (default)
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
798 movff xA+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
799 movff xA+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
800 movff xB+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
801 movff xB+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
802 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
803 btfss neg_flag ; xA>xB ?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
804 bra TFT_dive_compass_ruler ; No, xB >= xA, keep default left
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
805 movff xA+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
806 movff xA+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
807 movff xC+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
808 movff xC+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
809 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
810 btfss neg_flag ; xC>xA ?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
811 bra TFT_dive_compass_ruler ; No, xA >= xC, keep default left
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
812 bcf compass_bearing_lft
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
813
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
814 TFT_dive_compass_ruler:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
815 ; calculate mod15 for the ticks
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
816 movff xRD+0,xA+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
817 movff xRD+1,xA+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
818 movlw d'15'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
819 movwf xB+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
820 clrf xB+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
821 call div16x16 ;xA/xB=xC with xA+0 as remainder
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
822 ; check xA+0, it has the remainder
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
823 movlw d'0'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
824 cpfsgt xA+0 ; mod15 > 0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
825 bra TFT_dive_compass_ruler_1 ; no, RM = 0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
826 ; yes RM = 15 - RDmod15
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
827 movlw d'15'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
828 subfwb xA+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
829 TFT_dive_compass_ruler_1:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
830 ; xA+0 holds the RM, store it to 'lo'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
831 movff xA+0,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
832 ; init DD to zero, store it to 'hi'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
833 movlw d'0'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
834 movff WREG,hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
835
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
836 TFT_dive_compass_ruler_loop:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
837 ; 1. check if we run of from the display
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
838 movlw d'160' ; Looks like 160 works because TFT_box limits the dispay
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
839 cpfslt lo,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
840 bra TFT_dive_compass_ruler_lend ; xRM >= W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
841 ; 2. Clear the tick area from DD to RM - in segments to avoid blinking
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
842 ; don't do a clear if we are at 0 (zero) otherwise it will blink
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
843 ; because of the width underflow
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
844 movlw d'0'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
845 cpfsgt lo,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
846 bra TFT_dive_compass_ruler_loop_zz
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
847 rcall TFT_dive_compass_clr_ruler
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
848 TFT_dive_compass_ruler_loop_zz:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
849 ; 3. Draw the markers @ RM
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
850 rcall TFT_dive_compass_ruler_print
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
851 ; 4. If D<82 and RM>79: means we put something over the center line
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
852 ; redraw the center line
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
853 movlw d'82'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
854 cpfslt hi,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
855 bra TFT_dive_compass_ruler_loop_zz2
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
856 movlw d'79'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
857 cpfsgt lo,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
858 bra TFT_dive_compass_ruler_loop_zz2
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
859 rcall TFT_dive_compass_cline ;enough to print cline as bearing marker is not in the ticker area
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
860 TFT_dive_compass_ruler_loop_zz2:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
861 ; 5. set D = RM + 2 : position after the 2px tick
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
862 movff lo,hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
863 movlw d'2'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
864 addwf hi,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
865 ; 6. set RM = RM + 15 : position to the next tick
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
866 movlw d'15'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
867 addwf lo,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
868 ; 7. loop
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
869 bra TFT_dive_compass_ruler_loop
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
870
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
871 TFT_dive_compass_ruler_lend: ; loop end
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
872 ; 8. clear the rest of the tick area if D<160
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
873 movlw d'160'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
874 cpfslt hi,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
875 bra TFT_dive_compass_ruler_lend2 ; D >= W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
876 ; 9. position left to end of display to clear the remaining area
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
877 movlw d'160'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
878 movwf lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
879 ; 10. clear it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
880 rcall TFT_dive_compass_clr_ruler
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
881
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
882 TFT_dive_compass_ruler_lend2:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
883 ; done with the compass ruler, put the labels on the screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
884 ; get the RD abck to sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
885 movff xRD+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
886 movff xRD+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
887 ; hi stores the display position
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
888 movlw d'0'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
889 movwf hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
890 ; lo stores the last item's display position
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
891 movlw d'0'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
892 movwf lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
893 bcf print_compass_label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
894
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
895 movlw d'14'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
896 movwf up ; up stores the width of hte label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
897 movlw low( d'219' ) ; position of the label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
898 movwf sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
899 movlw high( d'219' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
900 movwf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
901 rcall TFT_dive_compass_label_proc ; check if the label should be on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
902 btfss print_compass_label ; Yes?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
903 bra dcr_1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
904 STRCPY_TEXT_PRINT tSW ; yes - print it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
905 dcr_1:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
906 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
907
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
908 movlw d'7'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
909 movwf up ; up stores the width of hte label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
910 movlw low( d'267' ) ; position of the label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
911 movwf sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
912 movlw high( d'267' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
913 movwf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
914 rcall TFT_dive_compass_label_proc ; check if the label should be on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
915 btfss print_compass_label ; Yes?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
916 bra dcr_2
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
917 STRCPY_TEXT_PRINT tW ; yes - print it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
918 dcr_2:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
919 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
920
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
921 movlw d'14'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
922 movwf up ; up stores the width of hte label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
923 movlw low( d'309' ) ; position of the label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
924 movwf sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
925 movlw high( d'309' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
926 movwf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
927 rcall TFT_dive_compass_label_proc ; check if the label should be on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
928 btfss print_compass_label ; Yes?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
929 bra dcr_3
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
930 STRCPY_TEXT_PRINT tNW ; yes - print it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
931 dcr_3:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
932 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
933
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
934 movlw d'6'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
935 movwf up ; up stores the width of hte label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
936 movlw low( d'358' ) ; position of the label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
937 movwf sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
938 movlw high( d'358' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
939 movwf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
940 rcall TFT_dive_compass_label_proc ; check if the label should be on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
941 btfss print_compass_label ; Yes?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
942 bra dcr_4
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
943 STRCPY_TEXT_PRINT tN ; yes - print it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
944 dcr_4:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
945 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
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 movlw d'13'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
948 movwf up ; up stores the width of hte label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
949 movlw low( d'399' ) ; position of the label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
950 movwf sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
951 movlw high( d'399' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
952 movwf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
953 rcall TFT_dive_compass_label_proc ; check if the label should be on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
954 btfss print_compass_label ; Yes?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
955 bra dcr_5
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
956 STRCPY_TEXT_PRINT tNE ; yes - print it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
957 dcr_5:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
958 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
959
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
960 movlw d'6'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
961 movwf up ; up stores the width of hte label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
962 movlw low( d'448' ) ; position of the label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
963 movwf sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
964 movlw high( d'448' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
965 movwf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
966 rcall TFT_dive_compass_label_proc ; check if the label should be on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
967 btfss print_compass_label ; Yes?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
968 bra dcr_6
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
969 STRCPY_TEXT_PRINT tE ; yes - print it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
970 dcr_6:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
971 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
972
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
973 movlw d'13'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
974 movwf up ; up stores the width of hte label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
975 movlw low( d'489' ) ; position of the label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
976 movwf sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
977 movlw high( d'489' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
978 movwf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
979 rcall TFT_dive_compass_label_proc ; check if the label should be on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
980 btfss print_compass_label ; Yes?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
981 bra dcr_7
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
982 STRCPY_TEXT_PRINT tSE ; yes - print it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
983 dcr_7:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
984 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
985
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
986 movlw d'6'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
987 movwf up ; up stores the width of hte label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
988 movlw low( d'538' ) ; position of the label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
989 movwf sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
990 movlw high( d'538' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
991 movwf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
992 rcall TFT_dive_compass_label_proc ; check if the label should be on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
993 btfss print_compass_label ; Yes?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
994 bra dcr_8
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
995 STRCPY_TEXT_PRINT tS ; yes - print it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
996 dcr_8:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
997 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
998
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
999 movlw d'14'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1000 movwf up ; up stores the width of hte label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1001 movlw low( d'579' ) ; position of the label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1002 movwf sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1003 movlw high( d'579' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1004 movwf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1005 rcall TFT_dive_compass_label_proc ; check if the label should be on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1006 btfss print_compass_label ; Yes?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1007 bra dcr_9
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1008 STRCPY_TEXT_PRINT tSW ; yes - print it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1009 dcr_9:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1010 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
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 movlw d'7'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1013 movwf up ; up stores the width of hte label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1014 movlw low( d'627' ) ; position of the label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1015 movwf sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1016 movlw high( d'627' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1017 movwf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1018 rcall TFT_dive_compass_label_proc ; check if the label should be on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1019 btfss print_compass_label ; Yes?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1020 bra dcr_10
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1021 STRCPY_TEXT_PRINT tW ; yes - print it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1022 dcr_10:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1023 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1024
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1025 movlw d'14'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1026 movwf up ; up stores the width of hte label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1027 movlw low( d'669' ) ; position of the label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1028 movwf sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1029 movlw high( d'669' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1030 movwf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1031 rcall TFT_dive_compass_label_proc ; check if the label should be on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1032 btfss print_compass_label ; Yes?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1033 bra dcr_11
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1034 STRCPY_TEXT_PRINT tNW ; yes - print it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1035 dcr_11:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1036 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
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 movlw d'6'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1039 movwf up ; up stores the width of hte label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1040 movlw low( d'718' ) ; position of the label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1041 movwf sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1042 movlw high( d'718' )
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1043 movwf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1044 rcall TFT_dive_compass_label_proc ; check if the label should be on screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1045 btfss print_compass_label ; Yes?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1046 bra dcr_12
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1047 STRCPY_TEXT_PRINT tN ; yes - print it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1048 dcr_12:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1049 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1050
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1051 TFT_dive_compass_label_end:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1052 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1053 ; restore lo and hi for the final cleanup
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1054 movff xLO,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1055 movff xHI,hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1056 ; clear the rest of the SQ area if there are more space
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1057 movlw d'160'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1058 cpfslt hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1059 bra TFT_dive_compass_label_end2 ; D >= 160, no more space
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1060 ; position left to end of display to clear the remaining area
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1061 movlw d'160'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1062 movff WREG,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1063 ; clear it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1064 rcall TFT_dive_compass_clr_label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1065 TFT_dive_compass_label_end2:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1066 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1067 ; do we have bearing set?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1068 btfsc compass_bearing_set
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1069 bra TFT_dive_compass_dir_text ; bearing_set=1 - go and print the dir (<< or >>)
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1070 rcall TFT_dive_compass_dir_lclr ; no, clear the area (e.g. we had but removed)
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1071 rcall TFT_dive_compass_dir_rclr
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1072 bra TFT_dive_compass_text
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1073
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1074 TFT_dive_compass_dir_text:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1075 ; bearing set, but does it point to heading?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1076 btfss compass_bearing_eq
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1077 bra TFT_dive_compass_dir_text_2 ; bearing != heading - go and print the dir
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1078 rcall TFT_dive_compass_dir_lclr ; bearing = heading, no need for direction markers
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1079 rcall TFT_dive_compass_dir_rclr
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1080 bra TFT_dive_compass_text
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1081
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1082 TFT_dive_compass_dir_text_2:
257
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1083 movlw color_green
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1084 call TFT_set_color
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1085 btfsc compass_bearing_lft
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1086 bra TFT_dive_compass_dir_ldir ; bearing_lft=1, print the left marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1087 ;TFT_dive_compass_text_rdir:
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1088 WIN_SMALL dm_custom_compass_rdir_column, dm_custom_compass_head_row
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1089 STRCPY_PRINT ">>"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1090 ; do not forget to clear the left
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1091 rcall TFT_dive_compass_dir_lclr
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1092 bra TFT_dive_compass_text
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1093
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1094 TFT_dive_compass_dir_ldir:
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1095 WIN_SMALL dm_custom_compass_ldir_column, dm_custom_compass_head_row
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1096 STRCPY_PRINT "<<"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1097 ; do not forget to clear the right
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1098 rcall TFT_dive_compass_dir_rclr
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1099 ;bra TFT_dive_compass_text
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1100
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1101 TFT_dive_compass_text:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1102 ; Text output
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1103 call TFT_standard_color
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1104 WIN_SMALL dm_custom_compass_head_column, dm_custom_compass_head_row
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1105 rcall TFT_surface_compass_heading_com ; Show "000° N"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1106 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1107
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1108 TFT_dive_compass_dir_lclr:
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1109 WIN_SMALL dm_custom_compass_ldir_column, dm_custom_compass_head_row
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1110 STRCPY_PRINT " "
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1111 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1112
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1113 TFT_dive_compass_dir_rclr:
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1114 WIN_SMALL dm_custom_compass_rdir_column, dm_custom_compass_head_row
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1115 STRCPY_PRINT " "
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1116 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1117
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1118 TFT_dive_compass_label_proc:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1119 ; Input:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1120 ; xHI: DD - display'a current position
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1121 ; xRD: RD - ruler display offset
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1122 ; sub_a: RP - item's ruler display offset
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1123 ; get the RD abck to sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1124 movff xHI,hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1125 bcf print_compass_label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1126 ; 1/a. check if it's viewable ? sub_a(RP) >= sub_b(RD) ?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1127 ; set the carry flag if sub_b(xRD) is equal to or greater than sub_a(xRP):
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1128 movff xRD+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1129 movff xRD+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1130 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1131 btfsc neg_flag ; >=0?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1132 return ; No
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1133 ; store the RO=RP-RD for drawing
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1134 movff sub_c+0,xC+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1135 movff sub_c+1,xC+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1136
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1137 ; 1/b. check if it's viewable ? sub_a(RP)+up(width) < sub_b(RD)+160
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1138 ; if already above, no need to process the rest of the labels
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1139 ;movff up,WREG ; don't worry about the width, low level call prevents overload
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1140 movlw d'2' ; .. but still avoid thin mess on the side of the display
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1141 addwf sub_a+0,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1142 btfsc STATUS, C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1143 incf sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1144
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1145 movff xRDr+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1146 movff xRDr+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1147 call subU16 ; sub_c = sub_a - sub_b
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1148 btfss neg_flag ; ? <0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1149 bra TFT_dive_compass_label_end ; No
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1150
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1151 ; 2. restore RO=RP-RD from 1/a.
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1152 movff xC+0,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1153
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1154 ; 3. Clear the segment from DD(hi) to lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1155 ; don't do a clear if we are at 0 (zero) otherwise it will blink
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1156 ; ?because of the width underflow?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1157 movlw d'0'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1158 cpfsgt lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1159 bra TFT_dive_compass_label_proc_p
257
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1160 rcall TFT_dive_compass_clr_label
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1161 TFT_dive_compass_label_proc_p:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1162 ; 4. print the SQ on the screen
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1163 call TFT_standard_color
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1164 bsf print_compass_label
257
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1165 ;TFT_dive_compass_label_print:
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1166 movlw dm_custom_compass_label_row
257
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1167 movff WREG,win_top
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1168 movff lo,win_leftx2
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1169 movlw FT_SMALL
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1170 movff WREG,win_font
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1171 ; 6. retain the new display positions
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1172 movff hi,divB ; old-hi will be used by the c_mk : clear+marker printing
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1173 movff lo,hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1174 movff up,WREG
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1175 addwf hi,1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1176 movff lo,xLO
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1177 movff hi,xHI
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1178 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1179
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1180 TFT_dive_compass_c_mk:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1181 ; Common task to draw center line and marker
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1182 ; until a proper implementation make it simple:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1183 rcall TFT_dive_compass_mk
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1184 rcall TFT_dive_compass_cline
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1185 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1186
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1187 TFT_dive_compass_mk:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1188 ; draw the bearing on the screen if visible and if we just put something over it
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1189 btfss compass_bearing_set
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1190 return ; bearing_set=0 nothing to display
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1191
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1192 btfss compass_bearing_vis
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1193 return ; bearing set but not visible
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1194
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1195 ; save lo/hi from trashing
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1196 movff lo,xA+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1197 movff hi,xA+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1198
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1199 ; did we just update the marker's position?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1200 ; DD.......DD
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1201 ; CM+2>=DD(old) or CM-2<=DD
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1202 ; ToDo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1203
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1204 btfss compass_bearing_ahd
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1205 bra TFT_dive_compass_mk_rear
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1206 ;TFT_dive_compass_mk_front:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1207 clrf lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1208 movff xCM,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1209 bsf print_compass_label ; set=green marker
257
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1210 rcall TFT_dive_compass_mk_print
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1211 bcf print_compass_label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1212 bra TFT_dive_compass_mk_end
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1213
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1214 TFT_dive_compass_mk_rear:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1215 clrf lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1216 movff xCM,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1217 bcf print_compass_label ; set=red marker
257
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1218 rcall TFT_dive_compass_mk_print
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1219
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1220 TFT_dive_compass_mk_end:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1221 movff xA+0,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1222 movff xA+1,hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1223 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1224
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1225 TFT_dive_compass_mk_print:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1226 movlw d'1'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1227 cpfsgt lo
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
1228 bra TFT_dive_compass_mk_print_2 ; lo<=1, skip the first line
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1229 movlw d'2'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1230 subwf lo,0
257
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1231 ; movff WREG,win_leftx2
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1232 rcall TFT_dive_compass_mk_print_3
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1233 TFT_dive_compass_mk_print_2:
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
1234 ; save hi/lo
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
1235 movff hi,divA+1
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
1236 movff lo,divA+0
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
1237 ; clear the middle of hte bearing marker
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
1238 movff lo,hi
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
1239 movlw d'2'
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
1240 addwf lo,1
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
1241 rcall TFT_dive_compass_clr_label
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
1242 ; restore hi/lo
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
1243 movff divA+1,hi
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
1244 movff divA+0,lo
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
1245 ; print a dot on the middle
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
1246 movff lo,WREG
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
1247 rcall TFT_dive_compass_mk_print_dot
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
1248 ; finally print the right marker line
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1249 movlw d'2'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1250 addwf lo,0
257
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1251 ; rcall TFT_dive_compass_mk_print_3
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1252 ; return
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1253 TFT_dive_compass_mk_print_3:
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1254 movff WREG,win_leftx2
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1255 movlw dm_custom_compass_label_row
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1256 movff WREG,win_top
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1257 movlw dm_custom_compass_label_height-.2
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1258 movff WREG,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
1259 bra TFT_dive_compass_mk_print_4
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
1260 TFT_dive_compass_mk_print_dot:
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
1261 movff WREG,win_leftx2
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1262 movlw dm_custom_compass_label_row + .9
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
1263 movff WREG,win_top
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
1264 movlw d'4'
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
1265 movff WREG,win_height
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
1266 TFT_dive_compass_mk_print_4:
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1267 movlw d'2'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1268 movff WREG,win_width
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1269 movff WREG,win_bargraph
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1270 movlw color_green
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1271 btfss print_compass_label
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1272 movlw color_red
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1273 call TFT_set_color
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1274 call TFT_box
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1275 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1276
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1277 TFT_dive_compass_clr_label:
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1278 movlw dm_custom_compass_label_row-.2 ; set top & height
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1279 movff WREG,win_top
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1280 movlw dm_custom_compass_label_height+.2
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1281 movff WREG,win_height
257
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1282 rcall TFT_dive_compass_clear
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1283 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1284
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1285 TFT_dive_compass_clr_ruler:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1286 ; top tick
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1287 movlw dm_custom_compass_tick_top_top ; set top & height
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1288 movff WREG,win_top
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1289 movlw dm_custom_compass_tick_height
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1290 movff WREG,win_height
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1291 rcall TFT_dive_compass_clear
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1292 ;bottom tick
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1293 movlw dm_custom_compass_tick_bot_top ; set top & height
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1294 movff WREG,win_top
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1295 movlw dm_custom_compass_tick_height
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1296 movff WREG,win_height
257
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1297 ; rcall TFT_dive_compass_clear
5dd0f39d05d4 minor speed and size improvements for the compass routine
heinrichsweikamp
parents: 256
diff changeset
1298 ; return
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1299 TFT_dive_compass_clear:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1300 ; we receive RM in lo and DD in hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1301 ; calculate width = RM-D
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1302 movff hi,WREG
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1303 subwf lo,0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1304 movff WREG,win_width ; RM-DD
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1305 movff WREG,win_bargraph
259
151148e2281f minor cleanup
heinrichsweikamp
parents: 258
diff changeset
1306 ; incf hi,W ; +1 pixel to avopid clipping of chars
151148e2281f minor cleanup
heinrichsweikamp
parents: 258
diff changeset
1307 ; movff WREG,win_leftx2
151148e2281f minor cleanup
heinrichsweikamp
parents: 258
diff changeset
1308 movff hi,win_leftx2
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1309 movlw color_black
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1310 call TFT_set_color
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1311 call TFT_box
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1312 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1313
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1314 TFT_dive_compass_ruler_print:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1315 ; we receive RM in lo and DD in hi
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1316 movlw dm_custom_compass_tick_top_top
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1317 movff WREG,win_top
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1318 movlw dm_custom_compass_tick_height
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1319 movff WREG,win_height
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1320 movlw d'2'
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1321 movff WREG,win_width
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1322 movff WREG,win_bargraph
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1323 movff lo,win_leftx2 ; 0..159
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1324 call TFT_standard_color
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1325 call TFT_box
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1326 movlw dm_custom_compass_tick_bot_top
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1327 movff WREG,win_top
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1328 movlw dm_custom_compass_tick_height
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1329 movff WREG,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
1330 call TFT_standard_color ; color in WREG is trashed, must be set again!
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1331 call TFT_box
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1332 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1333
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1334 TFT_dive_compass_cline:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1335 movlw color_yellow
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 282
diff changeset
1336 WIN_BOX_COLOR dm_custom_compass_tick_top_top, dm_custom_compass_tick_bot_bot,.80,.81
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1337 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1338
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1339 tft_compass_cardinal:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1340 btfsc hi,0 ; Heading >255°?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1341 bra tft_compass_cardinal2 ; Yes must be W, NW or N
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1342 ; No, Must be W, SW, S, SE, E, NE or N
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1343 movlw .23
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1344 subwf lo,W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1345 btfss STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1346 bra tft_compass_cardinal_N
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1347 movlw .68
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1348 subwf lo,W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1349 btfss STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1350 bra tft_compass_cardinal_NE
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1351 movlw .113
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1352 subwf lo,W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1353 btfss STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1354 bra tft_compass_cardinal_E
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1355 movlw .158
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1356 subwf lo,W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1357 btfss STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1358 bra tft_compass_cardinal_SE
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1359 movlw .203
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1360 subwf lo,W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1361 btfss STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1362 bra tft_compass_cardinal_S
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1363 movlw .248
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1364 subwf lo,W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1365 btfss STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1366 bra tft_compass_cardinal_SW
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1367 bra tft_compass_cardinal_W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1368
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1369 tft_compass_cardinal2:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1370 movlw .37
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1371 subwf lo,W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1372 btfss STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1373 bra tft_compass_cardinal_W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1374 movlw .82
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1375 subwf lo,W
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1376 btfss STATUS,C
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1377 bra tft_compass_cardinal_NW
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1378 ; bra tft_compass_cardinal_N
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1379 tft_compass_cardinal_N:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1380 STRCAT_TEXT tN
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1381 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1382 tft_compass_cardinal_NE:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1383 STRCAT_TEXT tNE
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1384 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1385 tft_compass_cardinal_E:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1386 STRCAT_TEXT tE
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1387 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1388 tft_compass_cardinal_SE:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1389 STRCAT_TEXT tSE
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1390 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1391 tft_compass_cardinal_S:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1392 STRCAT_TEXT tS
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1393 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1394 tft_compass_cardinal_SW:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1395 STRCAT_TEXT tSW
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1396 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1397 tft_compass_cardinal_W:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1398 STRCAT_TEXT tW
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1399 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1400 tft_compass_cardinal_NW:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1401 STRCAT_TEXT tNW
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1402 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1403
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1404 compass_heading_common:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1405 call speed_normal
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1406 movlw compass_averaging ; numbers of extra averaging
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1407 movwf up
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1408 compass_heading_common2:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1409 rcall TFT_get_compass
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1410 decfsz up,F
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1411 bra compass_heading_common2
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1412 extern compass
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1413 call compass ; Do compass corrections.
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1414 banksel common
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1415
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1416 ; More then compass_fast_treshold?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1417 movff compass_heading_old+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1418 movff compass_heading_old+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1419 movff compass_heading+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1420 movff compass_heading+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1421 call sub16
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1422 btfss neg_flag ; <0?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1423 bra compass_heading_common3 ; No, test for threshold
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1424 ; Yes, subtract the other way round
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1425 movff compass_heading+0,sub_a+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1426 movff compass_heading+1,sub_a+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1427 movff compass_heading_old+0,sub_b+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1428 movff compass_heading_old+1,sub_b+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1429 call sub16
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1430 compass_heading_common3:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1431 movff compass_heading+0,compass_heading_old+0 ; copy new "old"
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1432 movff compass_heading+1,compass_heading_old+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1433
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1434 bcf compass_fast_mode
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1435 movlw compass_fast_treshold
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1436 cpfslt sub_c+0 ; > compass_fast_treshold?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1437 bsf compass_fast_mode ; Yes!
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1438
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1439 btfss compass_fast_mode ; In fast mode?
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1440 return ; No.
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1441 ; Yes.
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1442 movff compass_heading+0,lo
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1443 movff compass_heading+1,hi
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1444 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1445 movff lo,compass_heading_shown+0
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1446 movff hi,compass_heading_shown+1
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1447 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1448
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1449 TFT_get_compass:
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1450 call I2C_RX_compass ; Test Compass
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1451 call I2C_RX_accelerometer ; Test Accelerometer
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1452 call compass_filter ; Filter Raw compass + accel readings.
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1453 banksel common
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1454 return
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 214
diff changeset
1455
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 0
diff changeset
1456
0
heinrichsweikamp
parents:
diff changeset
1457 END