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