Work in progress fixes to the remote button handling. Now the remote can be unplugged and then plugged in and it will work.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15628 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
d1c6d53962
commit
d3d0b26421
6 changed files with 84 additions and 60 deletions
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
/* choose the lcd orientation. both work */
|
/* choose the lcd orientation. both work */
|
||||||
/* #define CONFIG_ORIENTATION SCREEN_PORTAIT */
|
/* #define CONFIG_ORIENTATION SCREEN_PORTAIT */
|
||||||
#define CONFIG_ORIENTATION SCREEN_LANDSCAPE
|
#define CONFIG_ORIENTATION SCREEN_LANDSCAPE
|
||||||
|
|
||||||
#if CONFIG_ORIENTATION == SCREEN_PORTAIT
|
#if CONFIG_ORIENTATION == SCREEN_PORTAIT
|
||||||
#define LCD_WIDTH 480
|
#define LCD_WIDTH 480
|
||||||
|
|
|
@ -161,7 +161,7 @@ void rolo_restart(const unsigned char* source, unsigned char* dest,
|
||||||
/* Wait for the COP to tell us it is rebooting */
|
/* Wait for the COP to tell us it is rebooting */
|
||||||
while(cpu_reply != 2);
|
while(cpu_reply != 2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"mov r0, #0x10000000 \n"
|
"mov r0, #0x10000000 \n"
|
||||||
"mov pc, r0 \n"
|
"mov pc, r0 \n"
|
||||||
|
|
|
@ -33,20 +33,22 @@ bool __dbg_ports(void)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern char r_buffer[5];
|
||||||
|
extern int r_button;
|
||||||
bool __dbg_hw_info(void)
|
bool __dbg_hw_info(void)
|
||||||
{
|
{
|
||||||
int line = 0, button, oldline;
|
int line = 0, button, oldline;
|
||||||
int *address=0x0;
|
int *address=0x0;
|
||||||
bool done=false;
|
bool done=false;
|
||||||
char buf[100];
|
char buf[100];
|
||||||
|
|
||||||
lcd_setmargins(0, 0);
|
lcd_setmargins(0, 0);
|
||||||
lcd_setfont(FONT_SYSFIXED);
|
lcd_setfont(FONT_SYSFIXED);
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
|
|
||||||
/* Put all the static text befor the while loop */
|
/* Put all the static text befor the while loop */
|
||||||
lcd_puts(0, line++, "[Hardware info]");
|
lcd_puts(0, line++, "[Hardware info]");
|
||||||
|
|
||||||
lcd_puts(0, line++, "Clock info:");
|
lcd_puts(0, line++, "Clock info:");
|
||||||
snprintf(buf, sizeof(buf), "IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x",
|
snprintf(buf, sizeof(buf), "IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x",
|
||||||
IO_CLK_PLLA, IO_CLK_PLLB, IO_CLK_SEL0, IO_CLK_SEL1); lcd_puts(0, line++, buf);
|
IO_CLK_PLLA, IO_CLK_PLLB, IO_CLK_SEL0, IO_CLK_SEL1); lcd_puts(0, line++, buf);
|
||||||
|
@ -75,6 +77,10 @@ bool __dbg_hw_info(void)
|
||||||
else if (button==BUTTON_RC_REW)
|
else if (button==BUTTON_RC_REW)
|
||||||
address-=0x800;
|
address-=0x800;
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "Buffer: 0x%02x%02x%02x%02x%02x",
|
||||||
|
r_buffer[0], r_buffer[1], r_buffer[2], r_buffer[3],r_buffer[4] ); lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "Button: 0x%08x, HWread: 0x%08x",
|
||||||
|
(unsigned int)button, r_button); lcd_puts(0, line++, buf);
|
||||||
snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d",
|
snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d",
|
||||||
(unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf);
|
(unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf);
|
||||||
snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x",
|
snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x",
|
||||||
|
|
|
@ -41,11 +41,7 @@ static short last_x, last_y, last_z1, last_z2; /* for the touch screen */
|
||||||
static bool touch_available = false;
|
static bool touch_available = false;
|
||||||
|
|
||||||
static struct touch_calibration_point topleft, bottomright;
|
static struct touch_calibration_point topleft, bottomright;
|
||||||
static bool using_calibration = false;
|
|
||||||
void use_calibration(bool enable)
|
|
||||||
{
|
|
||||||
using_calibration = enable;
|
|
||||||
}
|
|
||||||
/* Jd's tests.. These will hopefully work for everyone so we dont have to
|
/* Jd's tests.. These will hopefully work for everyone so we dont have to
|
||||||
* create a calibration screen.
|
* create a calibration screen.
|
||||||
* Portait:
|
* Portait:
|
||||||
|
@ -55,12 +51,6 @@ void use_calibration(bool enable)
|
||||||
* (0,0) = 200, 270
|
* (0,0) = 200, 270
|
||||||
* (640,480) = 3880, 3900
|
* (640,480) = 3880, 3900
|
||||||
*/
|
*/
|
||||||
void set_calibration_points(struct touch_calibration_point *tl,
|
|
||||||
struct touch_calibration_point *br)
|
|
||||||
{
|
|
||||||
memcpy(&topleft, tl, sizeof(struct touch_calibration_point));
|
|
||||||
memcpy(&bottomright, br, sizeof(struct touch_calibration_point));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int touch_to_pixels(short val_x, short val_y)
|
static int touch_to_pixels(short val_x, short val_y)
|
||||||
{
|
{
|
||||||
|
@ -74,16 +64,20 @@ static int touch_to_pixels(short val_x, short val_y)
|
||||||
y=val_x;
|
y=val_x;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!using_calibration)
|
|
||||||
return (val_x<<16)|val_y;
|
|
||||||
|
|
||||||
x = (x-topleft.val_x)*(bottomright.px_x - topleft.px_x) / (bottomright.val_x - topleft.val_x) + topleft.px_x;
|
x = (x-topleft.val_x)*(bottomright.px_x - topleft.px_x) / (bottomright.val_x - topleft.val_x) + topleft.px_x;
|
||||||
y = (y-topleft.val_y)*(bottomright.px_y - topleft.px_y) / (bottomright.val_y - topleft.val_y) + topleft.px_y;
|
y = (y-topleft.val_y)*(bottomright.px_y - topleft.px_y) / (bottomright.val_y - topleft.val_y) + topleft.px_y;
|
||||||
|
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
x = 0;
|
x = 0;
|
||||||
|
else if (x>=LCD_WIDTH)
|
||||||
|
x=LCD_WIDTH-1;
|
||||||
|
|
||||||
if (y < 0)
|
if (y < 0)
|
||||||
y = 0;
|
y = 0;
|
||||||
|
else if (y>=LCD_HEIGHT)
|
||||||
|
y=LCD_HEIGHT-1;
|
||||||
|
|
||||||
|
|
||||||
return (x<<16)|y;
|
return (x<<16)|y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,14 +101,12 @@ void button_init_device(void)
|
||||||
bottomright.val_y = 3880;
|
bottomright.val_y = 3880;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
topleft.px_x = 0;
|
topleft.px_x = 0;
|
||||||
topleft.px_y = 0;
|
topleft.px_y = 0;
|
||||||
|
|
||||||
bottomright.px_x = LCD_WIDTH;
|
bottomright.px_x = LCD_WIDTH;
|
||||||
bottomright.px_y = LCD_HEIGHT;
|
bottomright.px_y = LCD_HEIGHT;
|
||||||
|
|
||||||
using_calibration = true;
|
|
||||||
|
|
||||||
/* Enable the touchscreen interrupt */
|
/* Enable the touchscreen interrupt */
|
||||||
IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */
|
IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -136,15 +128,18 @@ inline bool button_hold(void)
|
||||||
static void remote_heartbeat(void)
|
static void remote_heartbeat(void)
|
||||||
{
|
{
|
||||||
char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'};
|
char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'};
|
||||||
uart1_puts(data);
|
uart1_puts(data, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TOUCH_MARGIN 8
|
#define TOUCH_MARGIN 8
|
||||||
|
char r_buffer[5];
|
||||||
|
int r_button = BUTTON_NONE;
|
||||||
int button_read_device(int *data)
|
int button_read_device(int *data)
|
||||||
{
|
{
|
||||||
char buffer[5];
|
int retval, calbuf;
|
||||||
int button = BUTTON_NONE, retval;
|
|
||||||
static int oldbutton = BUTTON_NONE;
|
static int oldbutton = BUTTON_NONE;
|
||||||
|
|
||||||
|
r_button=BUTTON_NONE;
|
||||||
*data = 0;
|
*data = 0;
|
||||||
|
|
||||||
if (touch_available)
|
if (touch_available)
|
||||||
|
@ -170,7 +165,7 @@ int button_read_device(int *data)
|
||||||
last_x = x;
|
last_x = x;
|
||||||
last_y = y;
|
last_y = y;
|
||||||
*data = touch_to_pixels(x, y);
|
*data = touch_to_pixels(x, y);
|
||||||
button |= BUTTON_TOUCHPAD;
|
r_button |= BUTTON_TOUCHPAD;
|
||||||
}
|
}
|
||||||
last_touch = current_tick;
|
last_touch = current_tick;
|
||||||
touch_available = false;
|
touch_available = false;
|
||||||
|
@ -178,23 +173,34 @@ int button_read_device(int *data)
|
||||||
remote_heartbeat();
|
remote_heartbeat();
|
||||||
|
|
||||||
if ((IO_GIO_BITSET0&0x01) == 0)
|
if ((IO_GIO_BITSET0&0x01) == 0)
|
||||||
button |= BUTTON_POWER;
|
{
|
||||||
|
r_button |= BUTTON_POWER;
|
||||||
|
oldbutton=r_button;
|
||||||
|
}
|
||||||
|
|
||||||
retval=uart1_gets_queue(buffer, 5);
|
retval=uart1_gets_queue(r_buffer, 5);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
for(calbuf=0;calbuf<4;calbuf++)
|
||||||
|
{
|
||||||
|
if((r_buffer[calbuf]&0xF0)==0xF0 && (r_buffer[calbuf+1]&0xF0)!=0xF0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
calbuf++;
|
||||||
|
if(calbuf==5)
|
||||||
|
calbuf=0;
|
||||||
if(retval>=0)
|
if(retval>=0)
|
||||||
{
|
{
|
||||||
button |= buffer[1];
|
r_button |= r_buffer[calbuf];
|
||||||
oldbutton=button;
|
oldbutton=r_button;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
button=oldbutton;
|
r_button=oldbutton;
|
||||||
}
|
}
|
||||||
} while((retval=uart1_gets_queue(buffer, 5))>=5);
|
} while((retval=uart1_gets_queue(r_buffer, 5))>=5);
|
||||||
|
|
||||||
return button;
|
return r_button;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Touchpad data available interupt */
|
/* Touchpad data available interupt */
|
||||||
|
|
|
@ -62,39 +62,53 @@ void uart1_putc(char ch)
|
||||||
IO_UART1_DTRR=ch;
|
IO_UART1_DTRR=ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uart1_puts(const char *str)
|
void uart1_puts(const char *str, int size)
|
||||||
{
|
{
|
||||||
char ch;
|
int count=0;
|
||||||
while ((ch = *str++) != '\0') {
|
while (count<size)
|
||||||
uart1_putc(ch);
|
{
|
||||||
|
uart1_putc(str[count]);
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function returns the number of bytes left in the queue after a read is done (negative if fail)*/
|
/* This function returns the number of bytes left in the queue after a read is done (negative if fail)*/
|
||||||
int uart1_gets_queue(char *str, unsigned int size)
|
int uart1_gets_queue(char *str, unsigned int size)
|
||||||
{
|
{
|
||||||
|
IO_INTC_EINT0 &= ~(1<<IRQ_UART1);
|
||||||
|
int retval;
|
||||||
|
|
||||||
if(uart1_recieve_count<size)
|
if(uart1_recieve_count<size)
|
||||||
return -uart1_recieve_count;
|
|
||||||
|
|
||||||
if(uart1_recieve_read+size<RECIEVE_RING_SIZE)
|
|
||||||
{
|
{
|
||||||
memcpy(str,uart1_recieve_buffer_ring+uart1_recieve_read,size);
|
retval= -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int tempcount=(RECIEVE_RING_SIZE-uart1_recieve_read);
|
if(uart1_recieve_read+size<RECIEVE_RING_SIZE)
|
||||||
memcpy(str,uart1_recieve_buffer_ring+uart1_recieve_read,tempcount);
|
{
|
||||||
memcpy(str+tempcount,uart1_recieve_buffer_ring,size-tempcount);
|
memcpy(str,uart1_recieve_buffer_ring+uart1_recieve_read,size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int tempcount=(RECIEVE_RING_SIZE-uart1_recieve_read);
|
||||||
|
memcpy(str,uart1_recieve_buffer_ring+uart1_recieve_read,tempcount);
|
||||||
|
memcpy(str+tempcount,uart1_recieve_buffer_ring,size-tempcount);
|
||||||
|
}
|
||||||
|
|
||||||
|
uart1_recieve_count-=size;
|
||||||
|
|
||||||
|
if(uart1_recieve_read+size<RECIEVE_RING_SIZE)
|
||||||
|
uart1_recieve_read+=size;
|
||||||
|
else
|
||||||
|
uart1_recieve_read=size-(RECIEVE_RING_SIZE-uart1_recieve_read);
|
||||||
|
|
||||||
|
retval=uart1_recieve_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
uart1_recieve_count-=size;
|
/* Enable the interrupt */
|
||||||
|
IO_INTC_EINT0 |= (1<<IRQ_UART1);
|
||||||
|
|
||||||
if(uart1_recieve_read+size<RECIEVE_RING_SIZE)
|
return retval;
|
||||||
uart1_recieve_read+=size;
|
|
||||||
else
|
|
||||||
uart1_recieve_read=size-(RECIEVE_RING_SIZE-uart1_recieve_read);
|
|
||||||
|
|
||||||
return uart1_recieve_count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* UART1 receive interupt handler */
|
/* UART1 receive interupt handler */
|
||||||
|
@ -109,7 +123,8 @@ void UART1(void)
|
||||||
if(uart1_recieve_write==RECIEVE_RING_SIZE)
|
if(uart1_recieve_write==RECIEVE_RING_SIZE)
|
||||||
uart1_recieve_write=0;
|
uart1_recieve_write=0;
|
||||||
|
|
||||||
uart1_recieve_buffer_ring[uart1_recieve_write++] = IO_UART1_DTRR & 0xff;
|
uart1_recieve_buffer_ring[uart1_recieve_write] = IO_UART1_DTRR & 0xff;
|
||||||
|
uart1_recieve_write++;
|
||||||
uart1_recieve_count++;
|
uart1_recieve_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,12 @@
|
||||||
#define UART_H
|
#define UART_H
|
||||||
|
|
||||||
void uart_init(void);
|
void uart_init(void);
|
||||||
bool uart1_getch(char *c);
|
|
||||||
void uart1_heartbeat(void);
|
|
||||||
bool uart1_available(void);
|
bool uart1_available(void);
|
||||||
|
|
||||||
int uart1_gets_queue(char *, unsigned int);
|
int uart1_gets_queue(char *, unsigned int);
|
||||||
void uart1_puts(const char *str);
|
void uart1_puts(const char *str, int size);
|
||||||
void uart1_gets(char *str, unsigned int size);
|
void uart1_gets(char *str, unsigned int size);
|
||||||
int uart1_pollch(unsigned int ticks);
|
|
||||||
void uart1_putc(char ch);
|
void uart1_putc(char ch);
|
||||||
void uart1_putHex(unsigned int n);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue