How to prevent button from changing state after long press

Description

How to prevent button from changing state after long press?

What LVGL version are you using?

8.2 in combination with SquareLine Studio

What do you want to achieve?

A button which can be used to switch on and off a lamp. But when long pressed enable e.g. brightness control. But after the long press the button state should not change.

I have faced the same issue on my hardware TFT project with my custom board design from SquareLine studio project.

I have solved the issue by writing my own touch device call back function — touchpad_read() as below.

static void touchpad_read(lv_indev_drv_t *indev_drv, lv_indev_data_t data)
{
uint8_t touchpad_cnt = 0;
static uint8_t prvStat = LV_INDEV_STATE_RELEASED;
/Read touch controller is ready or not/
if (touch controller is ready)
{
/
Read data from touch controller */
if (touch found)
{
data->point.x = xdata;
data->point.y = ydata;
data->state = LV_INDEV_STATE_PRESSED;
prvStat = LV_INDEV_STATE_PRESSED;
}
else
{
data->state = LV_INDEV_STATE_RELEASED;
prvStat = LV_INDEV_STATE_RELEASED;
}
}
else{
//touch controller new data is not ready continue with previous state
data->state = prvStat;
}
}