summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2009-04-18 06:38:55 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2009-04-18 06:38:55 +0000
commit9340af5b251551388d2191fc4887839dcd7f5f26 (patch)
tree50b63334b4d3e02873fafcab9514ade2ea561b48
parent8ec87106bca99843ac2f9e8681d07e182eb4e25c (diff)
downloadrockbox-9340af5b251551388d2191fc4887839dcd7f5f26.tar.gz
rockbox-9340af5b251551388d2191fc4887839dcd7f5f26.zip
M:Robe 500: Move all remote specific code into a common file for reuse on other players (M:Robe 100). Include minor fixes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20728 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c70
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c2
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c57
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-target.h3
4 files changed, 78 insertions, 54 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
126int button_read_device(int *data) 127int 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 */
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
index 6caf751b39..ec85821649 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
@@ -250,7 +250,7 @@ void lcd_update_rect(int x, int y, int width, int height)
250 if (!lcd_on) 250 if (!lcd_on)
251 return; 251 return;
252 252
253 if ( (width | height) <= 0) 253 if ( (width | height) < 0)
254 return; /* nothing left to do */ 254 return; /* nothing left to do */
255 255
256 if (x + width > LCD_WIDTH) 256 if (x + width > LCD_WIDTH)
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c
index 0a41b2241f..3ff5d9c2fd 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c
@@ -26,6 +26,7 @@
26#include "adc.h" 26#include "adc.h"
27#include "scroll_engine.h" 27#include "scroll_engine.h"
28#include "uart-target.h" 28#include "uart-target.h"
29#include "button.h"
29 30
30static enum remote_control_states 31static enum remote_control_states
31{ 32{
@@ -44,11 +45,13 @@ static enum remote_draw_states
44 DRAW_PAUSE, 45 DRAW_PAUSE,
45} remote_state_draw = DRAW_TOP, remote_state_draw_next; 46} remote_state_draw = DRAW_TOP, remote_state_draw_next;
46 47
48static bool remote_hold_button=false;
49
47bool remote_initialized=true; 50bool remote_initialized=true;
48 51
49unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING; 52static unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING;
50unsigned char remote_power=0x00; 53static unsigned char remote_power=0x00;
51unsigned char remote_mask=0x00; 54static unsigned char remote_mask=0x00;
52 55
53/*** hardware configuration ***/ 56/*** hardware configuration ***/
54 57
@@ -274,6 +277,54 @@ void lcd_remote_update_rect(int x, int y, int width, int height)
274 remote_state_control=REMOTE_CONTROL_DRAW; 277 remote_state_control=REMOTE_CONTROL_DRAW;
275} 278}
276 279
280bool remote_button_hold(void)
281{
282 return remote_hold_button;
283}
284
285int remote_read_device(void)
286{
287 char read_buffer[5];
288 int read_button = BUTTON_NONE;
289
290 static int oldbutton=BUTTON_NONE;
291
292 /* Handle remote buttons */
293 if(uart1_gets_queue(read_buffer, 5)>=0)
294 {
295 int button_location;
296
297 for(button_location=0;button_location<4;button_location++)
298 {
299 if((read_buffer[button_location]&0xF0)==0xF0
300 && (read_buffer[button_location+1]&0xF0)!=0xF0)
301 break;
302 }
303
304 if(button_location==4)
305 button_location=0;
306
307 button_location++;
308
309 read_button |= read_buffer[button_location];
310
311 /* Find the hold status location */
312 if(button_location==4)
313 button_location=0;
314 else
315 button_location++;
316
317 remote_hold_button=((read_buffer[button_location]&0x80)?true:false);
318
319 uart1_clear_queue();
320 oldbutton=read_button;
321 }
322 else
323 read_button=oldbutton;
324
325 return read_button;
326}
327
277void _remote_backlight_on(void) 328void _remote_backlight_on(void)
278{ 329{
279 remote_power|=0x40; 330 remote_power|=0x40;
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-target.h b/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-target.h
index ee7faeb03b..2c44bf43b4 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-target.h
+++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-target.h
@@ -44,4 +44,7 @@ extern bool remote_initialized;
44 44
45void lcd_remote_sleep(void); 45void lcd_remote_sleep(void);
46 46
47int remote_read_device(void);
48bool remote_button_hold(void);
49
47#endif 50#endif