annotate src/testmode.asm @ 14:440e537e19d6

Show "MOD:" instead of "EAD:" in gas setup
author heinrichsweikamp
date Tue, 11 Jun 2013 09:42:59 +0200
parents 11d4fc797f74
children ec4d8503ec45
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"
heinrichsweikamp
parents:
diff changeset
27
heinrichsweikamp
parents:
diff changeset
28 extern compass
heinrichsweikamp
parents:
diff changeset
29 extern compass_filter
heinrichsweikamp
parents:
diff changeset
30 extern compass_filter_init
heinrichsweikamp
parents:
diff changeset
31 extern compass_reset_calibration
heinrichsweikamp
parents:
diff changeset
32 extern compass_add_calibration
heinrichsweikamp
parents:
diff changeset
33 extern compass_solve_calibration
heinrichsweikamp
parents:
diff changeset
34
heinrichsweikamp
parents:
diff changeset
35 testmode CODE
heinrichsweikamp
parents:
diff changeset
36
heinrichsweikamp
parents:
diff changeset
37 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
38 ; Boot tasks for all modes
heinrichsweikamp
parents:
diff changeset
39 global testloop
heinrichsweikamp
parents:
diff changeset
40 testloop:
heinrichsweikamp
parents:
diff changeset
41 call speed_normal
heinrichsweikamp
parents:
diff changeset
42 bcf no_sensor_int ; Sensor ISR
heinrichsweikamp
parents:
diff changeset
43
heinrichsweikamp
parents:
diff changeset
44 clrf CCP1CON ; stop PWM
heinrichsweikamp
parents:
diff changeset
45 bcf PORTC,2 ; Pull PWM output to GND
heinrichsweikamp
parents:
diff changeset
46 call TFT_boot ; Initialize TFT (includes clear screen)
heinrichsweikamp
parents:
diff changeset
47 call enable_ir ; Enable IR-Port
heinrichsweikamp
parents:
diff changeset
48 WIN_TOP .0
heinrichsweikamp
parents:
diff changeset
49 WIN_LEFT .0
heinrichsweikamp
parents:
diff changeset
50 WIN_FONT FT_SMALL
heinrichsweikamp
parents:
diff changeset
51 WIN_INVERT .0 ; Init new Wordprocessor
heinrichsweikamp
parents:
diff changeset
52 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
53 call mcp_reset_rssi ; Setup RX
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
heinrichsweikamp
parents:
diff changeset
105 goto surfloop ; Exit
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?
heinrichsweikamp
parents:
diff changeset
111 goto sleeploop ; Yes, switch into sleepmode!
heinrichsweikamp
parents:
diff changeset
112
heinrichsweikamp
parents:
diff changeset
113 bra testloop_loop ; loop testmode
heinrichsweikamp
parents:
diff changeset
114
heinrichsweikamp
parents:
diff changeset
115
heinrichsweikamp
parents:
diff changeset
116 global compass_calibration_loop
heinrichsweikamp
parents:
diff changeset
117 compass_calibration_loop: ; Compass calibration
heinrichsweikamp
parents:
diff changeset
118 bsf no_sensor_int ; No Sensor ISR
heinrichsweikamp
parents:
diff changeset
119 call I2C_init_accelerometer
heinrichsweikamp
parents:
diff changeset
120 call I2C_init_compass_fast
heinrichsweikamp
parents:
diff changeset
121 call TFT_ClearScreen
heinrichsweikamp
parents:
diff changeset
122
heinrichsweikamp
parents:
diff changeset
123 ; Mask
heinrichsweikamp
parents:
diff changeset
124 WIN_COLOR color_greenish
heinrichsweikamp
parents:
diff changeset
125 WIN_SMALL .16,.0
heinrichsweikamp
parents:
diff changeset
126 STRCPY_TEXT_PRINT tCompassMenu
heinrichsweikamp
parents:
diff changeset
127 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
128 WIN_SMALL .0,.215
heinrichsweikamp
parents:
diff changeset
129 STRCPY_TEXT_PRINT tExit
heinrichsweikamp
parents:
diff changeset
130
heinrichsweikamp
parents:
diff changeset
131 clrf timeout_counter2
heinrichsweikamp
parents:
diff changeset
132 clrf timeout_counter3
heinrichsweikamp
parents:
diff changeset
133
heinrichsweikamp
parents:
diff changeset
134 call speed_fastest
heinrichsweikamp
parents:
diff changeset
135 call I2C_RX_compass ; read compass
heinrichsweikamp
parents:
diff changeset
136 call I2C_RX_accelerometer ; read Accelerometer
heinrichsweikamp
parents:
diff changeset
137 call compass_filter_init ; set DX_f values
heinrichsweikamp
parents:
diff changeset
138 call compass_reset_calibration ; Reset CX_f values
heinrichsweikamp
parents:
diff changeset
139 banksel common
heinrichsweikamp
parents:
diff changeset
140
heinrichsweikamp
parents:
diff changeset
141 compass_calibration_loop2:
heinrichsweikamp
parents:
diff changeset
142 call I2C_RX_compass ; read compass
heinrichsweikamp
parents:
diff changeset
143 call I2C_RX_accelerometer ; Test Accelerometer
heinrichsweikamp
parents:
diff changeset
144 call compass_filter ; Filter compass raw data
heinrichsweikamp
parents:
diff changeset
145 banksel common
heinrichsweikamp
parents:
diff changeset
146
heinrichsweikamp
parents:
diff changeset
147 ; Twice
heinrichsweikamp
parents:
diff changeset
148 call I2C_RX_compass ; read compass
heinrichsweikamp
parents:
diff changeset
149 call I2C_RX_accelerometer ; Test Accelerometer
heinrichsweikamp
parents:
diff changeset
150 call compass_filter ; Filter compass raw data
heinrichsweikamp
parents:
diff changeset
151 banksel common
heinrichsweikamp
parents:
diff changeset
152 ;
heinrichsweikamp
parents:
diff changeset
153 ; ; Three
heinrichsweikamp
parents:
diff changeset
154 ; call I2C_RX_compass ; read compass
heinrichsweikamp
parents:
diff changeset
155 ; call I2C_RX_accelerometer ; Test Accelerometer
heinrichsweikamp
parents:
diff changeset
156 ; call compass_filter ; Filter compass raw data
heinrichsweikamp
parents:
diff changeset
157 ; banksel common
heinrichsweikamp
parents:
diff changeset
158 ;
heinrichsweikamp
parents:
diff changeset
159 ; ; Four times to get cleaner values
heinrichsweikamp
parents:
diff changeset
160 ; call I2C_RX_compass ; read compass
heinrichsweikamp
parents:
diff changeset
161 ; call I2C_RX_accelerometer ; Test Accelerometer
heinrichsweikamp
parents:
diff changeset
162 ; call compass_filter ; Filter compass raw data
heinrichsweikamp
parents:
diff changeset
163
heinrichsweikamp
parents:
diff changeset
164 ; And register only one value out of four:
heinrichsweikamp
parents:
diff changeset
165 call compass_add_calibration ; check and store new max/min values
heinrichsweikamp
parents:
diff changeset
166 banksel common
heinrichsweikamp
parents:
diff changeset
167
heinrichsweikamp
parents:
diff changeset
168 call TFT_compass_fast ; show values
heinrichsweikamp
parents:
diff changeset
169 ; btg LEDg ; Show read-out interval
heinrichsweikamp
parents:
diff changeset
170
heinrichsweikamp
parents:
diff changeset
171 btfsc sleepmode ; Sleepmode active?
heinrichsweikamp
parents:
diff changeset
172 bra compass_calibration_exit ; Yes, exit
heinrichsweikamp
parents:
diff changeset
173
heinrichsweikamp
parents:
diff changeset
174 btfsc switch_left ; Button pressed?
heinrichsweikamp
parents:
diff changeset
175 bra compass_calibration_exit ; Yes, exit
heinrichsweikamp
parents:
diff changeset
176
heinrichsweikamp
parents:
diff changeset
177 btfss onesecupdate ; do every second tasks?
heinrichsweikamp
parents:
diff changeset
178 bra compass_calibration_loop2 ; no, loop here
heinrichsweikamp
parents:
diff changeset
179
heinrichsweikamp
parents:
diff changeset
180 movlw .240
heinrichsweikamp
parents:
diff changeset
181 call timeout_testmode ; check timeout
heinrichsweikamp
parents:
diff changeset
182 bcf onesecupdate ; clear flag
heinrichsweikamp
parents:
diff changeset
183
heinrichsweikamp
parents:
diff changeset
184 bra compass_calibration_loop2 ; loop here
heinrichsweikamp
parents:
diff changeset
185
heinrichsweikamp
parents:
diff changeset
186 compass_calibration_exit:
heinrichsweikamp
parents:
diff changeset
187 call compass_solve_calibration
heinrichsweikamp
parents:
diff changeset
188 banksel common
heinrichsweikamp
parents:
diff changeset
189 extern option_save_all
heinrichsweikamp
parents:
diff changeset
190 call option_save_all ; save all settings into EEPROM
heinrichsweikamp
parents:
diff changeset
191 bcf sleepmode ; Clear the flag before exiting to surfacemode
heinrichsweikamp
parents:
diff changeset
192 movlw .6
heinrichsweikamp
parents:
diff changeset
193 movwf menupos3 ; Set to compass view...
heinrichsweikamp
parents:
diff changeset
194 goto surfloop ; ...and exit
heinrichsweikamp
parents:
diff changeset
195
heinrichsweikamp
parents:
diff changeset
196 END