summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-10-01 07:52:39 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-10-01 07:52:39 +0000
commit274c2b8d69900c3156ced83949d37c66492db22f (patch)
tree91941736e4b71010262fac758535d39f587443b4 /firmware/target/arm
parentf8ada4b9c104fdc729dcce4cf381cf356faadea5 (diff)
downloadrockbox-274c2b8d69900c3156ced83949d37c66492db22f.tar.gz
rockbox-274c2b8d69900c3156ced83949d37c66492db22f.zip
touchpad calibration (very simple calibration screen is in mrobe500.c
but will not actually be used in the bootloader once rockbox main is running) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14937 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c32
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-target.h8
2 files changed, 39 insertions, 1 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
index b157ae2d12..c30422fc79 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
@@ -38,6 +38,36 @@
38 /* but always the same one for the session? */ 38 /* but always the same one for the session? */
39static short last_x, last_y, last_z1, last_z2; /* for the touch screen */ 39static short last_x, last_y, last_z1, last_z2; /* for the touch screen */
40static int last_touch; 40static int last_touch;
41
42static struct touch_calibration_point topleft, bottomright;
43static bool using_calibration = false;
44void use_calibration(bool enable)
45{
46 using_calibration = enable;
47}
48
49void set_calibration_points(struct touch_calibration_point *tl,
50 struct touch_calibration_point *br)
51{
52 memcpy(&topleft, tl, sizeof(struct touch_calibration_point));
53 memcpy(&bottomright, br, sizeof(struct touch_calibration_point));
54}
55static int touch_to_pixels(short val_x, short val_y)
56{
57 short x,y;
58 int x1,x2;
59 if (!using_calibration)
60 return (val_x<<16)|val_y;
61 x1 = topleft.val_x; x2 = bottomright.val_x;
62 x = (val_x-x1)*(bottomright.px_x - topleft.px_x) / (x2 - x1) + topleft.px_x;
63 x1 = topleft.val_y; x2 = bottomright.val_y;
64 y = (val_y-x1)*(bottomright.px_y - topleft.px_y) / (x2 - x1) + topleft.px_y;
65 if (x < 0)
66 x = 0;
67 if (y < 0)
68 y = 0;
69 return (x<<16)|y;
70}
41void button_init_device(void) 71void button_init_device(void)
42{ 72{
43 last_touch = 0; 73 last_touch = 0;
@@ -128,6 +158,6 @@ void GIO14(void)
128{ 158{
129 tsc2100_read_values(&last_x, &last_y, 159 tsc2100_read_values(&last_x, &last_y,
130 &last_z1, &last_z2); 160 &last_z1, &last_z2);
131 last_touch = (last_x<<16)|last_y; 161 last_touch = touch_to_pixels(last_x, last_y);
132 IO_INTC_IRQ2 = (1<<3); 162 IO_INTC_IRQ2 = (1<<3);
133} 163}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h
index f574321717..d1fd46c629 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h
+++ b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h
@@ -29,6 +29,14 @@ bool button_hold(void);
29void button_init_device(void); 29void button_init_device(void);
30int button_read_device(void); 30int button_read_device(void);
31 31
32struct touch_calibration_point {
33 short px_x; /* known pixel value */
34 short px_y;
35 short val_x; /* touchpad value at the known pixel */
36 short val_y;
37};
38void use_calibration(bool enable);
39
32/* m:robe 500 specific button codes */ 40/* m:robe 500 specific button codes */
33 41
34#define BUTTON_POWER 0x00000001 42#define BUTTON_POWER 0x00000001