On page 103 of the LVGL-build-GUI’s course there is the sentence “LV_EVENT_LONG_PRESSED: the object has been pressed for at least long_press_time.”
I understand that with this value i can define how long to press the button on screen before it is classified as a long press.
My problem is that i can not find the “long_press_time” value in the sketch.
Hi.
That’s a great question.
To find out, we need to dig into the LVGL documentation:
From that page, if you search for “long_press_time”, we can see that to define and use the long_press_time for an input device in LVGL, you need to configure the lv_indev_t structure’s long_press_time parameter.
So, in the setup(), we can define that parameter after initializing the LVGL input device (after these lines):
// Initialize an LVGL input device object (Touchscreen) lv_indev_t * indev = lv_indev_create(); lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
Since the long_press_time is a parameter of the lv_indev_t structure (now created as indev), we can set it as follows:
indev->long_press_time = 2000; /* Set long press time to 2000 ms */
Adjust for your desired time.
If you need information about any LVGL function, variable, or parameter, you just need to search for it here:
In this case, I’m setting the search for the long_press_time parameter.
I hope this helps, and I’m sorry for the delay in my response.
Regards,
Sara
Hi Sara,
Thanks for the answer. I was under the impression that the long_press_time was already inside the sketch. But now i understand i had to search the LVGL lib. Great answer. Somewhat complicated for me because i am a relative newby, but it gives me some grip.
Regards,
Martin