From 23c18a6339638ef78b640d27418565ed5ef1c60e Mon Sep 17 00:00:00 2001 From: jdgordon Date: Thu, 18 Oct 2007 12:15:56 +0000 Subject: [PATCH] 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 --- bootloader/mrobe500.c | 14 ++++---- .../arm/tms320dm320/mrobe-500/button-mr500.c | 41 ++++++++++++++++------ .../arm/tms320dm320/mrobe-500/button-target.h | 4 ++- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/bootloader/mrobe500.c b/bootloader/mrobe500.c index 2ea9a1817..c051e54fb 100755 --- a/bootloader/mrobe500.c +++ b/bootloader/mrobe500.c @@ -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("time: %d", mktime(t)); #endif - button = button_status(); + button = button_get(false); if (button == BUTTON_POWER) { printf("reset"); @@ -138,14 +138,16 @@ void mrdebug(void) // tsc2100_keyclick(); /* doesnt work :( */ line -= 6; } -#if 0 +#if 1 if (button&BUTTON_TOUCHPAD) { - unsigned int data = button_get_last_touch(); - printf("x: %d, y: %d", data>>16, data&0xffff); - line-=3; + unsigned int data = button_get_data(); + int x = (data&0xffff0000)>>16, y = data&0x0000ffff; + reset_screen(); + lcd_hline(x-5, x+5, y); + lcd_vline(x, y-5, y+5); + lcd_update(); } - else line -=2; #endif } } diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c index ab5860ab0..ea97f6d0d 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c @@ -46,7 +46,11 @@ 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. and +(0,0) = 0x00c0, 0xf40 +(480,320) = 0x0f19, 0x00fc +*/ void set_calibration_points(struct touch_calibration_point *tl, struct touch_calibration_point *br) { @@ -75,7 +79,12 @@ void button_init_device(void) last_touch = 0; /* GIO is the power button, set as input */ 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 */ IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */ @@ -94,14 +103,13 @@ inline bool button_hold(void) { return false; } -#ifdef BOOTLOADER + int button_get_last_touch(void) { int ret_val = last_touch; last_touch = 0; return ret_val; } -#endif static void remote_heartbeat(void) { @@ -114,10 +122,7 @@ int button_read_device(void) char c; int i = 0; int btn = BUTTON_NONE; - - if (last_touch) - btn |= BUTTON_TOUCHPAD; - + if ((IO_GIO_BITSET0&0x01) == 0) btn |= BUTTON_POWER; @@ -158,11 +163,27 @@ int button_read_device(void) } return btn; } - +#define TOUCH_MARGIN 8 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_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); } diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h index d1fd46c62..238a3f614 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h @@ -28,6 +28,7 @@ bool button_hold(void); void button_init_device(void); int button_read_device(void); +int button_get_last_touch(void); struct touch_calibration_point { short px_x; /* known pixel value */ @@ -58,8 +59,9 @@ void use_calibration(bool enable); /* compatibility hacks */ #define BUTTON_LEFT BUTTON_RC_REW #define BUTTON_RIGHT BUTTON_RC_FF + #define POWEROFF_BUTTON BUTTON_POWER -#define POWEROFF_COUNT 40 +#define POWEROFF_COUNT 10 #define BUTTON_MAIN BUTTON_POWER -- 2.11.4.GIT