annotate src/compass_ops.asm @ 585:00ad4ffd915b

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