mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
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:
parent
8ec87106bc
commit
9340af5b25
4 changed files with 78 additions and 54 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -44,4 +44,7 @@ extern bool remote_initialized;
|
|||
|
||||
void lcd_remote_sleep(void);
|
||||
|
||||
int remote_read_device(void);
|
||||
bool remote_button_hold(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue