touchpad driver for the mrobe. nothing in apps/ uses it yet.

Changes to button driver: HAVE_BUTTON_DATA targets pass the button data straight back in the button_read_device() call


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15262 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2007-10-22 07:01:59 +00:00
parent e49ab427f0
commit 12d1ff912c
5 changed files with 98 additions and 58 deletions

View file

@ -48,7 +48,7 @@
#if defined(MRDEBUG)
extern int line;
#if 0
struct touch_calibration_point tl, br;
void touchpad_get_one_point(struct touch_calibration_point *p)
@ -96,7 +96,7 @@ void touchpad_calibrate_screen(void)
line++;
set_calibration_points(&tl, &br);
}
#endif
void mrdebug(void)
{
int button=0, *address=0x0;
@ -126,24 +126,28 @@ void mrdebug(void)
address+=0x1000;
else if (button==BUTTON_RC_REW)
address-=0x1000;
{
short x,y,z1,z2;
tsc2100_read_values(&x, &y, &z1, &z2);
printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2);
printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff);
printf("current tick: %04x", current_tick);
printf("Address: 0x%08x Data: 0x%08x", address, *address);
printf("Address: 0x%08x Data: 0x%08x", address+1, *(address+1));
printf("Address: 0x%08x Data: 0x%08x", address+2, *(address+2));
// tsc2100_keyclick(); /* doesnt work :( */
line -= 6;
}
// {
// short x,y,z1,z2;
// tsc2100_read_values(&x, &y, &z1, &z2);
// printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2);
// printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff);
// printf("current tick: %04x", current_tick);
// printf("Address: 0x%08x Data: 0x%08x", address, *address);
// printf("Address: 0x%08x Data: 0x%08x", address+1, *(address+1));
// printf("Address: 0x%08x Data: 0x%08x", address+2, *(address+2));
// // tsc2100_keyclick(); /* doesnt work :( */
// line -= 6;
// }
#if 1
if (button&BUTTON_TOUCHPAD)
{
if (button&BUTTON_REL)
continue;
unsigned int data = button_get_data();
int x = (data&0xffff0000)>>16, y = data&0x0000ffff;
reset_screen();
line = 9;
printf("%x %d %d\n", button, x,y);
lcd_hline(x-5, x+5, y);
lcd_vline(x, y-5, y+5);
lcd_update();

View file

@ -73,7 +73,11 @@ bool phones_present = false;
/* speed repeat finishes at, in ticks */
#define REPEAT_INTERVAL_FINISH 5
#ifdef HAVE_BUTTON_DATA
static int button_read(int *data);
#else
static int button_read(void);
#endif
static void button_tick(void)
{
@ -90,6 +94,11 @@ static void button_tick(void)
#endif
int diff;
int btn;
#ifdef HAVE_BUTTON_DATA
int data = 0;
#else
const int data = 0;
#endif
#ifdef HAS_SERIAL_REMOTE
/* Post events for the remote control */
@ -117,7 +126,11 @@ static void button_tick(void)
}
#endif
#ifdef HAVE_BUTTON_DATA
btn = button_read(&data);
#else
btn = button_read();
#endif
/* Find out if a key has been released */
diff = btn ^ lastbtn;
@ -127,17 +140,17 @@ static void button_tick(void)
#ifdef HAVE_REMOTE_LCD
if(diff & BUTTON_REMOTE)
if(!skip_remote_release)
queue_post(&button_queue, BUTTON_REL | diff, 0);
queue_post(&button_queue, BUTTON_REL | diff, data);
else
skip_remote_release = false;
else
#endif
if(!skip_release)
queue_post(&button_queue, BUTTON_REL | diff, 0);
queue_post(&button_queue, BUTTON_REL | diff, data);
else
skip_release = false;
#else
queue_post(&button_queue, BUTTON_REL | diff, 0);
queue_post(&button_queue, BUTTON_REL | diff, data);
#endif
}
else
@ -212,7 +225,7 @@ static void button_tick(void)
* to avoid afterscroll effects. */
if (queue_empty(&button_queue))
{
queue_post(&button_queue, BUTTON_REPEAT | btn, 0);
queue_post(&button_queue, BUTTON_REPEAT | btn, data);
#ifdef HAVE_BACKLIGHT
#ifdef HAVE_REMOTE_LCD
skip_remote_release = false;
@ -232,7 +245,7 @@ static void button_tick(void)
|| (remote_type()==REMOTETYPE_H300_NONLCD)
#endif
)
queue_post(&button_queue, btn, 0);
queue_post(&button_queue, btn, data);
else
skip_remote_release = true;
}
@ -243,11 +256,11 @@ static void button_tick(void)
|| (btn&BUTTON_REMOTE)
#endif
)
queue_post(&button_queue, btn, 0);
queue_post(&button_queue, btn, data);
else
skip_release = true;
#else /* no backlight, nothing to skip */
queue_post(&button_queue, btn, 0);
queue_post(&button_queue, btn, data);
#endif
post = false;
}
@ -356,13 +369,22 @@ intptr_t button_get_data(void)
void button_init(void)
{
#ifdef HAVE_BUTTON_DATA
int temp;
#endif
/* hardware inits */
button_init_device();
queue_init(&button_queue, true);
#ifdef HAVE_BUTTON_DATA
button_read(&temp);
lastbtn = button_read(&temp);
#else
button_read();
lastbtn = button_read();
#endif
tick_add_task(button_tick);
reset_poweroff_timer();
@ -457,9 +479,15 @@ void set_remote_backlight_filter_keypress(bool value)
/*
* Get button pressed from hardware
*/
#ifdef HAVE_BUTTON_DATA
static int button_read(int *data)
{
int btn = button_read_device(data);
#else
static int button_read(void)
{
int btn = button_read_device();
#endif
int retval;
#ifdef HAVE_LCD_BITMAP
@ -469,9 +497,11 @@ static int button_read(void)
/* Filter the button status. It is only accepted if we get the same
status twice in a row. */
#ifndef HAVE_TOUCHPAD
if (btn != last_read)
retval = lastbtn;
retval = lastbtn;
else
#endif
retval = btn;
last_read = btn;

View file

@ -77,6 +77,8 @@
#define DEFAULT_REMOTE_CONTRAST_SETTING 7
#define CONFIG_KEYPAD MROBE500_PAD
#define HAVE_TOUCHPAD
#define HAVE_BUTTON_DATA
/* Define this if you do software codec */
#define CONFIG_CODEC SWCODEC

View file

@ -38,7 +38,7 @@
#define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */
/* but always the same one for the session? */
static short last_x, last_y, last_z1, last_z2; /* for the touch screen */
static int last_touch;
static bool touch_available = false;
static struct touch_calibration_point topleft, bottomright;
static bool using_calibration = false;
@ -76,7 +76,7 @@ static int touch_to_pixels(short val_x, short val_y)
void button_init_device(void)
{
last_touch = 0;
touch_available = false;
/* GIO is the power button, set as input */
IO_GIO_DIR0 |= 0x01;
topleft.px_x = 0; topleft.px_y = 0;
@ -104,28 +104,50 @@ inline bool button_hold(void)
return false;
}
int button_get_last_touch(void)
{
int ret_val = last_touch;
last_touch = 0;
return ret_val;
}
static void remote_heartbeat(void)
{
char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'};
uart1_puts(data);
}
int button_read_device(void)
#define TOUCH_MARGIN 8
int button_read_device(int *data)
{
char c;
int i = 0;
int btn = BUTTON_NONE;
*data = 0;
if ((IO_GIO_BITSET0&0x01) == 0)
btn |= BUTTON_POWER;
if (touch_available)
{
short x,y;
static long last_touch = 0;
bool send_touch = false;
tsc2100_read_values(&x, &y, &last_z1, &last_z2);
if (TIME_BEFORE(last_touch + HZ/5, current_tick))
{
if ((x > last_x + TOUCH_MARGIN) ||
(x < last_x - TOUCH_MARGIN) ||
(y > last_y + TOUCH_MARGIN) ||
(y < last_y - TOUCH_MARGIN))
{
send_touch = true;
}
}
else
send_touch = true;
if (send_touch)
{
last_x = x;
last_y = y;
*data = touch_to_pixels(x, y);
btn |= BUTTON_TOUCHPAD;
}
last_touch = current_tick;
touch_available = false;
}
remote_heartbeat();
while (uart1_getch(&c))
{
@ -163,27 +185,10 @@ int button_read_device(void)
}
return btn;
}
#define TOUCH_MARGIN 8
/* Touchpad data available interupt */
void GIO14(void)
{
short x,y;
static int last_tick = 0;
tsc2100_read_values(&x, &y,
&last_z1, &last_z2);
if (TIME_BEFORE(last_tick+HZ/5, current_tick))
{
if ((x > last_x + TOUCH_MARGIN) ||
(x < last_x - TOUCH_MARGIN) ||
(y > last_y + TOUCH_MARGIN) ||
(y < last_y - TOUCH_MARGIN))
{
last_x = x;
last_y = y;
queue_clear(&button_queue);
queue_post(&button_queue, BUTTON_TOUCHPAD,
touch_to_pixels(x, y));
}
last_tick = current_tick;
}
IO_INTC_IRQ2 = (1<<3);
touch_available = true;
IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */
}

View file

@ -27,8 +27,7 @@
bool button_hold(void);
void button_init_device(void);
int button_read_device(void);
int button_get_last_touch(void);
int button_read_device(int *data);
struct touch_calibration_point {
short px_x; /* known pixel value */