diff options
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | 41 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-target.h | 4 |
2 files changed, 34 insertions, 11 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 | */ | ||
50 | void set_calibration_points(struct touch_calibration_point *tl, | 54 | void 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 | |
98 | int button_get_last_touch(void) | 107 | int 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 | ||
106 | static void remote_heartbeat(void) | 114 | static 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 | |
162 | void GIO14(void) | 167 | void 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 | } |
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h index d1fd46c629..238a3f6143 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 @@ | |||
28 | bool button_hold(void); | 28 | 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 | int button_get_last_touch(void); | ||
31 | 32 | ||
32 | struct touch_calibration_point { | 33 | struct touch_calibration_point { |
33 | short px_x; /* known pixel value */ | 34 | short px_x; /* known pixel value */ |
@@ -58,8 +59,9 @@ void use_calibration(bool enable); | |||
58 | /* compatibility hacks */ | 59 | /* compatibility hacks */ |
59 | #define BUTTON_LEFT BUTTON_RC_REW | 60 | #define BUTTON_LEFT BUTTON_RC_REW |
60 | #define BUTTON_RIGHT BUTTON_RC_FF | 61 | #define BUTTON_RIGHT BUTTON_RC_FF |
62 | |||
61 | #define POWEROFF_BUTTON BUTTON_POWER | 63 | #define POWEROFF_BUTTON BUTTON_POWER |
62 | #define POWEROFF_COUNT 40 | 64 | #define POWEROFF_COUNT 10 |
63 | 65 | ||
64 | #define BUTTON_MAIN BUTTON_POWER | 66 | #define BUTTON_MAIN BUTTON_POWER |
65 | 67 | ||