Mercurial > public > hwos_code
comparison src/compass_ops.asm @ 428:eccae727702f
some cleanup
author | heinrichsweikamp |
---|---|
date | Wed, 15 Jun 2016 12:26:48 +0200 |
parents | 3c55627d5f8f |
children | 4b93354b7738 |
comparison
equal
deleted
inserted
replaced
427:ceb1b7329dce | 428:eccae727702f |
---|---|
196 call TFT_ClearScreen | 196 call TFT_ClearScreen |
197 ; Mask | 197 ; Mask |
198 WIN_COLOR color_greenish | 198 WIN_COLOR color_greenish |
199 WIN_SMALL .16,.0 | 199 WIN_SMALL .16,.0 |
200 STRCPY_TEXT_PRINT tCompassMenu | 200 STRCPY_TEXT_PRINT tCompassMenu |
201 | 201 btfss switch_right2 ; wait until button is released |
202 call menu_processor_bottom_line | |
203 btfss switch_right2 ; wait until right button is released | |
204 bra $-4 | 202 bra $-4 |
205 | 203 |
206 call TFT_standard_color | 204 call TFT_standard_color |
207 ; WIN_SMALL .0,.215 | 205 ; WIN_SMALL .0,.215 |
208 ; STRCPY_TEXT_PRINT tExit | 206 ; STRCPY_TEXT_PRINT tExit |
209 WAITMS d'255' | 207 WAITMS d'255' |
210 WAITMS d'255' | 208 WAITMS d'255' |
209 | |
211 movlw .7 ; Gain init | 210 movlw .7 ; Gain init |
212 movff WREG,opt_compass_gain | 211 movff WREG,opt_compass_gain |
213 compass_calibration_gainset: ; Reduce the gain, set bank here! | 212 compass_calibration_gainset: ; Reduce the gain, set bank here! |
214 banksel opt_compass_gain | 213 banksel opt_compass_gain |
215 decf opt_compass_gain,F ; Reduce by one | 214 decf opt_compass_gain,F ; Reduce by one |
217 clrf opt_compass_gain ; Yes, keep at zero | 216 clrf opt_compass_gain ; Yes, keep at zero |
218 | 217 |
219 banksel common | 218 banksel common |
220 call I2C_init_accelerometer | 219 call I2C_init_accelerometer |
221 call I2C_init_compass_fast | 220 call I2C_init_compass_fast |
222 rcall TFT_compass_show_gain ; Show the current compass gain | 221 |
222 btfsc compass_type ; compass1? | |
223 bra compass_calibration_loop1 ; Yes, skip gain stuff | |
224 | |
225 ; rcall TFT_compass_show_gain ; Show the current compass gain | |
223 | 226 |
224 WAITMS d'100' | 227 WAITMS d'100' |
225 | 228 |
226 clrf timeout_counter2 | 229 clrf timeout_counter2 |
227 clrf timeout_counter3 | 230 clrf timeout_counter3 |
254 cpfseq compass_DZ+1 | 257 cpfseq compass_DZ+1 |
255 bra $+4 | 258 bra $+4 |
256 bra compass_calibration_gainset | 259 bra compass_calibration_gainset |
257 banksel common | 260 banksel common |
258 | 261 |
262 compass_calibration_loop1: ; Done with Gain | |
259 rcall compass_filter_init ; set DX_f values | 263 rcall compass_filter_init ; set DX_f values |
260 call compass_reset_calibration ; Reset CX_f values | 264 call compass_reset_calibration ; Reset CX_f values |
261 banksel common | 265 banksel common |
262 | 266 |
263 compass_calibration_loop2: | 267 compass_calibration_loop2: |
269 ; Twice | 273 ; Twice |
270 call I2C_RX_compass ; read compass | 274 call I2C_RX_compass ; read compass |
271 call I2C_RX_accelerometer ; Test Accelerometer | 275 call I2C_RX_accelerometer ; Test Accelerometer |
272 rcall compass_filter ; Filter compass raw data | 276 rcall compass_filter ; Filter compass raw data |
273 banksel common | 277 banksel common |
278 | |
279 btfsc compass_type ; compass1? | |
280 bra compass_calibration_loop3 ; Yes, skip gain stuff | |
274 | 281 |
275 ; Test all axes for +4096 (Hi byte=16) | 282 ; Test all axes for +4096 (Hi byte=16) |
276 banksel compass_DX+1 | 283 banksel compass_DX+1 |
277 movlw .16 | 284 movlw .16 |
278 cpfseq compass_DX+1 | 285 cpfseq compass_DX+1 |
307 ; ; Four times to get cleaner values | 314 ; ; Four times to get cleaner values |
308 ; call I2C_RX_compass ; read compass | 315 ; call I2C_RX_compass ; read compass |
309 ; call I2C_RX_accelerometer ; Test Accelerometer | 316 ; call I2C_RX_accelerometer ; Test Accelerometer |
310 ; call compass_filter ; Filter compass raw data | 317 ; call compass_filter ; Filter compass raw data |
311 | 318 |
319 compass_calibration_loop3: | |
312 ; And register only one value out of four: | 320 ; And register only one value out of four: |
313 call compass_add_calibration ; check and store new max/min values | 321 call compass_add_calibration ; check and store new max/min values |
314 banksel common | 322 banksel common |
315 | 323 |
316 call TFT_compass_fast ; show values | 324 call TFT_compass_fast ; show values |