What do you want to achieve?
Compile without errors an example Arduino sketch (lvgl_btn.ino) for the Lilygo T-Watch 2021 and upload it on the board, in order to use it as base code to use the UI I created with Squareline Studio.
What have you tried so far?
I have followed multiple times the instruction to setup the file structure. Loaded all the T-Watch libraries from the Lilygo GitHub page ( Xinyuan-LilyGO/T-Watch-2021 (github.com), I created the lv_conf.h file from the lv_conf_template.h, and pasted it next to the lvgl folder, I have configured the TWatch_config.h file. I am still getting a lot of errors (see below). Itâs unexpected because this is an example code so it should work properly without much tweaking⌠Other non lvgl example codes from the same library worked fine.
ONE THING I DONT UNDERSTAND: the code says:
// This project requires LVGL, please uncomment it
but it doesnât clarify WHAT and WHERE I am supposed to uncomment. I swept all the .c and .h files i could think of and there are is no LVGL code commented out.
Iâve opened an issue on Lilygo GitHub but no answer so far.
As an alternative, it would also help if someone could provide me with another simple code that I could use as basis to upload on the TWatch to start loading my UI files.
Screenshot or video
THIS IS THE CODE
#include <Arduino.h>
#include <TWatch_hal.h>
//âTWatch_config.hâ needs to be configured in the library for the first time
// This project requires LVGL, please uncomment it
lv_obj_t *count_label;
uint32_t count = 0;
TWatchClass *twatch = nullptr;
static void event_handler(lv_event_t *e) {
lv_event_code_t code = lv_event_get_code(e);
if (code == LV_EVENT_CLICKED) {
lv_label_set_text_fmt(count_label, âCount:%dâ, count++);
} else if (code == LV_EVENT_VALUE_CHANGED) {
LV_LOG_USER(âToggledâ);
}
}
void setup() {
Serial.begin(115200);
twatch = TWatchClass::getWatch();
Serial.println(âlvgl btn Demo (LVGL)â);
twatch->backlight_set_value(100);
twatch->hal_auto_update(true, 0);
lv_obj_t *label;
lv_obj_t *btn1 = lv_btn_create(lv_scr_act());
lv_obj_add_event_cb(btn1, event_handler, LV_EVENT_ALL, NULL);
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, -40);
label = lv_label_create(btn1);
lv_label_set_text(label, âButtonâ);
lv_obj_center(label);
count_label = lv_label_create(lv_scr_act());
lv_label_set_text(count_label, âCount:0â);
lv_obj_center(count_label);
lv_obj_t *btn2 = lv_btn_create(lv_scr_act());
lv_obj_add_event_cb(btn2, event_handler, LV_EVENT_ALL, NULL);
lv_obj_align(btn2, LV_ALIGN_CENTER, 0, 40);
lv_obj_add_flag(btn2, LV_OBJ_FLAG_CHECKABLE);
lv_obj_set_height(btn2, LV_SIZE_CONTENT);
label = lv_label_create(btn2);
lv_label_set_text(label, âToggleâ);
lv_obj_center(label);
}
void loop() {}
THESE ARE THE ERROR MESSAGES
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:7:1: error: âlv_obj_tâ does not name a type; did you mean ârmt_obj_tâ?
lv_obj_t *count_label;
^~~~~~~~
rmt_obj_t
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:11:27: error: variable or field âevent_handlerâ declared void
static void event_handler(lv_event_t *e) {
^~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:11:27: error: âlv_event_tâ was not declared in this scope
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:11:27: note: suggested alternative: âspi_event_tâ
static void event_handler(lv_event_t *e) {
^~~~~~~~~~
spi_event_t
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:11:39: error: âeâ was not declared in this scope
static void event_handler(lv_event_t *e) {
^
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:11:27: error: variable or field âevent_handlerâ declared void
static void event_handler(lv_event_t *e) {
^~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:11:27: error: âlv_event_tâ was not declared in this scope
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:11:27: note: suggested alternative: âspi_event_tâ
static void event_handler(lv_event_t *e) {
^~~~~~~~~~
spi_event_t
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:11:39: error: âeâ was not declared in this scope
static void event_handler(lv_event_t *e) {
^
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino: In function âvoid setup()â:
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:30:3: error: âlv_obj_tâ was not declared in this scope
lv_obj_t *label;
^~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:30:3: note: suggested alternative: ârmt_obj_tâ
lv_obj_t *label;
^~~~~~~~
rmt_obj_t
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:30:13: error: âlabelâ was not declared in this scope
lv_obj_t *label;
^~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:30:13: note: suggested alternative: âlabsâ
lv_obj_t *label;
^~~~~
labs
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:31:13: error: âbtn1â was not declared in this scope
lv_obj_t *btn1 = lv_btn_create(lv_scr_act());
^~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:31:34: error: âlv_scr_actâ was not declared in this scope
lv_obj_t *btn1 = lv_btn_create(lv_scr_act());
^~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:31:20: error: âlv_btn_createâ was not declared in this scope
lv_obj_t *btn1 = lv_btn_create(lv_scr_act());
^~~~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:31:20: note: suggested alternative: âtimer_createâ
lv_obj_t *btn1 = lv_btn_create(lv_scr_act());
^~~~~~~~~~~~~
timer_create
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:32:29: error: âevent_handlerâ was not declared in this scope
lv_obj_add_event_cb(btn1, event_handler, LV_EVENT_ALL, NULL);
^~~~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:32:29: note: suggested alternative: âxt_handlerâ
lv_obj_add_event_cb(btn1, event_handler, LV_EVENT_ALL, NULL);
^~~~~~~~~~~~~
xt_handler
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:32:44: error: âLV_EVENT_ALLâ was not declared in this scope
lv_obj_add_event_cb(btn1, event_handler, LV_EVENT_ALL, NULL);
^~~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:32:3: error: âlv_obj_add_event_cbâ was not declared in this scope
lv_obj_add_event_cb(btn1, event_handler, LV_EVENT_ALL, NULL);
^~~~~~~~~~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:33:22: error: âLV_ALIGN_CENTERâ was not declared in this scope
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, -40);
^~~~~~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:33:3: error: âlv_obj_alignâ was not declared in this scope
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, -40);
^~~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:35:11: error: âlv_label_createâ was not declared in this scope
label = lv_label_create(btn1);
^~~~~~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:35:11: note: suggested alternative: âtimer_createâ
label = lv_label_create(btn1);
^~~~~~~~~~~~~~~
timer_create
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:36:3: error: âlv_label_set_textâ was not declared in this scope
lv_label_set_text(label, âButtonâ);
^~~~~~~~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:37:3: error: âlv_obj_centerâ was not declared in this scope
lv_obj_center(label);
^~~~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:39:3: error: âcount_labelâ was not declared in this scope
count_label = lv_label_create(lv_scr_act());
^~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:43:13: error: âbtn2â was not declared in this scope
lv_obj_t *btn2 = lv_btn_create(lv_scr_act());
^~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:43:13: note: suggested alternative: âatan2â
lv_obj_t *btn2 = lv_btn_create(lv_scr_act());
^~~~
atan2
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:46:25: error: âLV_OBJ_FLAG_CHECKABLEâ was not declared in this scope
lv_obj_add_flag(btn2, LV_OBJ_FLAG_CHECKABLE);
^~~~~~~~~~~~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:46:3: error: âlv_obj_add_flagâ was not declared in this scope
lv_obj_add_flag(btn2, LV_OBJ_FLAG_CHECKABLE);
^~~~~~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:47:27: error: âLV_SIZE_CONTENTâ was not declared in this scope
lv_obj_set_height(btn2, LV_SIZE_CONTENT);
^~~~~~~~~~~~~~~
C:\Users\angel\Documents\Arduino\libraries\TWatch_2021_Library\examples\LVGL\lvgl_btn\lvgl_btn.ino:47:3: error: âlv_obj_set_heightâ was not declared in this scope
lv_obj_set_height(btn2, LV_SIZE_CONTENT);
^~~~~~~~~~~~~~~~~
exit status 1
Compilation error: âlv_obj_tâ does not name a type; did you mean ârmt_obj_tâ?
Others
- SquareLine Studio version: 1.3.0
- Operating system: Win 11
- Target hardware: Lilygo T-Watch 2021