Reputation: 25927
I'm implementing a sample application on SeeedStudio's Wio Terminal with LVGL. I followed the LVGL's porting tutorial and came up with the following:
#include "lib\lvgl\lvgl.h"
#include <SAMDTimerInterrupt.h>
#include <SAMD_ISR_Timer.h>
#include <TFT_eSPI.h>
// Defines --------------------------------------------------------------------
#define DISPLAY_WIDTH (320)
#define DISPLAY_HEIGHT (240)
#define LVGL_TICK_PERIOD_MS (5)
// Public variables -----------------------------------------------------------
// TFT
TFT_eSPI tft;
// LVGL
lv_disp_draw_buf_t lvgl_disp_buf;
lv_color_t lvgl_buffer_1[DISPLAY_WIDTH * 10];
lv_color_t lvgl_buffer_2[DISPLAY_WIDTH * 10];
lv_disp_drv_t lvgl_disp_drv;
lv_disp_t * lvgl_disp;
lv_obj_t * screen;
lv_obj_t * button;
lv_obj_t * label;
// Timer
SAMDTimer lvgl_timer(TIMER_TC3);
// Public functions -----------------------------------------------------------
void lvgl_flushDisplay(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
uint16_t c;
tft.startWrite(); /* Start new TFT transaction */
tft.setAddrWindow(area->x1, area->y1, (area->x2 - area->x1 + 1), (area->y2 - area->y1 + 1)); /* set the working window */
for (int y = area->y1; y <= area->y2; y++)
{
for (int x = area->x1; x <= area->x2; x++)
{
c = color_p->full;
tft.writeColor(c, 1);
color_p++;
}
}
tft.endWrite(); /* terminate TFT transaction */
lv_disp_flush_ready(disp); /* tell lvgl that flushing is done */
}
void lvgl_tick()
{
lv_tick_inc(LVGL_TICK_PERIOD_MS);
}
// Arduino core functions -----------------------------------------------------
void setup()
{
Serial.begin(9600); /* prepare for possible serial debug */
// Initialize TFT
tft = TFT_eSPI();
tft.begin();
tft.setRotation(3);
// Initialize LVGL
lv_init();
lv_disp_draw_buf_init(&lvgl_disp_buf, lvgl_buffer_1, lvgl_buffer_2, DISPLAY_WIDTH * 10);
lv_disp_drv_init(&lvgl_disp_drv);
lvgl_disp_drv.draw_buf = &lvgl_disp_buf;
lvgl_disp_drv.hor_res = DISPLAY_WIDTH;
lvgl_disp_drv.ver_res = DISPLAY_HEIGHT;
lvgl_disp_drv.flush_cb = lvgl_flushDisplay;
lvgl_disp = lv_disp_drv_register(&lvgl_disp_drv);
// Initialize timer for LVGL
lvgl_timer.attachInterruptInterval(LVGL_TICK_PERIOD_MS * 1000, lvgl_tick);
// Test interface
screen = lv_obj_create(nullptr);
button = lv_btn_create(screen);
lv_obj_set_pos(button, 60, 10);
lv_obj_set_size(button, 180, 30);
// lv_obj_set_event_cb(button, buttonEventCallback);
label = lv_label_create(button);
lv_label_set_text(label, "Przycisk");
lv_scr_load(screen);
}
void loop()
{
lv_timer_handler();
}
Note, that LVGL is present in the proper folder, lv_conf.h is configured properly etc.
If I now try to build this project in Arduino IDE, I'm getting the following error:
sketch\WioStation.ino.cpp.o: In function `lvgl_flushDisplay(_lv_disp_drv_t*, lv_area_t const*, lv_color16_t*)':
D:\Dokumenty\Arduino\WioStation/WioStation.ino:52: undefined reference to `lv_disp_flush_ready'
sketch\WioStation.ino.cpp.o: In function `lvgl_tick()':
D:\Dokumenty\Arduino\WioStation/WioStation.ino:57: undefined reference to `lv_tick_inc'
sketch\WioStation.ino.cpp.o: In function `setup':
D:\Dokumenty\Arduino\WioStation/WioStation.ino:74: undefined reference to `lv_init'
D:\Dokumenty\Arduino\WioStation/WioStation.ino:76: undefined reference to `lv_disp_draw_buf_init'
D:\Dokumenty\Arduino\WioStation/WioStation.ino:78: undefined reference to `lv_disp_drv_init'
D:\Dokumenty\Arduino\WioStation/WioStation.ino:83: undefined reference to `lv_disp_drv_register'
D:\Dokumenty\Arduino\WioStation/WioStation.ino:90: undefined reference to `lv_obj_create'
D:\Dokumenty\Arduino\WioStation/WioStation.ino:91: undefined reference to `lv_btn_create'
D:\Dokumenty\Arduino\WioStation/WioStation.ino:92: undefined reference to `lv_obj_set_pos'
D:\Dokumenty\Arduino\WioStation/WioStation.ino:93: undefined reference to `lv_obj_set_size'
D:\Dokumenty\Arduino\WioStation/WioStation.ino:95: undefined reference to `lv_label_create'
D:\Dokumenty\Arduino\WioStation/WioStation.ino:96: undefined reference to `lv_label_set_text'
sketch\WioStation.ino.cpp.o: In function `lv_scr_load':
D:\Dokumenty\Arduino\WioStation\lib\lvgl\src\core/lv_disp.h:187: undefined reference to `lv_disp_load_scr'
sketch\WioStation.ino.cpp.o: In function `loop':
D:\Dokumenty\Arduino\WioStation/WioStation.ino:102: undefined reference to `lv_timer_handler'
collect2.exe: error: ld returned 1 exit status
Znaleziono wiele bibliotek w "TFT_eSPI.h"
Wykorzystane: C:\Users\Spook\Documents\Arduino\libraries\TFT_eSPI
Niewykorzystane: C:\Users\Spook\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.1\libraries\Seeed_Arduino_LCD
exit status 1
Błąd kompilacji dla płytki Seeeduino Wio Terminal.
What's surprising is that if I only comment out #include
s with SAMDTimerInterrupt.h and SAMD_ISR_Timer.h, suddenly I'm getting no errors about LVGL anymore:
WioStation:32:1: error: 'SAMDTimer' does not name a type
SAMDTimer lvgl_timer(TIMER_TC3);
^~~~~~~~~
D:\Dokumenty\Arduino\WioStation\WioStation.ino: In function 'void setup()':
WioStation:87:3: error: 'lvgl_timer' was not declared in this scope
lvgl_timer.attachInterruptInterval(LVGL_TICK_PERIOD_MS * 1000, lvgl_tick);
^~~~~~~~~~
D:\Dokumenty\Arduino\WioStation\WioStation.ino:87:3: note: suggested alternative: 'lvgl_tick'
lvgl_timer.attachInterruptInterval(LVGL_TICK_PERIOD_MS * 1000, lvgl_tick);
^~~~~~~~~~
lvgl_tick
Znaleziono wiele bibliotek w "TFT_eSPI.h"
Wykorzystane: C:\Users\Spook\Documents\Arduino\libraries\TFT_eSPI
Niewykorzystane: C:\Users\Spook\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.1\libraries\Seeed_Arduino_LCD
exit status 1
'SAMDTimer' does not name a type
How do I see it is after including SAMDTimerInterrupt, suddenly lvgl is somehow not processed by the compiler.
What am I doing wrong?
Upvotes: 0
Views: 1944
Reputation: 25927
Arduino Studio IDE has a flaw regarding compilation: only files in src
subfolder of the sketch gets copied to the tmp folder and compiled. So all non-standard libraries should be placed in src
subfolder in sketch folder.
Upvotes: 1