Add mgos_stmpe610_is_touched() to let callers know if the user is pressing the screen at this moment

This commit is contained in:
Pim van Pelt
2017-11-28 15:57:59 +01:00
parent 1ef7195728
commit af23ddee37
2 changed files with 11 additions and 0 deletions

View File

@ -131,5 +131,6 @@ bool mgos_stmpe610_init(void);
typedef void (*mgos_stmpe610_event_t)(struct mgos_stmpe610_event_data *); typedef void (*mgos_stmpe610_event_t)(struct mgos_stmpe610_event_data *);
void mgos_stmpe610_set_handler(mgos_stmpe610_event_t handler); void mgos_stmpe610_set_handler(mgos_stmpe610_event_t handler);
void mgos_stmpe610_set_rotation(enum mgos_stmpe610_rotation_t rotation); void mgos_stmpe610_set_rotation(enum mgos_stmpe610_rotation_t rotation);
bool mgos_stmpe610_is_touching();
#endif // __STMPE610H_ #endif // __STMPE610H_

View File

@ -222,6 +222,9 @@ void mgos_stmpe610_set_rotation(enum mgos_stmpe610_rotation_t rotation) {
s_rotation = rotation; s_rotation = rotation;
} }
bool mgos_stmpe610_is_touching() {
return s_last_touch.direction == TOUCH_DOWN;
}
bool mgos_stmpe610_init(void) { bool mgos_stmpe610_init(void) {
esp_err_t ret; esp_err_t ret;
@ -287,5 +290,12 @@ bool mgos_stmpe610_init(void) {
mgos_gpio_set_pull(mgos_sys_config_get_stmpe610_irq_pin(), MGOS_GPIO_PULL_UP); mgos_gpio_set_pull(mgos_sys_config_get_stmpe610_irq_pin(), MGOS_GPIO_PULL_UP);
mgos_gpio_set_int_handler(mgos_sys_config_get_stmpe610_irq_pin(), MGOS_GPIO_INT_EDGE_NEG, stmpe610_irq, NULL); mgos_gpio_set_int_handler(mgos_sys_config_get_stmpe610_irq_pin(), MGOS_GPIO_INT_EDGE_NEG, stmpe610_irq, NULL);
mgos_gpio_enable_int(mgos_sys_config_get_stmpe610_irq_pin()); mgos_gpio_enable_int(mgos_sys_config_get_stmpe610_irq_pin());
// Initialize the last touch to TOUCH_UP
s_last_touch.direction=TOUCH_UP;
s_last_touch.x=0;
s_last_touch.y=0;
s_last_touch.z=0;
s_last_touch.length=0;
return true; return true;
} }