How to pass value from ui_events to ui.ino

Hey everyone!

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

or how about this:
ui.ino

void setup()
{
	//...bla bla..
}
void loop() 
{
	if(getVAL())
		//function 1
	else
		//function 2
}

ui_event.c

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; 
}

YEAAAHHHHHH thanks a lot… WoRKS

works this way too, but I prefer the first solution. probably more academic

thank you very much for your help.