1
0
Fork 0
forked from len0rd/rockbox

slightly better touchpad driver. Still not brilliant, but the bootloader/debugger can follow a stylus with a cursor, so we can start work on getting apps/ working

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15187 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2007-10-18 12:15:56 +00:00
parent b431fe349f
commit d8667df357
3 changed files with 42 additions and 17 deletions

View file

@ -112,7 +112,7 @@ void mrdebug(void)
printf("%d:%d:%d %d %d %d", t->tm_hour, t->tm_min, t->tm_sec, t->tm_mday, t->tm_mon, t->tm_year); printf("%d:%d:%d %d %d %d", t->tm_hour, t->tm_min, t->tm_sec, t->tm_mday, t->tm_mon, t->tm_year);
printf("time: %d", mktime(t)); printf("time: %d", mktime(t));
#endif #endif
button = button_status(); button = button_get(false);
if (button == BUTTON_POWER) if (button == BUTTON_POWER)
{ {
printf("reset"); printf("reset");
@ -138,14 +138,16 @@ void mrdebug(void)
// tsc2100_keyclick(); /* doesnt work :( */ // tsc2100_keyclick(); /* doesnt work :( */
line -= 6; line -= 6;
} }
#if 0 #if 1
if (button&BUTTON_TOUCHPAD) if (button&BUTTON_TOUCHPAD)
{ {
unsigned int data = button_get_last_touch(); unsigned int data = button_get_data();
printf("x: %d, y: %d", data>>16, data&0xffff); int x = (data&0xffff0000)>>16, y = data&0x0000ffff;
line-=3; reset_screen();
lcd_hline(x-5, x+5, y);
lcd_vline(x, y-5, y+5);
lcd_update();
} }
else line -=2;
#endif #endif
} }
} }

View file

@ -46,7 +46,11 @@ void use_calibration(bool enable)
{ {
using_calibration = enable; using_calibration = enable;
} }
/* Jd's tests.. These will hopefully work for everyone so we dont have to
create a calibration screen. and
(0,0) = 0x00c0, 0xf40
(480,320) = 0x0f19, 0x00fc
*/
void set_calibration_points(struct touch_calibration_point *tl, void set_calibration_points(struct touch_calibration_point *tl,
struct touch_calibration_point *br) struct touch_calibration_point *br)
{ {
@ -75,7 +79,12 @@ void button_init_device(void)
last_touch = 0; last_touch = 0;
/* GIO is the power button, set as input */ /* GIO is the power button, set as input */
IO_GIO_DIR0 |= 0x01; IO_GIO_DIR0 |= 0x01;
topleft.px_x = 0; topleft.px_y = 0;
topleft.val_x = 0x00c0; topleft.val_y = 0xf40;
bottomright.px_x = LCD_WIDTH; bottomright.px_y = LCD_HEIGHT;
bottomright.val_x = 0x0f19; bottomright.val_y = 0x00fc;
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 */
@ -94,14 +103,13 @@ inline bool button_hold(void)
{ {
return false; return false;
} }
#ifdef BOOTLOADER
int button_get_last_touch(void) int button_get_last_touch(void)
{ {
int ret_val = last_touch; int ret_val = last_touch;
last_touch = 0; last_touch = 0;
return ret_val; return ret_val;
} }
#endif
static void remote_heartbeat(void) static void remote_heartbeat(void)
{ {
@ -115,9 +123,6 @@ int button_read_device(void)
int i = 0; int i = 0;
int btn = BUTTON_NONE; int btn = BUTTON_NONE;
if (last_touch)
btn |= BUTTON_TOUCHPAD;
if ((IO_GIO_BITSET0&0x01) == 0) if ((IO_GIO_BITSET0&0x01) == 0)
btn |= BUTTON_POWER; btn |= BUTTON_POWER;
@ -158,11 +163,27 @@ int button_read_device(void)
} }
return btn; return btn;
} }
#define TOUCH_MARGIN 8
void GIO14(void) void GIO14(void)
{ {
tsc2100_read_values(&last_x, &last_y, short x,y;
static int last_tick = 0;
tsc2100_read_values(&x, &y,
&last_z1, &last_z2); &last_z1, &last_z2);
last_touch = touch_to_pixels(last_x, last_y); 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); IO_INTC_IRQ2 = (1<<3);
} }

View file

@ -28,6 +28,7 @@
bool button_hold(void); bool button_hold(void);
void button_init_device(void); void button_init_device(void);
int button_read_device(void); int button_read_device(void);
int button_get_last_touch(void);
struct touch_calibration_point { struct touch_calibration_point {
short px_x; /* known pixel value */ short px_x; /* known pixel value */
@ -58,8 +59,9 @@ void use_calibration(bool enable);
/* compatibility hacks */ /* compatibility hacks */
#define BUTTON_LEFT BUTTON_RC_REW #define BUTTON_LEFT BUTTON_RC_REW
#define BUTTON_RIGHT BUTTON_RC_FF #define BUTTON_RIGHT BUTTON_RC_FF
#define POWEROFF_BUTTON BUTTON_POWER #define POWEROFF_BUTTON BUTTON_POWER
#define POWEROFF_COUNT 40 #define POWEROFF_COUNT 10
#define BUTTON_MAIN BUTTON_POWER #define BUTTON_MAIN BUTTON_POWER