Description
I’ve created a load of UI buttons and got a fully working UI.
I want to use the state of those buttons in an array, to match up with my other arrays of things like motors and so on. I’m trying to create pointers to the button states in an array by doing this:
short unsigned int* SelArr[box_count] = { &ui_box01button->state, &ui_box02button->state, &ui_box03button->state, &ui_box04button->state, &ui_box05button->state, &ui_box06button->state, &ui_box07button->state, &ui_box08button->state };
While this compiles it doesn’t work, just giving me the value 43425 for every button no matter what state it’s in.
I’m right at the absolute limits of my C++ capabilities here and I suspect I’m somehow addressing things in the wrong way.
What I want to achieve:
An array with the states of the buttons by directly accessing their states via the array.
What I’ve done so far:
I did a bit of a clunky stuff of values into an array every loop. While this works it sort of feels a bit wrong to have to run this every loop when I only really need to access the states of the buttons on an occasional basis.
sel[0] = (lv_obj_has_state(ui_box01button, LV_STATE_CHECKED) == true);
sel[1] = (lv_obj_has_state(ui_box02button, LV_STATE_CHECKED) == true);
sel[2] = (lv_obj_has_state(ui_box03button, LV_STATE_CHECKED) == true);
sel[3] = (lv_obj_has_state(ui_box04button, LV_STATE_CHECKED) == true);
sel[4] = (lv_obj_has_state(ui_box05button, LV_STATE_CHECKED) == true);
sel[5] = (lv_obj_has_state(ui_box06button, LV_STATE_CHECKED) == true);
sel[6] = (lv_obj_has_state(ui_box07button, LV_STATE_CHECKED) == true);
sel[7] = (lv_obj_has_state(ui_box08button, LV_STATE_CHECKED) == true);
Any help with this would be greatly appreciated!
What MCU/Processor/Board and compiler are you using?
Arduino Giga
What LVGL version are you using?
8.4