I’m new to LVGL, and I’m trying to do something with ESP32 and SquareLine Studio.
at now i create a little ui with some buttons. I would like to start some functions depending on the key I press. to lunch or not the functions i’m using boolen variables like in the example below.
how i can change the value of the variable from an button event (in ui_event.c) to change the running functions
thanks for your help
in ui.ino
bool VAR=false;
void setup() {
...bla bla..
}
void loop() {
if (VAR) function 1
else function 2
}
in ui_event.c
void StartFunction(lv_event_t * e){
lv_label_set_text(ui_Label13, "PRESSED");
if (!VAL) VAL=true; // the pressure of the button changes the VAL value like a toggle button
else VAL=false;
}
Well I’m no expert and while I could tell you several ways to do this - they are likely wrong, but you probably don’t really need a variable - you can just do something like this in your ui.ino
if(lv_label_get_text(ui_Label13) == "PRESSED")
// do something
else
// do something else
static bool VAL = false;
bool getVAL(void);
bool getVAL(void)
{
return VAL;
}
void StartFunction(lv_event_t * e)
{
lv_label_set_text(ui_Label13, "PRESSED");
if (!VAL) VAL=true; // the pressure of the button changes the VAL value like a toggle button
else VAL=false;
}