What do you want to achieve?
Get a button to toggle a Boolean in Arduino
What have you tried so far?
I have got the project to export and compile in Arduino and I have got the WT911 touch controller to work. I can click buttons and move through the various screens but I have no idea how to get the GUI buttons to interact with an Arduino variable. Am I missing something in the Events section? Any pointer or links to a tutorial would be very much appreciated.
Screenshot or video
- **SquareLine Studio version: 1.3.2
- **Operating system: Win 11
- **Target hardware: esp32-3248s035C 320x480 WT911 capacitive touch
to every event you can add the action CALL FUNCTION. This will be exported by default in the file ui_events.h and ui_events.c(pp). You can change how it is exported in the settings. You can decide to not export the .c(pp) at all. Then you can just define the function in your arduino main file. In the exported C files you can import Arduino or anything else you need to make the functions work.
Else you just import the ui_events.h into your main sketch and define the functions there.
I am in Platfrom IO and use Arduino Framework and this how you can switch a GPIO pin on and of. This is the content of the ui_events.cpp.
void TurnLightOnOff(lv_event_t *e)
static bool relay_status = false; //Static so it doesnt changes with every function call and is only initilized once
lv_event_code_t code = lv_event_get_code(e);
// Serial.printf(“Relay Status: %d\n”, relay_status);
relay_status = false;
relay_status = true;
Also good resources are the youtube tutorials, this one on events:
This is the docs on the topic:
Primary reply to your question is you dont require bool. Every object (except temporary screens) is always in memory and your arduino or other code need only ask value. For example checked not checked etc. For control your code you can copy values to next variables, but many times isnt required.
For example slider or arc value can be used directly in code… But code is your job.