How to change the state of a button.
What MCU/Processor/Board and compiler are you using?
ESP32, WT32-SC01, SquareLine Studio + PlatformIO + Arduino Framework
What LVGL version are you using?
What do you want to achieve?
Change the state of a button.
What have you tried so far?
Tried the following functions, but none of them are accepted:
Code to reproduce
Could not find anything which worked.
April 3, 2023, 4:26pm
When you say set the state do you mean enable/disable it?
I think it is called CHECKED and RELEASED.
I can get the status using
But trying to change the state using
lv_obj_set_state results in
not declared in this scope.
April 3, 2023, 6:59pm
What are you trying to achieve?
I have a button which can control a lamp through MQTT.
But this lamp can also be controlled by a different controller through MQTT.
So if the state of the lamp changes by a different controller, this should be reflected by the state of the button.
April 3, 2023, 7:27pm
Can you share any code or screenshots?
It sounds like you need a switch instead of a button.
If I would use a switch, how do I change its state?
April 3, 2023, 8:58pm
April 4, 2023, 11:39am
I think function “lv_obj_add_state(obj*,state)” would work ,state can be any thing like LV_STATE_PRESSED
you can refer Link-
Objects — LVGL documentation
I can set and reset the buttons state with