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 */
|
||||
/* #define CONFIG_ORIENTATION SCREEN_PORTAIT */
|
||||
#define CONFIG_ORIENTATION SCREEN_LANDSCAPE
|
||||
#define CONFIG_ORIENTATION SCREEN_LANDSCAPE
|
||||
|
||||
#if CONFIG_ORIENTATION == SCREEN_PORTAIT
|
||||
#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 */
|
||||
while(cpu_reply != 2);
|
||||
#endif
|
||||
|
||||
|
||||
asm volatile(
|
||||
"mov r0, #0x10000000 \n"
|
||||
"mov pc, r0 \n"
|
||||
|
|
|
@ -33,20 +33,22 @@ bool __dbg_ports(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
extern char r_buffer[5];
|
||||
extern int r_button;
|
||||
bool __dbg_hw_info(void)
|
||||
{
|
||||
int line = 0, button, oldline;
|
||||
int *address=0x0;
|
||||
bool done=false;
|
||||
char buf[100];
|
||||
|
||||
|
||||
lcd_setmargins(0, 0);
|
||||
lcd_setfont(FONT_SYSFIXED);
|
||||
lcd_clear_display();
|
||||
|
||||
|
||||
/* Put all the static text befor the while loop */
|
||||
lcd_puts(0, line++, "[Hardware 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",
|
||||
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)
|
||||
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",
|
||||
(unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf);
|
||||
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 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
|
||||
* create a calibration screen.
|
||||
* Portait:
|
||||
|
@ -55,12 +51,6 @@ void use_calibration(bool enable)
|
|||
* (0,0) = 200, 270
|
||||
* (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)
|
||||
{
|
||||
|
@ -74,16 +64,20 @@ static int touch_to_pixels(short val_x, short val_y)
|
|||
y=val_x;
|
||||
#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;
|
||||
y = (y-topleft.val_y)*(bottomright.px_y - topleft.px_y) / (bottomright.val_y - topleft.val_y) + topleft.px_y;
|
||||
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
else if (x>=LCD_WIDTH)
|
||||
x=LCD_WIDTH-1;
|
||||
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y>=LCD_HEIGHT)
|
||||
y=LCD_HEIGHT-1;
|
||||
|
||||
|
||||
return (x<<16)|y;
|
||||
}
|
||||
|
||||
|
@ -107,14 +101,12 @@ void button_init_device(void)
|
|||
bottomright.val_y = 3880;
|
||||
#endif
|
||||
|
||||
topleft.px_x = 0;
|
||||
topleft.px_x = 0;
|
||||
topleft.px_y = 0;
|
||||
|
||||
bottomright.px_x = LCD_WIDTH;
|
||||
|
||||
bottomright.px_x = LCD_WIDTH;
|
||||
bottomright.px_y = LCD_HEIGHT;
|
||||
|
||||
using_calibration = true;
|
||||
|
||||
/* Enable the touchscreen interrupt */
|
||||
IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */
|
||||
#if 0
|
||||
|
@ -136,15 +128,18 @@ inline bool button_hold(void)
|
|||
static void remote_heartbeat(void)
|
||||
{
|
||||
char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'};
|
||||
uart1_puts(data);
|
||||
uart1_puts(data, 5);
|
||||
}
|
||||
|
||||
#define TOUCH_MARGIN 8
|
||||
char r_buffer[5];
|
||||
int r_button = BUTTON_NONE;
|
||||
int button_read_device(int *data)
|
||||
{
|
||||
char buffer[5];
|
||||
int button = BUTTON_NONE, retval;
|
||||
int retval, calbuf;
|
||||
static int oldbutton = BUTTON_NONE;
|
||||
|
||||
r_button=BUTTON_NONE;
|
||||
*data = 0;
|
||||
|
||||
if (touch_available)
|
||||
|
@ -170,7 +165,7 @@ int button_read_device(int *data)
|
|||
last_x = x;
|
||||
last_y = y;
|
||||
*data = touch_to_pixels(x, y);
|
||||
button |= BUTTON_TOUCHPAD;
|
||||
r_button |= BUTTON_TOUCHPAD;
|
||||
}
|
||||
last_touch = current_tick;
|
||||
touch_available = false;
|
||||
|
@ -178,23 +173,34 @@ int button_read_device(int *data)
|
|||
remote_heartbeat();
|
||||
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
button |= buffer[1];
|
||||
oldbutton=button;
|
||||
r_button |= r_buffer[calbuf];
|
||||
oldbutton=r_button;
|
||||
}
|
||||
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 */
|
||||
|
|
|
@ -62,39 +62,53 @@ void uart1_putc(char ch)
|
|||
IO_UART1_DTRR=ch;
|
||||
}
|
||||
|
||||
void uart1_puts(const char *str)
|
||||
void uart1_puts(const char *str, int size)
|
||||
{
|
||||
char ch;
|
||||
while ((ch = *str++) != '\0') {
|
||||
uart1_putc(ch);
|
||||
int count=0;
|
||||
while (count<size)
|
||||
{
|
||||
uart1_putc(str[count]);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
IO_INTC_EINT0 &= ~(1<<IRQ_UART1);
|
||||
int retval;
|
||||
|
||||
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
|
||||
{
|
||||
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);
|
||||
if(uart1_recieve_read+size<RECIEVE_RING_SIZE)
|
||||
{
|
||||
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)
|
||||
uart1_recieve_read+=size;
|
||||
else
|
||||
uart1_recieve_read=size-(RECIEVE_RING_SIZE-uart1_recieve_read);
|
||||
|
||||
return uart1_recieve_count;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* UART1 receive interupt handler */
|
||||
|
@ -109,7 +123,8 @@ void UART1(void)
|
|||
if(uart1_recieve_write==RECIEVE_RING_SIZE)
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,15 +21,12 @@
|
|||
#define UART_H
|
||||
|
||||
void uart_init(void);
|
||||
bool uart1_getch(char *c);
|
||||
void uart1_heartbeat(void);
|
||||
bool uart1_available(void);
|
||||
|
||||
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);
|
||||
int uart1_pollch(unsigned int ticks);
|
||||
void uart1_putc(char ch);
|
||||
void uart1_putHex(unsigned int n);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue