diff options
Diffstat (limited to 'firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c')
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | 70 |
1 files changed, 20 insertions, 50 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c index 036f777340..a2729adacd 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "adc.h" | 30 | #include "adc.h" |
31 | #include "system.h" | 31 | #include "system.h" |
32 | #include "backlight-target.h" | 32 | #include "backlight-target.h" |
33 | #include "lcd-remote-target.h" | ||
33 | #include "uart-target.h" | 34 | #include "uart-target.h" |
34 | #include "tsc2100.h" | 35 | #include "tsc2100.h" |
35 | #include "string.h" | 36 | #include "string.h" |
@@ -125,11 +126,9 @@ inline bool button_hold(void) | |||
125 | 126 | ||
126 | int button_read_device(int *data) | 127 | int button_read_device(int *data) |
127 | { | 128 | { |
128 | char r_buffer[5]; | 129 | int button_read = BUTTON_NONE; |
129 | int r_button = BUTTON_NONE; | 130 | static int button_old = BUTTON_NONE; |
130 | 131 | static bool hold_button_old = false; | |
131 | static int oldbutton = BUTTON_NONE; | ||
132 | static bool oldhold = false; | ||
133 | static long last_touch = 0; | 132 | static long last_touch = 0; |
134 | 133 | ||
135 | *data = 0; | 134 | *data = 0; |
@@ -143,9 +142,9 @@ int button_read_device(int *data) | |||
143 | tsc2100_read_values(&x, &y, &last_z1, &last_z2); | 142 | tsc2100_read_values(&x, &y, &last_z1, &last_z2); |
144 | 143 | ||
145 | *data = touch_to_pixels(x, y); | 144 | *data = touch_to_pixels(x, y); |
146 | r_button |= touchscreen_to_pixels((*data&0xffff0000)>>16, | 145 | button_read |= touchscreen_to_pixels((*data&0xffff0000)>>16, |
147 | *data&0x0000ffff, data); | 146 | *data&0x0000ffff, data); |
148 | oldbutton = r_button; | 147 | button_old = button_read; |
149 | 148 | ||
150 | touch_available = false; | 149 | touch_available = false; |
151 | last_touch=current_tick; | 150 | last_touch=current_tick; |
@@ -154,68 +153,39 @@ int button_read_device(int *data) | |||
154 | { | 153 | { |
155 | /* Touch hasn't happened in a while, clear the bits */ | 154 | /* Touch hasn't happened in a while, clear the bits */ |
156 | if(last_touch+3>current_tick) | 155 | if(last_touch+3>current_tick) |
157 | oldbutton&=(0xFF); | 156 | button_old&=(0xFF); |
158 | } | 157 | } |
159 | 158 | ||
160 | /* Handle power button */ | 159 | /* Handle power button */ |
161 | if ((IO_GIO_BITSET0&0x01) == 0) | 160 | if ((IO_GIO_BITSET0&0x01) == 0) |
162 | { | 161 | { |
163 | r_button |= BUTTON_POWER; | 162 | button_read |= BUTTON_POWER; |
164 | oldbutton=r_button; | 163 | button_old = button_read; |
165 | } | 164 | } |
166 | else | 165 | else |
167 | oldbutton&=~BUTTON_POWER; | 166 | button_old&=~BUTTON_POWER; |
168 | 167 | ||
169 | /* Handle remote buttons */ | 168 | /* Read data from the remote */ |
170 | if(uart1_gets_queue(r_buffer, 5)>=0) | 169 | button_read |= remote_read_device(); |
171 | { | 170 | hold_button=remote_button_hold(); |
172 | int button_location; | 171 | |
173 | 172 | /* Take care of hold notifications */ | |
174 | for(button_location=0;button_location<4;button_location++) | ||
175 | { | ||
176 | if((r_buffer[button_location]&0xF0)==0xF0 | ||
177 | && (r_buffer[button_location+1]&0xF0)!=0xF0) | ||
178 | break; | ||
179 | } | ||
180 | |||
181 | if(button_location==4) | ||
182 | button_location=0; | ||
183 | |||
184 | button_location++; | ||
185 | |||
186 | r_button |= r_buffer[button_location]; | ||
187 | |||
188 | /* Find the hold status location */ | ||
189 | if(button_location==4) | ||
190 | button_location=0; | ||
191 | else | ||
192 | button_location++; | ||
193 | |||
194 | hold_button=((r_buffer[button_location]&0x80)?true:false); | ||
195 | |||
196 | uart1_clear_queue(); | ||
197 | oldbutton=r_button; | ||
198 | } | ||
199 | else | ||
200 | r_button=oldbutton; | ||
201 | |||
202 | /* Take care of hold notices */ | ||
203 | #ifndef BOOTLOADER | 173 | #ifndef BOOTLOADER |
204 | /* give BL notice if HB state chaged */ | 174 | /* give BL notice if HB state chaged */ |
205 | if (hold_button != oldhold) | 175 | if (hold_button != hold_button_old) |
206 | { | 176 | { |
207 | backlight_hold_changed(hold_button); | 177 | backlight_hold_changed(hold_button); |
208 | oldhold=hold_button; | 178 | hold_button_old=hold_button; |
209 | } | 179 | } |
210 | #endif | 180 | #endif |
211 | 181 | ||
212 | if (hold_button) | 182 | if (hold_button) |
213 | { | 183 | { |
214 | r_button=BUTTON_NONE; | 184 | button_read = BUTTON_NONE; |
215 | oldbutton=r_button; | 185 | button_old = button_read; |
216 | } | 186 | } |
217 | 187 | ||
218 | return r_button; | 188 | return button_read; |
219 | } | 189 | } |
220 | 190 | ||
221 | /* Touchscreen data available interupt */ | 191 | /* Touchscreen data available interupt */ |