What do you want to achieve?
Import my SLS UI into the LilygoT-Watch 2021
What have you tried so far?
I exported my SLS UI in the folder structure provided in this post (Compile errors undefined reference to `ui_Screen1_screen_init - #9 by kisvegabor), opened a working LVGL examples from the Lilygo Twatch 2021 library, commented out all the LVGL objects, added #include “ui.h” and ui_init();
This is my code:
#include <Arduino.h>
#include <TWatch_hal.h>
#include “ui.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); */ui_init();
}
void loop() {}
When compiling I get a lot of error messages referring to all occurrencies of ‘lv_obj_t’ in the ui_helpers.h, ui.h, and ui_helpers.c files. Here I paste just a few of them but they are all similar.
c:\users\angel\documents\arduino\libraries\ui\src\ui_helpers.h:33:29: error: unknown type name ‘lv_obj_t’
void _ui_label_set_property(lv_obj_t * target, int id, const char * val);
^~~~~~~~
c:\users\angel\documents\arduino\libraries\ui\src\ui_helpers.h:37:30: error: unknown type name ‘lv_obj_t’
void _ui_roller_set_property(lv_obj_t * target, int id, int val);
^~~~~~~~
c:\users\angel\documents\arduino\libraries\ui\src\ui_helpers.h:41:30: error: unknown type name ‘lv_obj_t’
void _ui_slider_set_property(lv_obj_t * target, int id, int val);
I noticed that my ui.h file has the following code:
#if defined __has_include
#if __has_include(“lvgl.h”)
#include “lvgl.h”
#elif __has_include(“lvgl/lvgl.h”)
#include “lvgl/lvgl.h”
#else
#include “lvgl.h”
#endif
#else
#include “lvgl.h”
#endif
But if I use the “go to definition” function on the lvgl.h text I get “no definition available”, as if the Arduino wasn’t able to find the file, which I verified is present in my TWatch library.
Could this be the source of the problem?
###Screenshot
the orange folder is where my sketch is
the green folder is where the ui folder is
Others
- SquareLine Studio version: latest
- Operating system: win 11
- Target hardware: