diff options
-rwxr-xr-x | bootloader/mrobe500.c | 32 | ||||
-rw-r--r-- | firmware/drivers/button.c | 48 | ||||
-rw-r--r-- | firmware/export/config-mrobe500.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | 71 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-target.h | 3 |
5 files changed, 98 insertions, 58 deletions
diff --git a/bootloader/mrobe500.c b/bootloader/mrobe500.c index fe48ac6a95..a3317f69a4 100755 --- a/bootloader/mrobe500.c +++ b/bootloader/mrobe500.c | |||
@@ -48,7 +48,7 @@ | |||
48 | #if defined(MRDEBUG) | 48 | #if defined(MRDEBUG) |
49 | 49 | ||
50 | extern int line; | 50 | extern int line; |
51 | 51 | #if 0 | |
52 | struct touch_calibration_point tl, br; | 52 | struct touch_calibration_point tl, br; |
53 | 53 | ||
54 | void touchpad_get_one_point(struct touch_calibration_point *p) | 54 | void touchpad_get_one_point(struct touch_calibration_point *p) |
@@ -96,7 +96,7 @@ void touchpad_calibrate_screen(void) | |||
96 | line++; | 96 | line++; |
97 | set_calibration_points(&tl, &br); | 97 | set_calibration_points(&tl, &br); |
98 | } | 98 | } |
99 | 99 | #endif | |
100 | void mrdebug(void) | 100 | void mrdebug(void) |
101 | { | 101 | { |
102 | int button=0, *address=0x0; | 102 | int button=0, *address=0x0; |
@@ -126,24 +126,28 @@ void mrdebug(void) | |||
126 | address+=0x1000; | 126 | address+=0x1000; |
127 | else if (button==BUTTON_RC_REW) | 127 | else if (button==BUTTON_RC_REW) |
128 | address-=0x1000; | 128 | address-=0x1000; |
129 | { | 129 | // { |
130 | short x,y,z1,z2; | 130 | // short x,y,z1,z2; |
131 | tsc2100_read_values(&x, &y, &z1, &z2); | 131 | // tsc2100_read_values(&x, &y, &z1, &z2); |
132 | printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2); | 132 | // printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2); |
133 | printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff); | 133 | // printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff); |
134 | printf("current tick: %04x", current_tick); | 134 | // printf("current tick: %04x", current_tick); |
135 | printf("Address: 0x%08x Data: 0x%08x", address, *address); | 135 | // printf("Address: 0x%08x Data: 0x%08x", address, *address); |
136 | printf("Address: 0x%08x Data: 0x%08x", address+1, *(address+1)); | 136 | // printf("Address: 0x%08x Data: 0x%08x", address+1, *(address+1)); |
137 | printf("Address: 0x%08x Data: 0x%08x", address+2, *(address+2)); | 137 | // printf("Address: 0x%08x Data: 0x%08x", address+2, *(address+2)); |
138 | // tsc2100_keyclick(); /* doesnt work :( */ | 138 | // // tsc2100_keyclick(); /* doesnt work :( */ |
139 | line -= 6; | 139 | // line -= 6; |
140 | } | 140 | // } |
141 | #if 1 | 141 | #if 1 |
142 | if (button&BUTTON_TOUCHPAD) | 142 | if (button&BUTTON_TOUCHPAD) |
143 | { | 143 | { |
144 | if (button&BUTTON_REL) | ||
145 | continue; | ||
144 | unsigned int data = button_get_data(); | 146 | unsigned int data = button_get_data(); |
145 | int x = (data&0xffff0000)>>16, y = data&0x0000ffff; | 147 | int x = (data&0xffff0000)>>16, y = data&0x0000ffff; |
146 | reset_screen(); | 148 | reset_screen(); |
149 | line = 9; | ||
150 | printf("%x %d %d\n", button, x,y); | ||
147 | lcd_hline(x-5, x+5, y); | 151 | lcd_hline(x-5, x+5, y); |
148 | lcd_vline(x, y-5, y+5); | 152 | lcd_vline(x, y-5, y+5); |
149 | lcd_update(); | 153 | lcd_update(); |
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 3967dfcc1a..000c4789a5 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -73,7 +73,11 @@ bool phones_present = false; | |||
73 | /* speed repeat finishes at, in ticks */ | 73 | /* speed repeat finishes at, in ticks */ |
74 | #define REPEAT_INTERVAL_FINISH 5 | 74 | #define REPEAT_INTERVAL_FINISH 5 |
75 | 75 | ||
76 | #ifdef HAVE_BUTTON_DATA | ||
77 | static int button_read(int *data); | ||
78 | #else | ||
76 | static int button_read(void); | 79 | static int button_read(void); |
80 | #endif | ||
77 | 81 | ||
78 | static void button_tick(void) | 82 | static void button_tick(void) |
79 | { | 83 | { |
@@ -90,6 +94,11 @@ static void button_tick(void) | |||
90 | #endif | 94 | #endif |
91 | int diff; | 95 | int diff; |
92 | int btn; | 96 | int btn; |
97 | #ifdef HAVE_BUTTON_DATA | ||
98 | int data = 0; | ||
99 | #else | ||
100 | const int data = 0; | ||
101 | #endif | ||
93 | 102 | ||
94 | #ifdef HAS_SERIAL_REMOTE | 103 | #ifdef HAS_SERIAL_REMOTE |
95 | /* Post events for the remote control */ | 104 | /* Post events for the remote control */ |
@@ -117,7 +126,11 @@ static void button_tick(void) | |||
117 | } | 126 | } |
118 | #endif | 127 | #endif |
119 | 128 | ||
129 | #ifdef HAVE_BUTTON_DATA | ||
130 | btn = button_read(&data); | ||
131 | #else | ||
120 | btn = button_read(); | 132 | btn = button_read(); |
133 | #endif | ||
121 | 134 | ||
122 | /* Find out if a key has been released */ | 135 | /* Find out if a key has been released */ |
123 | diff = btn ^ lastbtn; | 136 | diff = btn ^ lastbtn; |
@@ -127,17 +140,17 @@ static void button_tick(void) | |||
127 | #ifdef HAVE_REMOTE_LCD | 140 | #ifdef HAVE_REMOTE_LCD |
128 | if(diff & BUTTON_REMOTE) | 141 | if(diff & BUTTON_REMOTE) |
129 | if(!skip_remote_release) | 142 | if(!skip_remote_release) |
130 | queue_post(&button_queue, BUTTON_REL | diff, 0); | 143 | queue_post(&button_queue, BUTTON_REL | diff, data); |
131 | else | 144 | else |
132 | skip_remote_release = false; | 145 | skip_remote_release = false; |
133 | else | 146 | else |
134 | #endif | 147 | #endif |
135 | if(!skip_release) | 148 | if(!skip_release) |
136 | queue_post(&button_queue, BUTTON_REL | diff, 0); | 149 | queue_post(&button_queue, BUTTON_REL | diff, data); |
137 | else | 150 | else |
138 | skip_release = false; | 151 | skip_release = false; |
139 | #else | 152 | #else |
140 | queue_post(&button_queue, BUTTON_REL | diff, 0); | 153 | queue_post(&button_queue, BUTTON_REL | diff, data); |
141 | #endif | 154 | #endif |
142 | } | 155 | } |
143 | else | 156 | else |
@@ -212,7 +225,7 @@ static void button_tick(void) | |||
212 | * to avoid afterscroll effects. */ | 225 | * to avoid afterscroll effects. */ |
213 | if (queue_empty(&button_queue)) | 226 | if (queue_empty(&button_queue)) |
214 | { | 227 | { |
215 | queue_post(&button_queue, BUTTON_REPEAT | btn, 0); | 228 | queue_post(&button_queue, BUTTON_REPEAT | btn, data); |
216 | #ifdef HAVE_BACKLIGHT | 229 | #ifdef HAVE_BACKLIGHT |
217 | #ifdef HAVE_REMOTE_LCD | 230 | #ifdef HAVE_REMOTE_LCD |
218 | skip_remote_release = false; | 231 | skip_remote_release = false; |
@@ -232,7 +245,7 @@ static void button_tick(void) | |||
232 | || (remote_type()==REMOTETYPE_H300_NONLCD) | 245 | || (remote_type()==REMOTETYPE_H300_NONLCD) |
233 | #endif | 246 | #endif |
234 | ) | 247 | ) |
235 | queue_post(&button_queue, btn, 0); | 248 | queue_post(&button_queue, btn, data); |
236 | else | 249 | else |
237 | skip_remote_release = true; | 250 | skip_remote_release = true; |
238 | } | 251 | } |
@@ -243,11 +256,11 @@ static void button_tick(void) | |||
243 | || (btn&BUTTON_REMOTE) | 256 | || (btn&BUTTON_REMOTE) |
244 | #endif | 257 | #endif |
245 | ) | 258 | ) |
246 | queue_post(&button_queue, btn, 0); | 259 | queue_post(&button_queue, btn, data); |
247 | else | 260 | else |
248 | skip_release = true; | 261 | skip_release = true; |
249 | #else /* no backlight, nothing to skip */ | 262 | #else /* no backlight, nothing to skip */ |
250 | queue_post(&button_queue, btn, 0); | 263 | queue_post(&button_queue, btn, data); |
251 | #endif | 264 | #endif |
252 | post = false; | 265 | post = false; |
253 | } | 266 | } |
@@ -356,13 +369,22 @@ intptr_t button_get_data(void) | |||
356 | 369 | ||
357 | void button_init(void) | 370 | void button_init(void) |
358 | { | 371 | { |
372 | #ifdef HAVE_BUTTON_DATA | ||
373 | int temp; | ||
374 | #endif | ||
359 | /* hardware inits */ | 375 | /* hardware inits */ |
360 | button_init_device(); | 376 | button_init_device(); |
361 | 377 | ||
362 | queue_init(&button_queue, true); | 378 | queue_init(&button_queue, true); |
363 | 379 | ||
380 | #ifdef HAVE_BUTTON_DATA | ||
381 | button_read(&temp); | ||
382 | lastbtn = button_read(&temp); | ||
383 | #else | ||
364 | button_read(); | 384 | button_read(); |
365 | lastbtn = button_read(); | 385 | lastbtn = button_read(); |
386 | #endif | ||
387 | |||
366 | tick_add_task(button_tick); | 388 | tick_add_task(button_tick); |
367 | reset_poweroff_timer(); | 389 | reset_poweroff_timer(); |
368 | 390 | ||
@@ -457,9 +479,15 @@ void set_remote_backlight_filter_keypress(bool value) | |||
457 | /* | 479 | /* |
458 | * Get button pressed from hardware | 480 | * Get button pressed from hardware |
459 | */ | 481 | */ |
482 | #ifdef HAVE_BUTTON_DATA | ||
483 | static int button_read(int *data) | ||
484 | { | ||
485 | int btn = button_read_device(data); | ||
486 | #else | ||
460 | static int button_read(void) | 487 | static int button_read(void) |
461 | { | 488 | { |
462 | int btn = button_read_device(); | 489 | int btn = button_read_device(); |
490 | #endif | ||
463 | int retval; | 491 | int retval; |
464 | 492 | ||
465 | #ifdef HAVE_LCD_BITMAP | 493 | #ifdef HAVE_LCD_BITMAP |
@@ -469,9 +497,11 @@ static int button_read(void) | |||
469 | 497 | ||
470 | /* Filter the button status. It is only accepted if we get the same | 498 | /* Filter the button status. It is only accepted if we get the same |
471 | status twice in a row. */ | 499 | status twice in a row. */ |
500 | #ifndef HAVE_TOUCHPAD | ||
472 | if (btn != last_read) | 501 | if (btn != last_read) |
473 | retval = lastbtn; | 502 | retval = lastbtn; |
474 | else | 503 | else |
504 | #endif | ||
475 | retval = btn; | 505 | retval = btn; |
476 | last_read = btn; | 506 | last_read = btn; |
477 | 507 | ||
diff --git a/firmware/export/config-mrobe500.h b/firmware/export/config-mrobe500.h index bd0176452f..9cd7a7c478 100644 --- a/firmware/export/config-mrobe500.h +++ b/firmware/export/config-mrobe500.h | |||
@@ -77,6 +77,8 @@ | |||
77 | #define DEFAULT_REMOTE_CONTRAST_SETTING 7 | 77 | #define DEFAULT_REMOTE_CONTRAST_SETTING 7 |
78 | 78 | ||
79 | #define CONFIG_KEYPAD MROBE500_PAD | 79 | #define CONFIG_KEYPAD MROBE500_PAD |
80 | #define HAVE_TOUCHPAD | ||
81 | #define HAVE_BUTTON_DATA | ||
80 | 82 | ||
81 | /* Define this if you do software codec */ | 83 | /* Define this if you do software codec */ |
82 | #define CONFIG_CODEC SWCODEC | 84 | #define CONFIG_CODEC SWCODEC |
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 @@ | |||
38 | #define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */ | 38 | #define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */ |
39 | /* but always the same one for the session? */ | 39 | /* but always the same one for the session? */ |
40 | static short last_x, last_y, last_z1, last_z2; /* for the touch screen */ | 40 | static short last_x, last_y, last_z1, last_z2; /* for the touch screen */ |
41 | static int last_touch; | 41 | static bool touch_available = false; |
42 | 42 | ||
43 | static struct touch_calibration_point topleft, bottomright; | 43 | static struct touch_calibration_point topleft, bottomright; |
44 | static bool using_calibration = false; | 44 | static bool using_calibration = false; |
@@ -76,7 +76,7 @@ static int touch_to_pixels(short val_x, short val_y) | |||
76 | 76 | ||
77 | void button_init_device(void) | 77 | void button_init_device(void) |
78 | { | 78 | { |
79 | last_touch = 0; | 79 | touch_available = false; |
80 | /* GIO is the power button, set as input */ | 80 | /* GIO is the power button, set as input */ |
81 | IO_GIO_DIR0 |= 0x01; | 81 | IO_GIO_DIR0 |= 0x01; |
82 | topleft.px_x = 0; topleft.px_y = 0; | 82 | topleft.px_x = 0; topleft.px_y = 0; |
@@ -104,28 +104,50 @@ inline bool button_hold(void) | |||
104 | return false; | 104 | return false; |
105 | } | 105 | } |
106 | 106 | ||
107 | int button_get_last_touch(void) | ||
108 | { | ||
109 | int ret_val = last_touch; | ||
110 | last_touch = 0; | ||
111 | return ret_val; | ||
112 | } | ||
113 | |||
114 | static void remote_heartbeat(void) | 107 | static void remote_heartbeat(void) |
115 | { | 108 | { |
116 | char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'}; | 109 | char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'}; |
117 | uart1_puts(data); | 110 | uart1_puts(data); |
118 | } | 111 | } |
119 | 112 | ||
120 | int button_read_device(void) | 113 | #define TOUCH_MARGIN 8 |
114 | int button_read_device(int *data) | ||
121 | { | 115 | { |
122 | char c; | 116 | char c; |
123 | int i = 0; | 117 | int i = 0; |
124 | int btn = BUTTON_NONE; | 118 | int btn = BUTTON_NONE; |
125 | 119 | *data = 0; | |
120 | |||
126 | if ((IO_GIO_BITSET0&0x01) == 0) | 121 | if ((IO_GIO_BITSET0&0x01) == 0) |
127 | btn |= BUTTON_POWER; | 122 | btn |= BUTTON_POWER; |
128 | 123 | if (touch_available) | |
124 | { | ||
125 | short x,y; | ||
126 | static long last_touch = 0; | ||
127 | bool send_touch = false; | ||
128 | tsc2100_read_values(&x, &y, &last_z1, &last_z2); | ||
129 | if (TIME_BEFORE(last_touch + HZ/5, current_tick)) | ||
130 | { | ||
131 | if ((x > last_x + TOUCH_MARGIN) || | ||
132 | (x < last_x - TOUCH_MARGIN) || | ||
133 | (y > last_y + TOUCH_MARGIN) || | ||
134 | (y < last_y - TOUCH_MARGIN)) | ||
135 | { | ||
136 | send_touch = true; | ||
137 | } | ||
138 | } | ||
139 | else | ||
140 | send_touch = true; | ||
141 | if (send_touch) | ||
142 | { | ||
143 | last_x = x; | ||
144 | last_y = y; | ||
145 | *data = touch_to_pixels(x, y); | ||
146 | btn |= BUTTON_TOUCHPAD; | ||
147 | } | ||
148 | last_touch = current_tick; | ||
149 | touch_available = false; | ||
150 | } | ||
129 | remote_heartbeat(); | 151 | remote_heartbeat(); |
130 | while (uart1_getch(&c)) | 152 | while (uart1_getch(&c)) |
131 | { | 153 | { |
@@ -163,27 +185,10 @@ int button_read_device(void) | |||
163 | } | 185 | } |
164 | return btn; | 186 | return btn; |
165 | } | 187 | } |
166 | #define TOUCH_MARGIN 8 | 188 | |
189 | /* Touchpad data available interupt */ | ||
167 | void GIO14(void) | 190 | void GIO14(void) |
168 | { | 191 | { |
169 | short x,y; | 192 | touch_available = true; |
170 | static int last_tick = 0; | 193 | IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */ |
171 | tsc2100_read_values(&x, &y, | ||
172 | &last_z1, &last_z2); | ||
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 | } | ||
188 | IO_INTC_IRQ2 = (1<<3); | ||
189 | } | 194 | } |
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 @@ | |||
27 | 27 | ||
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(int *data); |
31 | int button_get_last_touch(void); | ||
32 | 31 | ||
33 | struct touch_calibration_point { | 32 | struct touch_calibration_point { |
34 | short px_x; /* known pixel value */ | 33 | short px_x; /* known pixel value */ |