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
This commit is contained in:
Karl Kurbjun 2009-04-18 06:38:55 +00:00
parent 8ec87106bc
commit 9340af5b25
4 changed files with 78 additions and 54 deletions

View file

@ -30,6 +30,7 @@
#include "adc.h" #include "adc.h"
#include "system.h" #include "system.h"
#include "backlight-target.h" #include "backlight-target.h"
#include "lcd-remote-target.h"
#include "uart-target.h" #include "uart-target.h"
#include "tsc2100.h" #include "tsc2100.h"
#include "string.h" #include "string.h"
@ -125,11 +126,9 @@ inline bool button_hold(void)
int button_read_device(int *data) int button_read_device(int *data)
{ {
char r_buffer[5]; int button_read = BUTTON_NONE;
int r_button = BUTTON_NONE; static int button_old = BUTTON_NONE;
static bool hold_button_old = false;
static int oldbutton = BUTTON_NONE;
static bool oldhold = false;
static long last_touch = 0; static long last_touch = 0;
*data = 0; *data = 0;
@ -143,9 +142,9 @@ int button_read_device(int *data)
tsc2100_read_values(&x, &y, &last_z1, &last_z2); tsc2100_read_values(&x, &y, &last_z1, &last_z2);
*data = touch_to_pixels(x, y); *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); *data&0x0000ffff, data);
oldbutton = r_button; button_old = button_read;
touch_available = false; touch_available = false;
last_touch=current_tick; last_touch=current_tick;
@ -154,68 +153,39 @@ int button_read_device(int *data)
{ {
/* Touch hasn't happened in a while, clear the bits */ /* Touch hasn't happened in a while, clear the bits */
if(last_touch+3>current_tick) if(last_touch+3>current_tick)
oldbutton&=(0xFF); button_old&=(0xFF);
} }
/* Handle power button */ /* Handle power button */
if ((IO_GIO_BITSET0&0x01) == 0) if ((IO_GIO_BITSET0&0x01) == 0)
{ {
r_button |= BUTTON_POWER; button_read |= BUTTON_POWER;
oldbutton=r_button; button_old = button_read;
} }
else else
oldbutton&=~BUTTON_POWER; button_old&=~BUTTON_POWER;
/* Handle remote buttons */ /* Read data from the remote */
if(uart1_gets_queue(r_buffer, 5)>=0) button_read |= remote_read_device();
{ hold_button=remote_button_hold();
int button_location;
for(button_location=0;button_location<4;button_location++) /* Take care of hold notifications */
{
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 */
#ifndef BOOTLOADER #ifndef BOOTLOADER
/* give BL notice if HB state chaged */ /* give BL notice if HB state chaged */
if (hold_button != oldhold) if (hold_button != hold_button_old)
{ {
backlight_hold_changed(hold_button); backlight_hold_changed(hold_button);
oldhold=hold_button; hold_button_old=hold_button;
} }
#endif #endif
if (hold_button) if (hold_button)
{ {
r_button=BUTTON_NONE; button_read = BUTTON_NONE;
oldbutton=r_button; button_old = button_read;
} }
return r_button; return button_read;
} }
/* Touchscreen data available interupt */ /* Touchscreen data available interupt */

View file

@ -250,7 +250,7 @@ void lcd_update_rect(int x, int y, int width, int height)
if (!lcd_on) if (!lcd_on)
return; return;
if ( (width | height) <= 0) if ( (width | height) < 0)
return; /* nothing left to do */ return; /* nothing left to do */
if (x + width > LCD_WIDTH) if (x + width > LCD_WIDTH)

View file

@ -26,6 +26,7 @@
#include "adc.h" #include "adc.h"
#include "scroll_engine.h" #include "scroll_engine.h"
#include "uart-target.h" #include "uart-target.h"
#include "button.h"
static enum remote_control_states static enum remote_control_states
{ {
@ -44,11 +45,13 @@ static enum remote_draw_states
DRAW_PAUSE, DRAW_PAUSE,
} remote_state_draw = DRAW_TOP, remote_state_draw_next; } remote_state_draw = DRAW_TOP, remote_state_draw_next;
static bool remote_hold_button=false;
bool remote_initialized=true; bool remote_initialized=true;
unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING; static unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING;
unsigned char remote_power=0x00; static unsigned char remote_power=0x00;
unsigned char remote_mask=0x00; static unsigned char remote_mask=0x00;
/*** hardware configuration ***/ /*** 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; 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) void _remote_backlight_on(void)
{ {
remote_power|=0x40; remote_power|=0x40;

View file

@ -44,4 +44,7 @@ extern bool remote_initialized;
void lcd_remote_sleep(void); void lcd_remote_sleep(void);
int remote_read_device(void);
bool remote_button_hold(void);
#endif #endif