summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c')
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
index ab5860ab02..ea97f6d0db 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)
46{ 46{
47 using_calibration = enable; 47 using_calibration = enable;
48} 48}
49 49/* Jd's tests.. These will hopefully work for everyone so we dont have to
50 create a calibration screen. and
51(0,0) = 0x00c0, 0xf40
52(480,320) = 0x0f19, 0x00fc
53*/
50void set_calibration_points(struct touch_calibration_point *tl, 54void set_calibration_points(struct touch_calibration_point *tl,
51 struct touch_calibration_point *br) 55 struct touch_calibration_point *br)
52{ 56{
@@ -75,7 +79,12 @@ void button_init_device(void)
75 last_touch = 0; 79 last_touch = 0;
76 /* GIO is the power button, set as input */ 80 /* GIO is the power button, set as input */
77 IO_GIO_DIR0 |= 0x01; 81 IO_GIO_DIR0 |= 0x01;
82 topleft.px_x = 0; topleft.px_y = 0;
83 topleft.val_x = 0x00c0; topleft.val_y = 0xf40;
78 84
85 bottomright.px_x = LCD_WIDTH; bottomright.px_y = LCD_HEIGHT;
86 bottomright.val_x = 0x0f19; bottomright.val_y = 0x00fc;
87 using_calibration = true;
79 88
80 /* Enable the touchscreen interrupt */ 89 /* Enable the touchscreen interrupt */
81 IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */ 90 IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */
@@ -94,14 +103,13 @@ inline bool button_hold(void)
94{ 103{
95 return false; 104 return false;
96} 105}
97#ifdef BOOTLOADER 106
98int button_get_last_touch(void) 107int button_get_last_touch(void)
99{ 108{
100 int ret_val = last_touch; 109 int ret_val = last_touch;
101 last_touch = 0; 110 last_touch = 0;
102 return ret_val; 111 return ret_val;
103} 112}
104#endif
105 113
106static void remote_heartbeat(void) 114static void remote_heartbeat(void)
107{ 115{
@@ -114,10 +122,7 @@ int button_read_device(void)
114 char c; 122 char c;
115 int i = 0; 123 int i = 0;
116 int btn = BUTTON_NONE; 124 int btn = BUTTON_NONE;
117 125
118 if (last_touch)
119 btn |= BUTTON_TOUCHPAD;
120
121 if ((IO_GIO_BITSET0&0x01) == 0) 126 if ((IO_GIO_BITSET0&0x01) == 0)
122 btn |= BUTTON_POWER; 127 btn |= BUTTON_POWER;
123 128
@@ -158,11 +163,27 @@ int button_read_device(void)
158 } 163 }
159 return btn; 164 return btn;
160} 165}
161 166#define TOUCH_MARGIN 8
162void GIO14(void) 167void GIO14(void)
163{ 168{
164 tsc2100_read_values(&last_x, &last_y, 169 short x,y;
170 static int last_tick = 0;
171 tsc2100_read_values(&x, &y,
165 &last_z1, &last_z2); 172 &last_z1, &last_z2);
166 last_touch = touch_to_pixels(last_x, last_y); 173 if (TIME_BEFORE(last_tick+HZ/5, current_tick))
174 {
175 if ((x > last_x + TOUCH_MARGIN) ||
176 (x < last_x - TOUCH_MARGIN) ||
177 (y > last_y + TOUCH_MARGIN) ||
178 (y < last_y - TOUCH_MARGIN))
179 {
180 last_x = x;
181 last_y = y;
182 queue_clear(&button_queue);
183 queue_post(&button_queue, BUTTON_TOUCHPAD,
184 touch_to_pixels(x, y));
185 }
186 last_tick = current_tick;
187 }
167 IO_INTC_IRQ2 = (1<<3); 188 IO_INTC_IRQ2 = (1<<3);
168} 189}