diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | 32 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-target.h | 8 |
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? */ |
39 | static short last_x, last_y, last_z1, last_z2; /* for the touch screen */ | 39 | static short last_x, last_y, last_z1, last_z2; /* for the touch screen */ |
40 | static int last_touch; | 40 | static int last_touch; |
41 | |||
42 | static struct touch_calibration_point topleft, bottomright; | ||
43 | static bool using_calibration = false; | ||
44 | void use_calibration(bool enable) | ||
45 | { | ||
46 | using_calibration = enable; | ||
47 | } | ||
48 | |||
49 | void 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 | } | ||
55 | static 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 | } | ||
41 | void button_init_device(void) | 71 | void 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); | |||
29 | void button_init_device(void); | 29 | void button_init_device(void); |
30 | int button_read_device(void); | 30 | int button_read_device(void); |
31 | 31 | ||
32 | struct 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 | }; | ||
38 | void 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 |