32 lines
780 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"
2025-02-14 16:48:04 -05:00
I2C i2c;
2025-02-13 19:31:11 -05:00
void setup()
{
2025-02-14 16:48:04 -05:00
Display d(i2c);
2025-02-13 19:31:11 -05:00
2025-02-14 16:48:04 -05:00
// UI function scope.
2025-02-13 19:31:11 -05:00
{
2025-02-14 15:50:35 -05:00
// Lock the mutex due to the LVGL APIs are not thread-safe
2025-02-14 16:33:41 -05:00
ScopedLock lock;
2025-02-14 15:50:35 -05:00
ESP_LOGI(TAG, "Display LVGL Scroll Text");
2025-02-14 15:56:15 -05:00
lv_obj_t *scr = lv_display_get_screen_active(d.get());
2025-02-13 19:31:11 -05:00
lv_obj_t *label = lv_label_create(scr);
// Circular scroll
2025-02-14 15:56:15 -05:00
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_label_set_text(label, "Hello hello hello hello hello hello hello.");
2025-02-13 19:31:11 -05:00
// Size of the screen
// if you use rotation 90 or 270 use lv_display_get_vertical_resolution
2025-02-14 15:56:15 -05:00
lv_obj_set_width(label, lv_display_get_horizontal_resolution(*d));
2025-02-13 19:31:11 -05:00
lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 0);
}
}
void loop() { }