summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-10-22 07:01:59 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-10-22 07:01:59 +0000
commit12d1ff912c1f1d292bf91f29f7896882360424aa (patch)
tree968cdb858a05303a1474207244110c623bce5438 /firmware/target
parente49ab427f035af3a3e6f15e56fc839836533f23e (diff)
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
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c71
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-target.h3
2 files changed, 39 insertions, 35 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
index ea97f6d0db..f31c6ecb9f 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
@@ -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 */
}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h
index 238a3f6143..aa4768c05b 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h
+++ b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h
@@ -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 */