summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-10-18 12:15:56 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-10-18 12:15:56 +0000
commitd8667df35731bad09dcdbc19a8239bf8b131114f (patch)
tree03b25a748a88735ad85ff457dc2209249e40c524
parentb431fe349faca089bc98b77a995c7b632b8ca3e3 (diff)
downloadrockbox-d8667df35731bad09dcdbc19a8239bf8b131114f.tar.gz
rockbox-d8667df35731bad09dcdbc19a8239bf8b131114f.zip
slightly better touchpad driver. Still not brilliant, but the bootloader/debugger can follow a stylus with a cursor, so we can start work on getting apps/ working
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15187 a1c6a512-1295-4272-9138-f99709370657
-rwxr-xr-xbootloader/mrobe500.c14
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c41
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-target.h4
3 files changed, 42 insertions, 17 deletions
diff --git a/bootloader/mrobe500.c b/bootloader/mrobe500.c
index 2ea9a1817b..c051e54fb6 100755
--- a/bootloader/mrobe500.c
+++ b/bootloader/mrobe500.c
@@ -112,7 +112,7 @@ void mrdebug(void)
112 printf("%d:%d:%d %d %d %d", t->tm_hour, t->tm_min, t->tm_sec, t->tm_mday, t->tm_mon, t->tm_year); 112 printf("%d:%d:%d %d %d %d", t->tm_hour, t->tm_min, t->tm_sec, t->tm_mday, t->tm_mon, t->tm_year);
113 printf("time: %d", mktime(t)); 113 printf("time: %d", mktime(t));
114#endif 114#endif
115 button = button_status(); 115 button = button_get(false);
116 if (button == BUTTON_POWER) 116 if (button == BUTTON_POWER)
117 { 117 {
118 printf("reset"); 118 printf("reset");
@@ -138,14 +138,16 @@ void mrdebug(void)
138// tsc2100_keyclick(); /* doesnt work :( */ 138// tsc2100_keyclick(); /* doesnt work :( */
139 line -= 6; 139 line -= 6;
140 } 140 }
141#if 0 141#if 1
142 if (button&BUTTON_TOUCHPAD) 142 if (button&BUTTON_TOUCHPAD)
143 { 143 {
144 unsigned int data = button_get_last_touch(); 144 unsigned int data = button_get_data();
145 printf("x: %d, y: %d", data>>16, data&0xffff); 145 int x = (data&0xffff0000)>>16, y = data&0x0000ffff;
146 line-=3; 146 reset_screen();
147 lcd_hline(x-5, x+5, y);
148 lcd_vline(x, y-5, y+5);
149 lcd_update();
147 } 150 }
148 else line -=2;
149#endif 151#endif
150 } 152 }
151} 153}
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}
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 @@
28bool button_hold(void); 28bool button_hold(void);
29void button_init_device(void); 29void button_init_device(void);
30int button_read_device(void); 30int button_read_device(void);
31int button_get_last_touch(void);
31 32
32struct touch_calibration_point { 33struct 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