32 lines
879 B
C++

#include "display.h"
#include "esp_log.h"
#include "lvgl.h"
void setup()
{
Display d;
// UI function
{
// Lock the mutex due to the LVGL APIs are not thread-safe
ScopedLock lock(Display::lvgl_api_lock_);
ESP_LOGI(TAG, "Display LVGL Scroll Text");
lv_obj_t *scr = lv_display_get_screen_active(d.get_display());
lv_obj_t *label = lv_label_create(scr);
// Circular scroll
lv_label_set_long_mode(label,
LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_label_set_text(label,
"Hello hello hello hello hello hello hello hello.");
// Size of the screen
// if you use rotation 90 or 270 use lv_display_get_vertical_resolution
lv_obj_set_width(label,
lv_display_get_horizontal_resolution(d.get_display()));
lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 0);
}
}
void loop() { }