annotate src/testmode.asm @ 143:be997abd1f73

seperate option table, place in address <0x10000
author heinrichsweikamp
date Sun, 03 Aug 2014 10:28:21 +0200
parents f2201aa374db
children e3ac5b2021bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File tesmode.asm
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Test Mode for Hardware check
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2012-10-31 : [mH] Creation
heinrichsweikamp
parents:
diff changeset
11
heinrichsweikamp
parents:
diff changeset
12 #include "ostc3.inc" ; Mandatory header
heinrichsweikamp
parents:
diff changeset
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
heinrichsweikamp
parents:
diff changeset
14 #include "start.inc"
heinrichsweikamp
parents:
diff changeset
15 #include "tft.inc"
heinrichsweikamp
parents:
diff changeset
16 #include "tft_outputs.inc"
heinrichsweikamp
parents:
diff changeset
17 #include "isr.inc"
heinrichsweikamp
parents:
diff changeset
18 #include "adc_lightsensor.inc"
heinrichsweikamp
parents:
diff changeset
19 #include "strings.inc"
heinrichsweikamp
parents:
diff changeset
20 #include "sleepmode.inc"
heinrichsweikamp
parents:
diff changeset
21 #include "wait.inc" ; speed_*
heinrichsweikamp
parents:
diff changeset
22 #include "mcp.inc" ; RX
heinrichsweikamp
parents:
diff changeset
23 #include "i2c.inc"
heinrichsweikamp
parents:
diff changeset
24 #include "surfmode.inc"
heinrichsweikamp
parents:
diff changeset
25 #include "math.inc"
heinrichsweikamp
parents:
diff changeset
26 #include "eeprom_rs232.inc"
67
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
27 #include "ms5541.inc"
0
heinrichsweikamp
parents:
diff changeset
28
heinrichsweikamp
parents:
diff changeset
29 extern compass
heinrichsweikamp
parents:
diff changeset
30 extern compass_filter
heinrichsweikamp
parents:
diff changeset
31 extern compass_filter_init
heinrichsweikamp
parents:
diff changeset
32 extern compass_reset_calibration
heinrichsweikamp
parents:
diff changeset
33 extern compass_add_calibration
heinrichsweikamp
parents:
diff changeset
34 extern compass_solve_calibration
heinrichsweikamp
parents:
diff changeset
35
heinrichsweikamp
parents:
diff changeset
36 testmode CODE
heinrichsweikamp
parents:
diff changeset
37
heinrichsweikamp
parents:
diff changeset
38 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
39 ; Boot tasks for all modes
heinrichsweikamp
parents:
diff changeset
40 global testloop
67
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
41 testloop: ; Page1
0
heinrichsweikamp
parents:
diff changeset
42 call speed_normal
heinrichsweikamp
parents:
diff changeset
43 bcf no_sensor_int ; Sensor ISR
heinrichsweikamp
parents:
diff changeset
44
heinrichsweikamp
parents:
diff changeset
45 clrf CCP1CON ; stop PWM
heinrichsweikamp
parents:
diff changeset
46 bcf PORTC,2 ; Pull PWM output to GND
heinrichsweikamp
parents:
diff changeset
47 call TFT_boot ; Initialize TFT (includes clear screen)
heinrichsweikamp
parents:
diff changeset
48 call enable_ir ; Enable IR-Port
heinrichsweikamp
parents:
diff changeset
49 WIN_TOP .0
heinrichsweikamp
parents:
diff changeset
50 WIN_LEFT .0
heinrichsweikamp
parents:
diff changeset
51 WIN_FONT FT_SMALL
heinrichsweikamp
parents:
diff changeset
52 WIN_INVERT .0 ; Init new Wordprocessor
heinrichsweikamp
parents:
diff changeset
53 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
54 call TFT_Display_FadeIn
heinrichsweikamp
parents:
diff changeset
55
heinrichsweikamp
parents:
diff changeset
56 call I2C_init_compass
heinrichsweikamp
parents:
diff changeset
57 call I2C_init_accelerometer
heinrichsweikamp
parents:
diff changeset
58
heinrichsweikamp
parents:
diff changeset
59 ; Init compass/accel filtering value.
heinrichsweikamp
parents:
diff changeset
60 call I2C_RX_compass
heinrichsweikamp
parents:
diff changeset
61 call I2C_RX_accelerometer
heinrichsweikamp
parents:
diff changeset
62 call compass_filter_init
heinrichsweikamp
parents:
diff changeset
63
heinrichsweikamp
parents:
diff changeset
64 clrf timeout_counter2
heinrichsweikamp
parents:
diff changeset
65 clrf timeout_counter3
heinrichsweikamp
parents:
diff changeset
66 bcf premenu ; clear premenu flag
heinrichsweikamp
parents:
diff changeset
67 bcf menubit ; clear menu flag
heinrichsweikamp
parents:
diff changeset
68
heinrichsweikamp
parents:
diff changeset
69 bcf switch_left
heinrichsweikamp
parents:
diff changeset
70 bcf switch_right
heinrichsweikamp
parents:
diff changeset
71
heinrichsweikamp
parents:
diff changeset
72 testloop_loop:
heinrichsweikamp
parents:
diff changeset
73 btfss onesecupdate ; do every second tasks?
heinrichsweikamp
parents:
diff changeset
74 bra testloop_loop2 ; no, loop
heinrichsweikamp
parents:
diff changeset
75
heinrichsweikamp
parents:
diff changeset
76 ; One Second tasks
heinrichsweikamp
parents:
diff changeset
77 call speed_normal
heinrichsweikamp
parents:
diff changeset
78 call I2C_RX_compass ; Test Compass
heinrichsweikamp
parents:
diff changeset
79 call I2C_RX_accelerometer ; Test Accelerometer
heinrichsweikamp
parents:
diff changeset
80 call compass_filter ; Filter Raw compass + accel readings.
heinrichsweikamp
parents:
diff changeset
81 banksel common
heinrichsweikamp
parents:
diff changeset
82
heinrichsweikamp
parents:
diff changeset
83 ; Make a second measure and filter, to show faster reactions.
heinrichsweikamp
parents:
diff changeset
84 call I2C_RX_compass ; Test Compass
heinrichsweikamp
parents:
diff changeset
85 call I2C_RX_accelerometer ; Test Accelerometer
heinrichsweikamp
parents:
diff changeset
86 call compass_filter ; Filter Raw compass + accel readings.
heinrichsweikamp
parents:
diff changeset
87 call compass ; Do compass corrections.
heinrichsweikamp
parents:
diff changeset
88 banksel common
heinrichsweikamp
parents:
diff changeset
89
heinrichsweikamp
parents:
diff changeset
90 call TFT_update_raw_data
heinrichsweikamp
parents:
diff changeset
91 movlw .240
heinrichsweikamp
parents:
diff changeset
92 call timeout_testmode ; check timeout
heinrichsweikamp
parents:
diff changeset
93
heinrichsweikamp
parents:
diff changeset
94 bcf onesecupdate ; every second tasks done
heinrichsweikamp
parents:
diff changeset
95
heinrichsweikamp
parents:
diff changeset
96 testloop_loop2:
heinrichsweikamp
parents:
diff changeset
97 ; Tasks approx. every 50ms for all modes
heinrichsweikamp
parents:
diff changeset
98 bcf LEDg
heinrichsweikamp
parents:
diff changeset
99 btfsc vusb_in
heinrichsweikamp
parents:
diff changeset
100 bsf LEDg
heinrichsweikamp
parents:
diff changeset
101
heinrichsweikamp
parents:
diff changeset
102 ; Mode tasks
heinrichsweikamp
parents:
diff changeset
103 extern surfloop
heinrichsweikamp
parents:
diff changeset
104 btfsc switch_left
67
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
105 bra testloop2 ; Page 2
0
heinrichsweikamp
parents:
diff changeset
106
heinrichsweikamp
parents:
diff changeset
107 btfsc switch_right
heinrichsweikamp
parents:
diff changeset
108 goto compass_calibration_loop
heinrichsweikamp
parents:
diff changeset
109
heinrichsweikamp
parents:
diff changeset
110 btfsc sleepmode ; Sleepmode active?
67
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
111 bra testloop2 ; Page 2
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
112
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
113 bra testloop_loop ; loop testmode
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
114
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
115 testloop2: ; Page2
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
116 call speed_normal
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
117 bsf no_sensor_int ; disable sensor interrupt
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
118 call get_calibration_data ; Get calibration data from pressure sensor
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
119 banksel common ; get_calibration_data uses isr_backup
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
120 bcf no_sensor_int ; normal sensor interrupt mode
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
121
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
122 clrf CCP1CON ; stop PWM
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
123 bcf PORTC,2 ; Pull PWM output to GND
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
124 call TFT_boot ; Initialize TFT (includes clear screen)
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
125 WIN_TOP .0
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
126 WIN_LEFT .0
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
127 WIN_FONT FT_SMALL
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
128 WIN_INVERT .0 ; Init new Wordprocessor
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
129 call TFT_standard_color
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
130 call TFT_Display_FadeIn
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
131
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
132 clrf timeout_counter2
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
133 clrf timeout_counter3
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
134 bcf premenu ; clear premenu flag
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
135 bcf menubit ; clear menu flag
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
136
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
137 bcf switch_left
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
138 bcf switch_right
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
139
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
140 testloop2_loop:
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
141 btfss onesecupdate ; do every second tasks?
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
142 bra testloop2_loop2 ; no, loop
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
143
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
144 ; One Second tasks
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
145 call TFT_update_raw_data2
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
146 movlw .240
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
147 call timeout_testmode ; check timeout
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
148
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
149 bcf onesecupdate ; every second tasks done
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
150
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
151 testloop2_loop2:
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
152 ; Tasks approx. every 50ms for all modes
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
153 bcf LEDg
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
154 btfsc vusb_in
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
155 bsf LEDg
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
156
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
157 ; Mode tasks
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
158 btfsc switch_left
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
159 goto surfloop ; Exit
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
160
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
161 btfsc sleepmode ; Sleepmode active?
0
heinrichsweikamp
parents:
diff changeset
162 goto sleeploop ; Yes, switch into sleepmode!
heinrichsweikamp
parents:
diff changeset
163
67
7815bf21d353 second debug mode page
heinrichsweikamp
parents: 50
diff changeset
164 bra testloop2_loop ; loop testmode
0
heinrichsweikamp
parents:
diff changeset
165
heinrichsweikamp
parents:
diff changeset
166
heinrichsweikamp
parents:
diff changeset
167 global compass_calibration_loop
heinrichsweikamp
parents:
diff changeset
168 compass_calibration_loop: ; Compass calibration
heinrichsweikamp
parents:
diff changeset
169 bsf no_sensor_int ; No Sensor ISR
91
917393caf559 minor, always re-init compass in calibration loop
heinrichsweikamp
parents: 90
diff changeset
170 call I2C_sleep_accelerometer ; Stop accelerometer
917393caf559 minor, always re-init compass in calibration loop
heinrichsweikamp
parents: 90
diff changeset
171 call I2C_sleep_compass ; Stop compass
0
heinrichsweikamp
parents:
diff changeset
172 call TFT_ClearScreen
heinrichsweikamp
parents:
diff changeset
173 ; Mask
heinrichsweikamp
parents:
diff changeset
174 WIN_COLOR color_greenish
heinrichsweikamp
parents:
diff changeset
175 WIN_SMALL .16,.0
heinrichsweikamp
parents:
diff changeset
176 STRCPY_TEXT_PRINT tCompassMenu
90
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
177 btfss switch_right2 ; wait until button is released
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
178 bra $-4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
179
0
heinrichsweikamp
parents:
diff changeset
180 call TFT_standard_color
94
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 91
diff changeset
181 ; WIN_SMALL .0,.215
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 91
diff changeset
182 ; STRCPY_TEXT_PRINT tExit
90
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
183 WAITMS d'255'
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
184 WAITMS d'255'
94
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 91
diff changeset
185 movlw .7 ; Gain init
90
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
186 movff WREG,opt_compass_gain
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
187 compass_calibration_gainset: ; Reduce the gain, set bank here!
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
188 banksel opt_compass_gain
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
189 decf opt_compass_gain,F ; Reduce by one
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
190 btfsc STATUS,N ; <0?
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
191 clrf opt_compass_gain ; Yes, keep at zero
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
192
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
193 banksel common
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
194 call I2C_init_accelerometer
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
195 call I2C_init_compass_fast
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
196 call TFT_compass_show_gain ; Show the current compass gain
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
197
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
198 WAITMS d'100'
0
heinrichsweikamp
parents:
diff changeset
199
heinrichsweikamp
parents:
diff changeset
200 clrf timeout_counter2
heinrichsweikamp
parents:
diff changeset
201 clrf timeout_counter3
heinrichsweikamp
parents:
diff changeset
202
heinrichsweikamp
parents:
diff changeset
203 call speed_fastest
heinrichsweikamp
parents:
diff changeset
204 call I2C_RX_compass ; read compass
heinrichsweikamp
parents:
diff changeset
205 call I2C_RX_accelerometer ; read Accelerometer
90
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
206
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
207 ; Test all axes for +4096 (Hi byte=16)
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
208 banksel compass_DX+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
209 movlw .16
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
210 cpfseq compass_DX+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
211 bra $+4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
212 bra compass_calibration_gainset
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
213 cpfseq compass_DY+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
214 bra $+4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
215 bra compass_calibration_gainset
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
216 cpfseq compass_DZ+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
217 bra $+4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
218 bra compass_calibration_gainset
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
219
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
220 ; Test all axes for -4096 (Hi byte=240)
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
221 movlw .240
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
222 cpfseq compass_DX+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
223 bra $+4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
224 bra compass_calibration_gainset
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
225 cpfseq compass_DY+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
226 bra $+4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
227 bra compass_calibration_gainset
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
228 cpfseq compass_DZ+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
229 bra $+4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
230 bra compass_calibration_gainset
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
231 banksel common
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
232
0
heinrichsweikamp
parents:
diff changeset
233 call compass_filter_init ; set DX_f values
heinrichsweikamp
parents:
diff changeset
234 call compass_reset_calibration ; Reset CX_f values
heinrichsweikamp
parents:
diff changeset
235 banksel common
heinrichsweikamp
parents:
diff changeset
236
heinrichsweikamp
parents:
diff changeset
237 compass_calibration_loop2:
heinrichsweikamp
parents:
diff changeset
238 call I2C_RX_compass ; read compass
heinrichsweikamp
parents:
diff changeset
239 call I2C_RX_accelerometer ; Test Accelerometer
heinrichsweikamp
parents:
diff changeset
240 call compass_filter ; Filter compass raw data
heinrichsweikamp
parents:
diff changeset
241 banksel common
heinrichsweikamp
parents:
diff changeset
242
heinrichsweikamp
parents:
diff changeset
243 ; Twice
heinrichsweikamp
parents:
diff changeset
244 call I2C_RX_compass ; read compass
heinrichsweikamp
parents:
diff changeset
245 call I2C_RX_accelerometer ; Test Accelerometer
heinrichsweikamp
parents:
diff changeset
246 call compass_filter ; Filter compass raw data
heinrichsweikamp
parents:
diff changeset
247 banksel common
90
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
248
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
249 ; Test all axes for +4096 (Hi byte=16)
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
250 banksel compass_DX+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
251 movlw .16
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
252 cpfseq compass_DX+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
253 bra $+4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
254 bra compass_calibration_gainset
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
255 cpfseq compass_DY+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
256 bra $+4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
257 bra compass_calibration_gainset
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
258 cpfseq compass_DZ+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
259 bra $+4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
260 bra compass_calibration_gainset
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
261
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
262 ; Test all axes for -4096 (Hi byte=240)
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
263 movlw .240
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
264 cpfseq compass_DX+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
265 bra $+4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
266 bra compass_calibration_gainset
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
267 cpfseq compass_DY+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
268 bra $+4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
269 bra compass_calibration_gainset
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
270 cpfseq compass_DZ+1
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
271 bra $+4
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
272 bra compass_calibration_gainset
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
273 banksel common
0
heinrichsweikamp
parents:
diff changeset
274 ;
heinrichsweikamp
parents:
diff changeset
275 ; ; Three
heinrichsweikamp
parents:
diff changeset
276 ; call I2C_RX_compass ; read compass
heinrichsweikamp
parents:
diff changeset
277 ; call I2C_RX_accelerometer ; Test Accelerometer
heinrichsweikamp
parents:
diff changeset
278 ; call compass_filter ; Filter compass raw data
heinrichsweikamp
parents:
diff changeset
279 ; banksel common
heinrichsweikamp
parents:
diff changeset
280 ;
heinrichsweikamp
parents:
diff changeset
281 ; ; Four times to get cleaner values
heinrichsweikamp
parents:
diff changeset
282 ; call I2C_RX_compass ; read compass
heinrichsweikamp
parents:
diff changeset
283 ; call I2C_RX_accelerometer ; Test Accelerometer
heinrichsweikamp
parents:
diff changeset
284 ; call compass_filter ; Filter compass raw data
heinrichsweikamp
parents:
diff changeset
285
heinrichsweikamp
parents:
diff changeset
286 ; And register only one value out of four:
heinrichsweikamp
parents:
diff changeset
287 call compass_add_calibration ; check and store new max/min values
heinrichsweikamp
parents:
diff changeset
288 banksel common
heinrichsweikamp
parents:
diff changeset
289
heinrichsweikamp
parents:
diff changeset
290 call TFT_compass_fast ; show values
heinrichsweikamp
parents:
diff changeset
291
heinrichsweikamp
parents:
diff changeset
292 btfsc sleepmode ; Sleepmode active?
heinrichsweikamp
parents:
diff changeset
293 bra compass_calibration_exit ; Yes, exit
heinrichsweikamp
parents:
diff changeset
294
94
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 91
diff changeset
295 ; btfsc switch_left ; Button pressed?
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 91
diff changeset
296 ; bra compass_calibration_exit ; Yes, exit
0
heinrichsweikamp
parents:
diff changeset
297
heinrichsweikamp
parents:
diff changeset
298 btfss onesecupdate ; do every second tasks?
heinrichsweikamp
parents:
diff changeset
299 bra compass_calibration_loop2 ; no, loop here
heinrichsweikamp
parents:
diff changeset
300
94
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 91
diff changeset
301 movlw .60
0
heinrichsweikamp
parents:
diff changeset
302 call timeout_testmode ; check timeout
94
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 91
diff changeset
303 movlw .60
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 91
diff changeset
304 call TFT_show_timeout_testmode ; Show the timeout
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 91
diff changeset
305
0
heinrichsweikamp
parents:
diff changeset
306 bcf onesecupdate ; clear flag
heinrichsweikamp
parents:
diff changeset
307
heinrichsweikamp
parents:
diff changeset
308 bra compass_calibration_loop2 ; loop here
heinrichsweikamp
parents:
diff changeset
309
heinrichsweikamp
parents:
diff changeset
310 compass_calibration_exit:
heinrichsweikamp
parents:
diff changeset
311 call compass_solve_calibration
heinrichsweikamp
parents:
diff changeset
312 banksel common
heinrichsweikamp
parents:
diff changeset
313 extern option_save_all
heinrichsweikamp
parents:
diff changeset
314 call option_save_all ; save all settings into EEPROM
heinrichsweikamp
parents:
diff changeset
315 bcf sleepmode ; Clear the flag before exiting to surfacemode
heinrichsweikamp
parents:
diff changeset
316 movlw .6
90
3274e87fd027 NEW: automatic compass gain makes calibration quicker
heinrichsweikamp
parents: 67
diff changeset
317 movwf customview_surfmode ; Set to compass view...
0
heinrichsweikamp
parents:
diff changeset
318 goto surfloop ; ...and exit
heinrichsweikamp
parents:
diff changeset
319
heinrichsweikamp
parents:
diff changeset
320 END