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.zip
rockbox-9340af5b251551388d2191fc4887839dcd7f5f26.tar.gz
rockbox-9340af5b251551388d2191fc4887839dcd7f5f26.tar.bz2
rockbox-9340af5b251551388d2191fc4887839dcd7f5f26.tar.xz
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 036f777..a2729ad 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 @@
#include "adc.h"
#include "system.h"
#include "backlight-target.h"
+#include "lcd-remote-target.h"
#include "uart-target.h"
#include "tsc2100.h"
#include "string.h"
@@ -125,11 +126,9 @@ inline bool button_hold(void)
int button_read_device(int *data)
{
- char r_buffer[5];
- int r_button = BUTTON_NONE;
-
- static int oldbutton = BUTTON_NONE;
- static bool oldhold = false;
+ int button_read = BUTTON_NONE;
+ static int button_old = BUTTON_NONE;
+ static bool hold_button_old = false;
static long last_touch = 0;
*data = 0;
@@ -143,9 +142,9 @@ int button_read_device(int *data)
tsc2100_read_values(&x, &y, &last_z1, &last_z2);
*data = touch_to_pixels(x, y);
- r_button |= touchscreen_to_pixels((*data&0xffff0000)>>16,
+ button_read |= touchscreen_to_pixels((*data&0xffff0000)>>16,
*data&0x0000ffff, data);
- oldbutton = r_button;
+ button_old = button_read;
touch_available = false;
last_touch=current_tick;
@@ -154,68 +153,39 @@ int button_read_device(int *data)
{
/* Touch hasn't happened in a while, clear the bits */
if(last_touch+3>current_tick)
- oldbutton&=(0xFF);
+ button_old&=(0xFF);
}
/* Handle power button */
if ((IO_GIO_BITSET0&0x01) == 0)
{
- r_button |= BUTTON_POWER;
- oldbutton=r_button;
+ button_read |= BUTTON_POWER;
+ button_old = button_read;
}
else
- oldbutton&=~BUTTON_POWER;
+ button_old&=~BUTTON_POWER;
- /* Handle remote buttons */
- if(uart1_gets_queue(r_buffer, 5)>=0)
- {
- int button_location;
-
- for(button_location=0;button_location<4;button_location++)
- {
- if((r_buffer[button_location]&0xF0)==0xF0
- && (r_buffer[button_location+1]&0xF0)!=0xF0)
- break;
- }
-
- if(button_location==4)
- button_location=0;
-
- button_location++;
-
- r_button |= r_buffer[button_location];
-
- /* Find the hold status location */
- if(button_location==4)
- button_location=0;
- else
- button_location++;
-
- hold_button=((r_buffer[button_location]&0x80)?true:false);
-
- uart1_clear_queue();
- oldbutton=r_button;
- }
- else
- r_button=oldbutton;
-
- /* Take care of hold notices */
+ /* Read data from the remote */
+ button_read |= remote_read_device();
+ hold_button=remote_button_hold();
+
+ /* Take care of hold notifications */
#ifndef BOOTLOADER
/* give BL notice if HB state chaged */
- if (hold_button != oldhold)
+ if (hold_button != hold_button_old)
{
backlight_hold_changed(hold_button);
- oldhold=hold_button;
+ hold_button_old=hold_button;
}
#endif
if (hold_button)
{
- r_button=BUTTON_NONE;
- oldbutton=r_button;
+ button_read = BUTTON_NONE;
+ button_old = button_read;
}
- return r_button;
+ return button_read;
}
/* 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 6caf751..ec85821 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)
if (!lcd_on)
return;
- if ( (width | height) <= 0)
+ if ( (width | height) < 0)
return; /* nothing left to do */
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 0a41b22..3ff5d9c 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 @@
#include "adc.h"
#include "scroll_engine.h"
#include "uart-target.h"
+#include "button.h"
static enum remote_control_states
{
@@ -44,11 +45,13 @@ static enum remote_draw_states
DRAW_PAUSE,
} remote_state_draw = DRAW_TOP, remote_state_draw_next;
+static bool remote_hold_button=false;
+
bool remote_initialized=true;
-unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING;
-unsigned char remote_power=0x00;
-unsigned char remote_mask=0x00;
+static unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING;
+static unsigned char remote_power=0x00;
+static unsigned char remote_mask=0x00;
/*** hardware configuration ***/
@@ -274,6 +277,54 @@ void lcd_remote_update_rect(int x, int y, int width, int height)
remote_state_control=REMOTE_CONTROL_DRAW;
}
+bool remote_button_hold(void)
+{
+ return remote_hold_button;
+}
+
+int remote_read_device(void)
+{
+ char read_buffer[5];
+ int read_button = BUTTON_NONE;
+
+ static int oldbutton=BUTTON_NONE;
+
+ /* Handle remote buttons */
+ if(uart1_gets_queue(read_buffer, 5)>=0)
+ {
+ int button_location;
+
+ for(button_location=0;button_location<4;button_location++)
+ {
+ if((read_buffer[button_location]&0xF0)==0xF0
+ && (read_buffer[button_location+1]&0xF0)!=0xF0)
+ break;
+ }
+
+ if(button_location==4)
+ button_location=0;
+
+ button_location++;
+
+ read_button |= read_buffer[button_location];
+
+ /* Find the hold status location */
+ if(button_location==4)
+ button_location=0;
+ else
+ button_location++;
+
+ remote_hold_button=((read_buffer[button_location]&0x80)?true:false);
+
+ uart1_clear_queue();
+ oldbutton=read_button;
+ }
+ else
+ read_button=oldbutton;
+
+ return read_button;
+}
+
void _remote_backlight_on(void)
{
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 ee7faeb..2c44bf4 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;
void lcd_remote_sleep(void);
+int remote_read_device(void);
+bool remote_button_hold(void);
+
#endif