34 lines
916 B
C++
Raw Normal View History

2025-02-14 15:02:49 -05:00
#include "display.h"
2025-02-13 19:31:11 -05:00
#include "esp_log.h"
#include "lvgl.h"
void setup()
{
2025-02-14 15:02:49 -05:00
Display d;
2025-02-13 19:31:11 -05:00
ESP_LOGI(TAG, "Display LVGL Scroll Text");
// Lock the mutex due to the LVGL APIs are not thread-safe
2025-02-14 15:02:49 -05:00
_lock_acquire(&Display::lvgl_api_lock_);
2025-02-13 19:31:11 -05:00
// UI function
{
2025-02-14 15:02:49 -05:00
lv_obj_t *scr = lv_display_get_screen_active(d.get_display());
2025-02-13 19:31:11 -05:00
lv_obj_t *label = lv_label_create(scr);
// Circular scroll
lv_label_set_long_mode(label,
2025-02-14 15:02:49 -05:00
LV_LABEL_LONG_SCROLL_CIRCULAR);
2025-02-13 19:31:11 -05:00
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
2025-02-14 15:02:49 -05:00
lv_obj_set_width(label,
lv_display_get_horizontal_resolution(d.get_display()));
2025-02-13 19:31:11 -05:00
lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 0);
}
2025-02-14 15:02:49 -05:00
_lock_release(&Display::lvgl_api_lock_);
2025-02-13 19:31:11 -05:00
}
void loop() { }