What MCU/Processor/Board and compiler are you using?
ESP32 WT32-SC01 touch screen
What LVGL version are you using?
V8.3
What do you want to achieve?
Change images between released/pressed one same button. Which is: when not pressing any button, the image button shows RPLAY_N, when pressed, shows RPLAY_P constantly.
What have you tried so far?
One more question: The possible states are:
LV_IMGBTN_STATE_RELEASED
LV_IMGBTN_STATE_PRESSED
LV_IMGBTN_STATE_DISABLED
LV_IMGBTN_STATE_CHECKED_RELEASED
LV_IMGBTN_STATE_CHECKED_PRESSED
LV_IMGBTN_STATE_CHECKED_DISABLED
I do not understand the difference between former 3 states and later 3?? What exactly does āCHECKEDā mean?
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The documentation you have linked to is for version 7.11 and not 8.3. You need to change what version of the documentation you are using, that can be done at the top left of the webpage.
Pls see attached code in the first post. My purpose is to show pic1, when clicking it, it shows me the other image and keeps the pic. I have example code in V7.1 but no example code in v8.3. The code in V7.1 does not work in V8.3. Pls help!
The checked states are when you enable the ācheck-ableā flag which means when you click the button it stays in a pressed state until you press it again and then it will be unpressed again if that makes sense? In other words you can toggle the state of the button by clicking itā¦
To enable this in version 8 you can try this with your code snippet, (it may or maynot work):
(NOTE: I have changed the referenced images from your original)
Thanks Pete! I noticed you added the last line to my code. My test shows when I touch and press the button, the button can change to the other pic; however, when I stop touching, the button return to the original pic, cannot constantly show the second pic. Now my solution is adding the pic change in the buttonās event handler, when hit the button, the handler will change the image to be the second one. Although I didnāt implement it like the example in V7.1 but it now works for me. Let me know if you have any other idea, I would like to implement it in other ways.
Your work around is fine and will not cause any issues I can think of⦠it will be okay for the time being I am sure.
It does seem to me there may be a bug in the image button which is causing it not to respect the LV_OBJ_FLAG_CHECKABLE flag. I have looked into it, but I have not found the issue yet I will continue to investigate, but I am out of time right now. I will let you know when I have taken a further look.
I have also raised this as an issue on github here so others can take a look if they get timeā¦
Thanks a lot! If I need the button to do something else, like turn on a GPIO, the handler is still needed, right?
Now I have another issue. I created an image button DSL on GUI, it works well. Then I added another one DOLBY by same method, my screen just flash and nothing appears. Resource 20% RAM is used, 52% of flash is used so far. Pls help.
Each button image is 211KB with TRUE color, c format. Iāll have 17 imgbtns. Several images will fill all 512KB RAM of ESP32. Therefore, I tried converting images to TRUE_color Binary RGB332 but screen only shows me half grey box. Tried all other formats, neither worked for me. Iām looking for an efficient BIN format to reduce RAM occupation while work with imgbtn. Pls help!