What do you want to achieve?
I have 2 buttons on my UI (Turn led on & Turn Led Off) in the generated ui_events.c file there is a pre-defined section for both button call function events with a section of commented out code saying “Your code here” when i place code here nothing happens and I get compile errors in the IDE
What have you tried so far?
Read multiple forums (here & lvgl) and searched multiple video tutorials
Hardware Etc
M5StackDial (ESP32)
Arduino IDE 2.3.4
ui_events.c
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.5.1
// LVGL version: 8.3.11
// Project name: SquareLine_Project
#include "ui.h"
void turnledon(lv_event_t * e)
{
// Your code here
digitalWrite(ledpin, HIGH);
}
void turnledoff(lv_event_t * e)
{
// Your code here
digitalWrite(ledpin, LOW);
}
ui.c
///////////////////// FUNCTIONS ////////////////////
void ui_event_Button1(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
if(event_code == LV_EVENT_PRESSED) {
turnledon(e);
}
}
void ui_event_Button2(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
if(event_code == LV_EVENT_PRESSED) {
turnledoff(e);
}
}
SimpleLed.ino
#include "Display_ST7789.h"
#include "LVGL_Driver.h"
#include "ui.h"
int ledpin = 9;
void setup()
{
LCD_Init();
Lvgl_Init();
ui_init();
pinMode(ledpin, OUTPUT);
}
void loop()
{
Timer_Loop();
delay(5);
}
Compilation Errors
C:\Users\innovatum\Desktop\SimpleLed\ui_events.c: In function 'turnledon':
C:\Users\innovatum\Desktop\SimpleLed\ui_events.c:11:16: error: 'ledpin' undeclared (first use in this function)
11 | digitalWrite(ledpin, HIGH);
| ^~~~~~
C:\Users\innovatum\Desktop\SimpleLed\ui_events.c:11:16: note: each undeclared identifier is reported only once for each function it appears in
C:\Users\innovatum\Desktop\SimpleLed\ui_events.c: In function 'turnledoff':
C:\Users\innovatum\Desktop\SimpleLed\ui_events.c:17:16: error: 'ledpin' undeclared (first use in this function)
17 | digitalWrite(ledpin, LOW);
| ^~~~~~
exit status 1
Compilation error: 'ledpin' undeclared (first use in this function)