diff options
Diffstat (limited to 'firmware/target/mips/ingenic_x1000')
3 files changed, 82 insertions, 12 deletions
diff --git a/firmware/target/mips/ingenic_x1000/debug-x1000.c b/firmware/target/mips/ingenic_x1000/debug-x1000.c index 1965b0b74e..98b8f95fb5 100644 --- a/firmware/target/mips/ingenic_x1000/debug-x1000.c +++ b/firmware/target/mips/ingenic_x1000/debug-x1000.c | |||
@@ -149,6 +149,9 @@ static bool dbg_cpuidle(void) | |||
149 | #ifdef FIIO_M3K | 149 | #ifdef FIIO_M3K |
150 | extern bool dbg_fiiom3k_touchpad(void); | 150 | extern bool dbg_fiiom3k_touchpad(void); |
151 | #endif | 151 | #endif |
152 | #ifdef SHANLING_Q1 | ||
153 | extern bool dbg_shanlingq1_touchscreen(void); | ||
154 | #endif | ||
152 | #ifdef HAVE_AXP_PMU | 155 | #ifdef HAVE_AXP_PMU |
153 | extern bool axp_debug_menu(void); | 156 | extern bool axp_debug_menu(void); |
154 | #endif | 157 | #endif |
@@ -170,6 +173,9 @@ static const struct { | |||
170 | #ifdef FIIO_M3K | 173 | #ifdef FIIO_M3K |
171 | {"Touchpad", &dbg_fiiom3k_touchpad}, | 174 | {"Touchpad", &dbg_fiiom3k_touchpad}, |
172 | #endif | 175 | #endif |
176 | #ifdef SHANLING_Q1 | ||
177 | {"Touchscreen", &dbg_shanlingq1_touchscreen}, | ||
178 | #endif | ||
173 | #ifdef HAVE_AXP_PMU | 179 | #ifdef HAVE_AXP_PMU |
174 | {"Power stats", &axp_debug_menu}, | 180 | {"Power stats", &axp_debug_menu}, |
175 | #endif | 181 | #endif |
diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c index 04e3102d42..24daf2ef69 100644 --- a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c +++ b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c | |||
@@ -318,7 +318,7 @@ static void ft_step_state(uint32_t t, int evt, int tx, int ty) | |||
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | static void ft_event_cb(int evt, int tx, int ty) | 321 | static void ft_event_cb(struct ft6x06_state* state) |
322 | { | 322 | { |
323 | /* TODO: convert the touch positions to linear positions. | 323 | /* TODO: convert the touch positions to linear positions. |
324 | * | 324 | * |
@@ -327,7 +327,8 @@ static void ft_event_cb(int evt, int tx, int ty) | |||
327 | * the middle of the touchpad than on the edges, so scrolling feels slow | 327 | * the middle of the touchpad than on the edges, so scrolling feels slow |
328 | * in the middle and faster near the edge. | 328 | * in the middle and faster near the edge. |
329 | */ | 329 | */ |
330 | ft_step_state(__ost_read32(), evt, tx, ty); | 330 | struct ft6x06_point* pt = &state->points[0]; |
331 | ft_step_state(__ost_read32(), pt->event, pt->pos_x, pt->pos_y); | ||
331 | } | 332 | } |
332 | 333 | ||
333 | static void ft_init(void) | 334 | static void ft_init(void) |
diff --git a/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c b/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c index 27c49a7bd7..13b0cdd078 100644 --- a/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c +++ b/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c | |||
@@ -32,6 +32,11 @@ | |||
32 | #include "i2c-x1000.h" | 32 | #include "i2c-x1000.h" |
33 | #include <stdbool.h> | 33 | #include <stdbool.h> |
34 | 34 | ||
35 | #ifndef BOOTLOADER | ||
36 | # include "lcd.h" | ||
37 | # include "font.h" | ||
38 | #endif | ||
39 | |||
35 | /* Volume wheel rotation */ | 40 | /* Volume wheel rotation */ |
36 | static volatile int wheel_pos = 0; | 41 | static volatile int wheel_pos = 0; |
37 | 42 | ||
@@ -109,6 +114,7 @@ void button_init_device(void) | |||
109 | 114 | ||
110 | int button_read_device(int* data) | 115 | int button_read_device(int* data) |
111 | { | 116 | { |
117 | const struct ft6x06_point* point; | ||
112 | int r = 0; | 118 | int r = 0; |
113 | 119 | ||
114 | /* Read GPIO buttons, these are all active low */ | 120 | /* Read GPIO buttons, these are all active low */ |
@@ -138,16 +144,22 @@ int button_read_device(int* data) | |||
138 | reset_poweroff_timer(); | 144 | reset_poweroff_timer(); |
139 | } | 145 | } |
140 | 146 | ||
141 | /* Handle touchscreen | 147 | if(touchscreen_get_mode() == TOUCHSCREEN_POINT) { |
142 | * | 148 | /* Pointing mode can't use multitouch since we can only pass |
143 | * TODO: Support 2-point multitouch (useful for 3x3 grid mode) | 149 | * along coordinates for one touch event at a time */ |
144 | * TODO: Support simple gestures by converting them to fake buttons | 150 | point = &ft6x06_state.points[0]; |
145 | */ | 151 | int t = touchscreen_to_pixels(point->pos_x, point->pos_y, data); |
146 | int t = touchscreen_to_pixels(ft6x06_state.pos_x, ft6x06_state.pos_y, data); | 152 | if(point->event == FT6x06_EVT_PRESS || |
147 | if(ft6x06_state.event == FT6x06_EVT_PRESS || | 153 | point->event == FT6x06_EVT_CONTACT) |
148 | ft6x06_state.event == FT6x06_EVT_CONTACT) { | 154 | r |= t; |
149 | /* Only set the button bit if the screen is being touched. */ | 155 | } else { |
150 | r |= t; | 156 | /* 3x3 mode can have simultaneous 'button' presses via multitouch */ |
157 | for(int i = 0; i < ft6x06_state.nr_points; ++i) { | ||
158 | point = &ft6x06_state.points[i]; | ||
159 | if(point->event == FT6x06_EVT_PRESS || | ||
160 | point->event == FT6x06_EVT_CONTACT) | ||
161 | r |= touchscreen_to_pixels(point->pos_x, point->pos_y, NULL); | ||
162 | } | ||
151 | } | 163 | } |
152 | 164 | ||
153 | return r; | 165 | return r; |
@@ -193,3 +205,54 @@ void GPIOD03(void) | |||
193 | handle_wheel_irq(); | 205 | handle_wheel_irq(); |
194 | gpio_flip_edge_irq(GPIO_WHEEL2); | 206 | gpio_flip_edge_irq(GPIO_WHEEL2); |
195 | } | 207 | } |
208 | |||
209 | #ifndef BOOTLOADER | ||
210 | static int getbtn(void) | ||
211 | { | ||
212 | int btn; | ||
213 | do { | ||
214 | btn = button_get_w_tmo(1); | ||
215 | } while(btn & (BUTTON_REL|BUTTON_REPEAT)); | ||
216 | return btn; | ||
217 | } | ||
218 | |||
219 | bool dbg_shanlingq1_touchscreen(void) | ||
220 | { | ||
221 | /* definition of box used to represent the touchpad */ | ||
222 | const int pad_w = LCD_WIDTH; | ||
223 | const int pad_h = LCD_HEIGHT; | ||
224 | const int box_h = pad_h - SYSFONT_HEIGHT*5; | ||
225 | const int box_w = pad_w * box_h / pad_h; | ||
226 | const int box_x = (LCD_WIDTH - box_w) / 2; | ||
227 | const int box_y = SYSFONT_HEIGHT * 9 / 2; | ||
228 | |||
229 | bool draw_border = true; | ||
230 | |||
231 | do { | ||
232 | int line = 0; | ||
233 | lcd_clear_display(); | ||
234 | lcd_putsf(0, line++, "nr_points: %d gesture: %d", | ||
235 | ft6x06_state.nr_points, ft6x06_state.gesture); | ||
236 | |||
237 | /* draw touchpad box borders */ | ||
238 | if(draw_border) | ||
239 | lcd_drawrect(box_x, box_y, box_w, box_h); | ||
240 | |||
241 | for(int i = 0; i < ft6x06_state.nr_points; ++i) { | ||
242 | const struct ft6x06_point* point = &ft6x06_state.points[i]; | ||
243 | lcd_putsf(0, line++, "pt%d id:%d pos: %d,%d wgt: %d area:%d", | ||
244 | i, point->touch_id, point->pos_x, point->pos_y, | ||
245 | point->weight, point->area); | ||
246 | |||
247 | /* draw crosshair */ | ||
248 | int tx = box_x + point->pos_x * box_w / pad_w; | ||
249 | int ty = box_y + point->pos_y * box_h / pad_h; | ||
250 | lcd_hline(tx-2, tx+2, ty); | ||
251 | lcd_vline(tx, ty-2, ty+2); | ||
252 | } | ||
253 | |||
254 | lcd_update(); | ||
255 | } while(getbtn() != BUTTON_POWER); | ||
256 | return false; | ||
257 | } | ||
258 | #endif | ||