Description
unable to execute call function event in ui_events.c
What MCU/Processor/Board and compiler are you using?
ESP32_C6 with Arduino IDE 2.3.4
What LVGL version are you using?
8.3.11
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
have tried lots of “includes” but all to no avail so thought best to ask the community rather than trying to guess and get lucky after 3 days.
Not entirely sure if this is a SquareLine issue or an LVGL issue, thinking about it now.
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)
I did see other posts relating to this being a “feature update” that would be added later to allow this to work with the arduino IDE but as those posts were older than a year I am assuming this feature to be implemented. Any help would be much appreciated and if it can be in fairly lay terms that would be even better thanks.