Added a function in the lvgl input device binding file to be able to know if the touch screen was touched or not

This commit is contained in:
anschrammh 2023-04-13 13:37:50 +02:00
parent c885568e34
commit 82ad6d16ba
2 changed files with 27 additions and 0 deletions

View File

@ -36,6 +36,8 @@ static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
* STATIC VARIABLES
**********************/
static lv_indev_t * indev_touchpad;
static bool _indev_touched = false;
/**********************
* MACROS
@ -49,6 +51,7 @@ static void touch_panel_isr(void *arg)
CST816D_Touch_Data_t *p = arg;
tls_clr_gpio_irq_status(LCD_TOUCH_PANEL_IRQ);
CST816D_read_touch_event(p);
_indev_touched = true;
}
static void touch_panel_feedback_cb(struct _lv_indev_drv_t *lv_indev_drv, uint8_t lv_event_code)
@ -112,6 +115,17 @@ void lv_port_indev_init(void)
indev_touchpad = lv_indev_drv_register(&indev_drv);
}
bool lv_port_indev_touched(void)
{
if(_indev_touched)
{
_indev_touched = false;
return true;
}
return false;
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -30,8 +30,21 @@ extern "C" {
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* @brief Initializes the input device for LVGL to use.
*
*/
void lv_port_indev_init(void);
/**
* @brief Checks if the input device registered a touch event or not.
*
* @return true if a touch event was registered, the event is cleared once the function is called.
* @return false if not
*/
bool lv_port_indev_touched(void);
/**********************
* MACROS
**********************/