diff options
Diffstat (limited to 'firmware/target')
3 files changed, 14 insertions, 92 deletions
diff --git a/firmware/target/arm/tcc780x/cowond2/button-cowond2.c b/firmware/target/arm/tcc780x/cowond2/button-cowond2.c index 9449bcdf30..12eb88907a 100644 --- a/firmware/target/arm/tcc780x/cowond2/button-cowond2.c +++ b/firmware/target/arm/tcc780x/cowond2/button-cowond2.c | |||
@@ -25,31 +25,13 @@ | |||
25 | #include "adc.h" | 25 | #include "adc.h" |
26 | #include "pcf50606.h" | 26 | #include "pcf50606.h" |
27 | #include "backlight.h" | 27 | #include "backlight.h" |
28 | #include "touchscreen.h" | ||
28 | 29 | ||
29 | #define TOUCH_MARGIN 8 | 30 | #define TOUCH_MARGIN 8 |
30 | 31 | ||
31 | static enum touchscreen_mode current_mode = TOUCHSCREEN_POINT; | ||
32 | |||
33 | static short last_x, last_y; | 32 | static short last_x, last_y; |
34 | static bool touch_available = false; | 33 | static bool touch_available = false; |
35 | 34 | ||
36 | static int touchscreen_buttons[3][3] = | ||
37 | { | ||
38 | {BUTTON_TOPLEFT, BUTTON_TOPMIDDLE, BUTTON_TOPRIGHT}, | ||
39 | {BUTTON_MIDLEFT, BUTTON_CENTER, BUTTON_MIDRIGHT}, | ||
40 | {BUTTON_BOTTOMLEFT, BUTTON_BOTTOMMIDDLE, BUTTON_BOTTOMRIGHT}, | ||
41 | }; | ||
42 | |||
43 | void touchscreen_set_mode(enum touchscreen_mode mode) | ||
44 | { | ||
45 | current_mode = mode; | ||
46 | } | ||
47 | |||
48 | enum touchscreen_mode touchscreen_get_mode(void) | ||
49 | { | ||
50 | return current_mode; | ||
51 | } | ||
52 | |||
53 | void button_set_touch_available(void) | 35 | void button_set_touch_available(void) |
54 | { | 36 | { |
55 | touch_available = true; | 37 | touch_available = true; |
@@ -186,20 +168,9 @@ int button_read_device(int *data) | |||
186 | last_x = x; | 168 | last_x = x; |
187 | last_y = y; | 169 | last_y = y; |
188 | *data = touch_to_pixels(x, y); | 170 | *data = touch_to_pixels(x, y); |
189 | switch (current_mode) | 171 | btn |= touchscreen_to_pixels((*data&0xffff0000)>>16, |
190 | { | 172 | (*data&0x0000ffff), |
191 | case TOUCHSCREEN_POINT: | 173 | data); |
192 | btn |= BUTTON_TOUCHSCREEN; | ||
193 | break; | ||
194 | case TOUCHSCREEN_BUTTON: | ||
195 | { | ||
196 | int px_x = (*data&0xffff0000)>>16; | ||
197 | int px_y = (*data&0x0000ffff); | ||
198 | btn |= touchscreen_buttons[px_y/(LCD_HEIGHT/3)] | ||
199 | [px_x/(LCD_WIDTH/3)]; | ||
200 | break; | ||
201 | } | ||
202 | } | ||
203 | } | 174 | } |
204 | last_touch = current_tick; | 175 | last_touch = current_tick; |
205 | touch_available = false; | 176 | touch_available = false; |
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-target.h index 677e4d1c67..67d710a38a 100644 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-target.h +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-target.h | |||
@@ -57,6 +57,10 @@ void button_set_touch_available(void); | |||
57 | 57 | ||
58 | #define BUTTON_TOUCH 0x00002000 | 58 | #define BUTTON_TOUCH 0x00002000 |
59 | 59 | ||
60 | #define DEFAULT_TOUCHSCREEN_CALIBRATION {.A=0xFFF9FDA2, .B=0xFFFFE82A, \ | ||
61 | .C=0xA22AA2C, .D=0x23DC, .E=0x8E3E6, \ | ||
62 | .F=0x76CF88AA, .divider=0xFFAD4013} | ||
63 | |||
60 | #define BUTTON_MAIN 0x3FFF | 64 | #define BUTTON_MAIN 0x3FFF |
61 | 65 | ||
62 | /* No remote */ | 66 | /* No remote */ |
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; | |||
68 | static volatile unsigned short bat_val; | 68 | static volatile unsigned short bat_val; |
69 | static struct mutex battery_mtx; | 69 | static struct mutex battery_mtx; |
70 | 70 | ||
71 | static enum touchscreen_mode current_mode = TOUCHSCREEN_POINT; | ||
72 | static 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 | |||
79 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | 71 | const 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 | ||
166 | static 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 | |||
190 | bool button_hold(void) | 158 | bool 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 | ||
243 | void touchscreen_set_mode(enum touchscreen_mode mode) | ||
244 | { | ||
245 | current_mode = mode; | ||
246 | } | ||
247 | |||
248 | enum touchscreen_mode touchscreen_get_mode(void) | ||
249 | { | ||
250 | return current_mode; | ||
251 | } | ||
252 | |||
253 | /* Interrupt handler */ | 199 | /* Interrupt handler */ |
254 | void SADC(void) | 200 | void 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 | } |