summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c65
1 files changed, 6 insertions, 59 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
index c6fffdec42..3dce73b05e 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
@@ -68,14 +68,6 @@ static volatile bool pen_down = false;
68static volatile unsigned short bat_val; 68static volatile unsigned short bat_val;
69static struct mutex battery_mtx; 69static struct mutex battery_mtx;
70 70
71static enum touchscreen_mode current_mode = TOUCHSCREEN_POINT;
72static const int touchscreen_buttons[3][3] =
73{
74 {BUTTON_TOPLEFT, BUTTON_TOPMIDDLE, BUTTON_TOPRIGHT},
75 {BUTTON_MIDLEFT, BUTTON_CENTER, BUTTON_MIDRIGHT},
76 {BUTTON_BOTTOMLEFT, BUTTON_BOTTOMMIDDLE, BUTTON_BOTTOMRIGHT}
77};
78
79const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = 71const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
80{ 72{
81 /* TODO */ 73 /* TODO */
@@ -163,30 +155,6 @@ void button_init_device(void)
163 mutex_init(&battery_mtx); 155 mutex_init(&battery_mtx);
164} 156}
165 157
166static int touch_to_pixels(short x, short y)
167{
168 /* X:300 -> 3800 Y:300->3900 */
169 x -= 300;
170 y -= 300;
171
172#if CONFIG_ORIENTATION == SCREEN_PORTRAIT
173 x /= 3200 / LCD_WIDTH;
174 y /= 3600 / LCD_HEIGHT;
175
176 y = LCD_HEIGHT - y;
177
178 return (x << 16) | y;
179#else
180 x /= 3200 / LCD_HEIGHT;
181 y /= 3600 / LCD_WIDTH;
182
183 y = LCD_WIDTH - y;
184 x = LCD_HEIGHT - x;
185
186 return (y << 16) | x;
187#endif
188}
189
190bool button_hold(void) 158bool button_hold(void)
191{ 159{
192 return ( 160 return (
@@ -218,38 +186,16 @@ int button_read_device(int *data)
218 if(tmp & BTN_OFF) 186 if(tmp & BTN_OFF)
219 ret |= BUTTON_POWER; 187 ret |= BUTTON_POWER;
220 188
221 if(cur_touch != 0) 189 if(cur_touch != 0 && pen_down)
222 { 190 {
223 if(current_mode == TOUCHSCREEN_BUTTON) 191 ret |= touchscreen_to_pixels(cur_touch >> 16, cur_touch & 0xFFFF, data);
224 { 192 if( UNLIKELY(!is_backlight_on(true)) )
225 int px_x = cur_touch >> 16; 193 *data = 0;
226 int px_y = cur_touch & 0xFFFF;
227 ret |= touchscreen_buttons[px_y/(LCD_HEIGHT/3)]
228 [px_x/(LCD_WIDTH/3)];
229 }
230 else if(pen_down)
231 {
232 ret |= BUTTON_TOUCHSCREEN;
233 *data = cur_touch;
234 }
235 } 194 }
236
237 if(ret & BUTTON_TOUCHSCREEN && !is_backlight_on(true))
238 *data = 0;
239 195
240 return ret; 196 return ret;
241} 197}
242 198
243void touchscreen_set_mode(enum touchscreen_mode mode)
244{
245 current_mode = mode;
246}
247
248enum touchscreen_mode touchscreen_get_mode(void)
249{
250 return current_mode;
251}
252
253/* Interrupt handler */ 199/* Interrupt handler */
254void SADC(void) 200void SADC(void)
255{ 201{
@@ -314,7 +260,8 @@ void SADC(void)
314 260
315 if(datacount >= TS_AD_COUNT) 261 if(datacount >= TS_AD_COUNT)
316 { 262 {
317 cur_touch = touch_to_pixels(x_pos/datacount, y_pos/datacount); 263 cur_touch = ((x_pos / datacount) << 16) |
264 ((y_pos / datacount) & 0xFFFF);
318 datacount = 0; 265 datacount = 0;
319 } 266 }
320 } 267 }