Has anybody figured out a way to deal with lvgl.checkboxes. They are easy to tick but changing their state and reading their state is more than a little troublesome.
I have tried lvgl.get_state and lvgl.set_state and they certainly work but the values that are returned are boolean and I have tried bitwise operations and I have found no reliable way to set and unset the checks (ticks) or to read a true or false from the tick on screen. These operations are in c++ lvgl but I have not found it in Annex32. I have also tried lvgl.get_value but this does not apply to checkboxes:
Arguments:
● obj: Object to get value for.
○ For Slider: Get the value.
○ For Arc: Get the value.
○ For Bar: Get the value.
○ For Led: Get the brightness.
○ For Roller: Get the index of the selected option.
○ For Dropdown: Get the index of the selected option.
○ For ImageButton: Get the state.
○ For Keyboard: Get the index of the last "activated" key by the user (pressed, released, focused, etc.).
○ For ButtonMatrix: Get the index of the last "activated" button by the user (pressed, released, focused, etc.).
Return: Value of the object.
I have tried the following (for four checkboxes):
A2$ = checkbox$(cbx1) which reveals a lengthy sentence but does not indicate a checked or unchecked state. No matter what it always comes back with a checked state whether it has a tick or not
A2 = lvgl.get_state cbx1
B2 = lvgl.get_state cbx2
C2 = lvgl.get_state cbx3
D2 = lvgl.get_state cbx4 The come back with values from 19 to 16 depending on the state of the tick but not a consistent value sometimes it is a 16 or 17 and when ticked 18/19 but sometimes a 17
Applying the bitwise 4 shift it comes up with a 1 or zero but even this is inconsistent
A2 = A2 >> 4
B2 = B2 >> 4
C2 = C2 >> 4
D2 = D2 >> 4
I have tried to get a true or false from all matter of commands but I have not found it.
Does anybody know how to reliably read a true/false or on/off from a checkbox? I am going crazy trying to execute what should be a straightforward procedure. I will not be insulted if it is something really easy - that would be great.
LVGL Checkboxes in ANNEX32
-
- Posts: 123
- Joined: Mon Feb 27, 2023 12:56 pm
- Location: Berlin
- Has thanked: 41 times
- Been thanked: 22 times
Re: LVGL Checkboxes in ANNEX32
versuche das hier.
LVGL.HAS_STATE(obj, state) : Checks if the specified state (or combination of states) is set on the object.
Wetere Infos findest du in dem Tutorial von Francesco (switch,radio button, Checkbox)
LVGL.HAS_STATE(obj, state) : Checks if the specified state (or combination of states) is set on the object.
Wetere Infos findest du in dem Tutorial von Francesco (switch,radio button, Checkbox)
- cicciocb
- Site Admin
- Posts: 3237
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 645 times
- Been thanked: 2281 times
- Contact:
Re: LVGL Checkboxes in ANNEX32
The checked state is LV_STATE_CHECKED 0x0001
As explained in the tutorial, you can use LVGL.HAS_STATE of, if you want use LVGL.SET_STATE;
In this case you can do
so is just the bit 0 that give the checked/unchecked state.As explained in the tutorial, you can use LVGL.HAS_STATE of, if you want use LVGL.SET_STATE;
In this case you can do
Code: [Local Link Removed for Guests]
val = LVGL.GET_STATE obj
checked = val and &h0001
or
checked = (LVGL.GET_STATE obj) and 1
You do not have the required permissions to view the files attached to this post.
- Starraker
- Posts: 158
- Joined: Tue Sep 03, 2024 1:53 am
- Location: Canberra Australia
- Been thanked: 45 times
- Contact:
Re: LVGL Checkboxes in ANNEX32
Monki and Francesco,
I was ripping my hair out and I forgot to check CiCCIOCB's LVGL Addendum notes. Gives you some idea of where I was at. Thank you both.
Simple as expected!! I guess that setting the state is as easy.
I was ripping my hair out and I forgot to check CiCCIOCB's LVGL Addendum notes. Gives you some idea of where I was at. Thank you both.
Simple as expected!! I guess that setting the state is as easy.
- cicciocb
- Site Admin
- Posts: 3237
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 645 times
- Been thanked: 2281 times
- Contact:
Re: LVGL Checkboxes in ANNEX32
I can add this in the LVGL.GET_VALUE and LVGL.SET_VALUE, probably is much simpler.
In this case these functions will be almost applicable for all the objects
In this case these functions will be almost applicable for all the objects
- Starraker
- Posts: 158
- Joined: Tue Sep 03, 2024 1:53 am
- Location: Canberra Australia
- Been thanked: 45 times
- Contact:
Re: LVGL Checkboxes in ANNEX32
Francesco,
These were the functions I thought of first but soon discovered that they did not work (the start of ripping out of hair).
However, if the value is revealed ( by, in my case, the lvgl.get_state function ) the number comes back as 16, 17, 18, 19 (depending on circumstance). So when you implement the changes, it would be better to be on/off or true/false as that is the only purpose for checkboxes.
The state commands can then be used for those other uses.
Paul
These were the functions I thought of first but soon discovered that they did not work (the start of ripping out of hair).
However, if the value is revealed ( by, in my case, the lvgl.get_state function ) the number comes back as 16, 17, 18, 19 (depending on circumstance). So when you implement the changes, it would be better to be on/off or true/false as that is the only purpose for checkboxes.
The state commands can then be used for those other uses.
Paul