0xPIT
January 5, 2025, 9:13pm
1
Description
I use a button to react on press and release only.
This is to implement a “manual activation” mode by enabling some GPIO only while that button is pressed/held .
I’ve tried the PRESSED/RELEASED/LONG_PRESSED_REPEAT events, and the events are repeated while I hold the button → I’d expect one PRESSED and one RELEASED only.
Logging lv_event_get_code(e)
on a widget that has 1 callback for the 3 events mentioned:
1
8
1
8
1
8
1
6
8
1
8
1
8
1
8
...
What MCU/Processor/Board and compiler are you using?
ESP32-S3 ESP-BOX 1.0 with esp-idf; UI created by SquareLine studio
What LVGL version are you using?
9.2.2
What do you want to achieve?
I’d like to create a button that turns on a GPIO only while it is held pressed.
What have you tried so far?
Attaching mentioned events to arbitrary widget types and tracing lv_event_get_code(e)
, all with the same results as mentioned above.
You might be looking for LV_EVENT_SHORT_CLICKED
and LV_EVENT_LONG_PRESSED
.
You should get only one of either event, not both and not repeated.
If that does not solve the issue, then the code that generates the event (lv_indev driver?) possibly has a bug.
0xPIT
January 6, 2025, 7:53am
3
Thanks for you reply!
I will investigate.
How would I detect the finger being lifted with just those two?
Would be weird needing to implement some manual timeout & event counting…
The short click one only triggers when lifting the finger, but long-press by design triggers as your finger is still down, so you’d likely have to write some state machine code and tie events together. (e.g. with LV_EVENT_RELEASED)
0xPIT
January 6, 2025, 8:40am
5
Hm, does not seem to work as suspected.
Below is a trace of pressing my finger once and then releasing for all input device events.
I’ve also added a style color for focussed
and pressed
: while holding my finger, a flicker between them is observable.
I have several other guy buttons and they seem to work fine.
Trace: (mind the “manual grind” → this is for a coffee mill)
Manual grind LV_EVENT_HOVER_OVER
Manual grind LV_EVENT_PRESSED
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_RELEASED
Manual grind LV_EVENT_SHORT_CLICKED
Manual grind LV_EVENT_CLICKED
Manual grind LV_EVENT_HOVER_OVER
Manual grind LV_EVENT_PRESSED
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_RELEASED
Manual grind LV_EVENT_SHORT_CLICKED
Manual grind LV_EVENT_CLICKED
Manual grind LV_EVENT_HOVER_OVER
Manual grind LV_EVENT_PRESSED
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_LONG_PRESSED
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_LONG_PRESSED_REPEAT
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_LONG_PRESSED_REPEAT
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_LONG_PRESSED_REPEAT
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_LONG_PRESSED_REPEAT
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_LONG_PRESSED_REPEAT
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_RELEASED
Manual grind LV_EVENT_CLICKED
Manual grind LV_EVENT_HOVER_OVER
Manual grind LV_EVENT_PRESSED
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_RELEASED
Manual grind LV_EVENT_SHORT_CLICKED
Manual grind LV_EVENT_CLICKED
Manual grind LV_EVENT_HOVER_OVER
Manual grind LV_EVENT_PRESSED
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_RELEASED
Manual grind LV_EVENT_SHORT_CLICKED
Manual grind LV_EVENT_CLICKED
Manual grind LV_EVENT_HOVER_OVER
Manual grind LV_EVENT_PRESSED
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_PRESSING
Manual grind LV_EVENT_RELEASED
Manual grind LV_EVENT_SHORT_CLICKED
Manual grind LV_EVENT_CLICKED
Could it be an electrical connection issue? Perhaps you can try a different switch or just bridge the connections for a test?
0xPIT
January 7, 2025, 8:25pm
7
No, the touch works fine elsewhere.
I got it mostly working by just using the CLICKED event, but it’s still somewhat flaky if you move the finger.
I’ve just published the thing, so you can see the code here:
Espresso Mill Controller based on ESP32 & LVGL Touchscreen
Thanks for your help.
bahaman
January 13, 2025, 11:11am
8
try reducing the i2c frequency to 100000 (or whatever freq. the specific touch controller needs).