ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
lvgl_esphome.cpp
Go to the documentation of this file.
2#include "esphome/core/hal.h"
4#include "esphome/core/log.h"
5#include "lvgl_hal.h"
6#include "lvgl_esphome.h"
7
8#include <numeric>
9
10namespace esphome {
11namespace lvgl {
12static const char *const TAG = "lvgl";
13
14static const size_t MIN_BUFFER_FRAC = 8;
15
16static const char *const EVENT_NAMES[] = {
17 "NONE",
18 "PRESSED",
19 "PRESSING",
20 "PRESS_LOST",
21 "SHORT_CLICKED",
22 "LONG_PRESSED",
23 "LONG_PRESSED_REPEAT",
24 "CLICKED",
25 "RELEASED",
26 "SCROLL_BEGIN",
27 "SCROLL_END",
28 "SCROLL",
29 "GESTURE",
30 "KEY",
31 "FOCUSED",
32 "DEFOCUSED",
33 "LEAVE",
34 "HIT_TEST",
35 "COVER_CHECK",
36 "REFR_EXT_DRAW_SIZE",
37 "DRAW_MAIN_BEGIN",
38 "DRAW_MAIN",
39 "DRAW_MAIN_END",
40 "DRAW_POST_BEGIN",
41 "DRAW_POST",
42 "DRAW_POST_END",
43 "DRAW_PART_BEGIN",
44 "DRAW_PART_END",
45 "VALUE_CHANGED",
46 "INSERT",
47 "REFRESH",
48 "READY",
49 "CANCEL",
50 "DELETE",
51 "CHILD_CHANGED",
52 "CHILD_CREATED",
53 "CHILD_DELETED",
54 "SCREEN_UNLOAD_START",
55 "SCREEN_LOAD_START",
56 "SCREEN_LOADED",
57 "SCREEN_UNLOADED",
58 "SIZE_CHANGED",
59 "STYLE_CHANGED",
60 "LAYOUT_CHANGED",
61 "GET_SELF_SIZE",
62};
63
64std::string lv_event_code_name_for(uint8_t event_code) {
65 if (event_code < sizeof(EVENT_NAMES) / sizeof(EVENT_NAMES[0])) {
66 return EVENT_NAMES[event_code];
67 }
68 return str_sprintf("%2d", event_code);
69}
70
71static void rounder_cb(lv_disp_drv_t *disp_drv, lv_area_t *area) {
72 // cater for display driver chips with special requirements for bounds of partial
73 // draw areas. Extend the draw area to satisfy:
74 // * Coordinates must be a multiple of draw_rounding
75 auto *comp = static_cast<LvglComponent *>(disp_drv->user_data);
76 auto draw_rounding = comp->draw_rounding;
77 // round down the start coordinates
78 area->x1 = area->x1 / draw_rounding * draw_rounding;
79 area->y1 = area->y1 / draw_rounding * draw_rounding;
80 // round up the end coordinates
81 area->x2 = (area->x2 + draw_rounding) / draw_rounding * draw_rounding - 1;
82 area->y2 = (area->y2 + draw_rounding) / draw_rounding * draw_rounding - 1;
83}
84
85void LvglComponent::monitor_cb(lv_disp_drv_t *disp_drv, uint32_t time, uint32_t px) {
86 ESP_LOGVV(TAG, "Draw end: %" PRIu32 " pixels in %" PRIu32 " ms", px, time);
87 auto *comp = static_cast<LvglComponent *>(disp_drv->user_data);
88 comp->draw_end_();
89}
90
91void LvglComponent::render_start_cb(lv_disp_drv_t *disp_drv) {
92 ESP_LOGVV(TAG, "Draw start");
93 auto *comp = static_cast<LvglComponent *>(disp_drv->user_data);
94 comp->draw_start_();
95}
96
97lv_event_code_t lv_api_event; // NOLINT
98lv_event_code_t lv_update_event; // NOLINT
100 ESP_LOGCONFIG(TAG,
101 "LVGL:\n"
102 " Display width/height: %d x %d\n"
103 " Buffer size: %zu%%\n"
104 " Rotation: %d\n"
105 " Draw rounding: %d",
106 this->disp_drv_.hor_res, this->disp_drv_.ver_res, 100 / this->buffer_frac_, this->rotation,
107 (int) this->draw_rounding);
108}
109void LvglComponent::set_paused(bool paused, bool show_snow) {
110 this->paused_ = paused;
111 this->show_snow_ = show_snow;
112 if (!paused && lv_scr_act() != nullptr) {
113 lv_disp_trig_activity(this->disp_); // resets the inactivity time
114 lv_obj_invalidate(lv_scr_act());
115 }
116 if (paused && this->pause_callback_ != nullptr)
117 this->pause_callback_->trigger();
118 if (!paused && this->resume_callback_ != nullptr)
119 this->resume_callback_->trigger();
120}
121
123 lv_init();
124 lv_update_event = static_cast<lv_event_code_t>(lv_event_register_id());
125 lv_api_event = static_cast<lv_event_code_t>(lv_event_register_id());
126}
127void LvglComponent::add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event) {
128 lv_obj_add_event_cb(obj, callback, event, nullptr);
129}
130void LvglComponent::add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event1,
131 lv_event_code_t event2) {
132 add_event_cb(obj, callback, event1);
133 add_event_cb(obj, callback, event2);
134}
135void LvglComponent::add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event1,
136 lv_event_code_t event2, lv_event_code_t event3) {
137 add_event_cb(obj, callback, event1);
138 add_event_cb(obj, callback, event2);
139 add_event_cb(obj, callback, event3);
140}
142 this->pages_.push_back(page);
143 page->set_parent(this);
144 lv_disp_set_default(this->disp_);
145 page->setup(this->pages_.size() - 1);
146}
147void LvglComponent::show_page(size_t index, lv_scr_load_anim_t anim, uint32_t time) {
148 if (index >= this->pages_.size())
149 return;
150 this->current_page_ = index;
151 lv_scr_load_anim(this->pages_[this->current_page_]->obj, anim, time, 0, false);
152}
153void LvglComponent::show_next_page(lv_scr_load_anim_t anim, uint32_t time) {
154 if (this->pages_.empty() || (this->current_page_ == this->pages_.size() - 1 && !this->page_wrap_))
155 return;
156 do {
157 this->current_page_ = (this->current_page_ + 1) % this->pages_.size();
158 } while (this->pages_[this->current_page_]->skip); // skip empty pages()
159 this->show_page(this->current_page_, anim, time);
160}
161void LvglComponent::show_prev_page(lv_scr_load_anim_t anim, uint32_t time) {
162 if (this->pages_.empty() || (this->current_page_ == 0 && !this->page_wrap_))
163 return;
164 do {
165 this->current_page_ = (this->current_page_ + this->pages_.size() - 1) % this->pages_.size();
166 } while (this->pages_[this->current_page_]->skip); // skip empty pages()
167 this->show_page(this->current_page_, anim, time);
168}
169size_t LvglComponent::get_current_page() const { return this->current_page_; }
170bool LvPageType::is_showing() const { return this->parent_->get_current_page() == this->index; }
171void LvglComponent::draw_buffer_(const lv_area_t *area, lv_color_t *ptr) {
172 auto width = lv_area_get_width(area);
173 auto height = lv_area_get_height(area);
174 auto height_rounded = (height + this->draw_rounding - 1) / this->draw_rounding * this->draw_rounding;
175 auto x1 = area->x1;
176 auto y1 = area->y1;
177 lv_color_t *dst = this->rotate_buf_;
178 switch (this->rotation) {
180 for (lv_coord_t x = height; x-- != 0;) {
181 for (lv_coord_t y = 0; y != width; y++) {
182 dst[y * height_rounded + x] = *ptr++;
183 }
184 }
185 y1 = x1;
186 x1 = this->disp_drv_.ver_res - area->y1 - height;
187 height = width;
188 width = height_rounded;
189 break;
190
192 for (lv_coord_t y = height; y-- != 0;) {
193 for (lv_coord_t x = width; x-- != 0;) {
194 dst[y * width + x] = *ptr++;
195 }
196 }
197 x1 = this->disp_drv_.hor_res - x1 - width;
198 y1 = this->disp_drv_.ver_res - y1 - height;
199 break;
200
202 for (lv_coord_t x = 0; x != height; x++) {
203 for (lv_coord_t y = width; y-- != 0;) {
204 dst[y * height_rounded + x] = *ptr++;
205 }
206 }
207 x1 = y1;
208 y1 = this->disp_drv_.hor_res - area->x1 - width;
209 height = width;
210 width = height_rounded;
211 break;
212
213 default:
214 dst = ptr;
215 break;
216 }
217 for (auto *display : this->displays_) {
218 ESP_LOGV(TAG, "draw buffer x1=%d, y1=%d, width=%d, height=%d", x1, y1, width, height);
219 display->draw_pixels_at(x1, y1, width, height, (const uint8_t *) dst, display::COLOR_ORDER_RGB, LV_BITNESS,
220 LV_COLOR_16_SWAP);
221 }
222}
223
224void LvglComponent::flush_cb_(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) {
225 if (!this->paused_) {
226 auto now = millis();
227 this->draw_buffer_(area, color_p);
228 ESP_LOGVV(TAG, "flush_cb, area=%d/%d, %d/%d took %dms", area->x1, area->y1, lv_area_get_width(area),
229 lv_area_get_height(area), (int) (millis() - now));
230 }
231 lv_disp_flush_ready(disp_drv);
232}
233IdleTrigger::IdleTrigger(LvglComponent *parent, TemplatableValue<uint32_t> timeout) : timeout_(std::move(timeout)) {
234 parent->add_on_idle_callback([this](uint32_t idle_time) {
235 if (!this->is_idle_ && idle_time > this->timeout_.value()) {
236 this->is_idle_ = true;
237 this->trigger();
238 } else if (this->is_idle_ && idle_time < this->timeout_.value()) {
239 this->is_idle_ = false;
240 }
241 });
242}
243
244#ifdef USE_LVGL_TOUCHSCREEN
245LVTouchListener::LVTouchListener(uint16_t long_press_time, uint16_t long_press_repeat_time, LvglComponent *parent) {
246 this->set_parent(parent);
247 lv_indev_drv_init(&this->drv_);
248 this->drv_.disp = parent->get_disp();
249 this->drv_.long_press_repeat_time = long_press_repeat_time;
250 this->drv_.long_press_time = long_press_time;
251 this->drv_.type = LV_INDEV_TYPE_POINTER;
252 this->drv_.user_data = this;
253 this->drv_.read_cb = [](lv_indev_drv_t *d, lv_indev_data_t *data) {
254 auto *l = static_cast<LVTouchListener *>(d->user_data);
255 if (l->touch_pressed_) {
256 data->point.x = l->touch_point_.x;
257 data->point.y = l->touch_point_.y;
258 data->state = LV_INDEV_STATE_PRESSED;
259 } else {
260 data->state = LV_INDEV_STATE_RELEASED;
261 }
262 };
263}
264
266 this->touch_pressed_ = !this->parent_->is_paused() && !tpoints.empty();
267 if (this->touch_pressed_)
268 this->touch_point_ = tpoints[0];
269}
270#endif // USE_LVGL_TOUCHSCREEN
271
272#ifdef USE_LVGL_KEY_LISTENER
273LVEncoderListener::LVEncoderListener(lv_indev_type_t type, uint16_t lpt, uint16_t lprt) {
274 lv_indev_drv_init(&this->drv_);
275 this->drv_.type = type;
276 this->drv_.user_data = this;
277 this->drv_.long_press_time = lpt;
278 this->drv_.long_press_repeat_time = lprt;
279 this->drv_.read_cb = [](lv_indev_drv_t *d, lv_indev_data_t *data) {
280 auto *l = static_cast<LVEncoderListener *>(d->user_data);
281 data->state = l->pressed_ ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
282 data->key = l->key_;
283 data->enc_diff = (int16_t) (l->count_ - l->last_count_);
284 l->last_count_ = l->count_;
285 data->continue_reading = false;
286 };
287}
288#endif // USE_LVGL_KEY_LISTENER
289
290#if defined(USE_LVGL_DROPDOWN) || defined(LV_USE_ROLLER)
292 auto selected = this->get_selected_index();
293 if (selected >= this->options_.size())
294 return "";
295 return this->options_[selected];
296}
297
298static std::string join_string(std::vector<std::string> options) {
299 return std::accumulate(
300 options.begin(), options.end(), std::string(),
301 [](const std::string &a, const std::string &b) -> std::string { return a + (!a.empty() ? "\n" : "") + b; });
302}
303
304void LvSelectable::set_selected_text(const std::string &text, lv_anim_enable_t anim) {
305 auto index = std::find(this->options_.begin(), this->options_.end(), text);
306 if (index != this->options_.end()) {
307 this->set_selected_index(index - this->options_.begin(), anim);
308 lv_event_send(this->obj, lv_api_event, nullptr);
309 }
310}
311
312void LvSelectable::set_options(std::vector<std::string> options) {
313 auto index = this->get_selected_index();
314 if (index >= options.size())
315 index = options.size() - 1;
316 this->options_ = std::move(options);
317 this->set_option_string(join_string(this->options_).c_str());
318 lv_event_send(this->obj, LV_EVENT_REFRESH, nullptr);
319 this->set_selected_index(index, LV_ANIM_OFF);
320}
321#endif // USE_LVGL_DROPDOWN || LV_USE_ROLLER
322
323#ifdef USE_LVGL_BUTTONMATRIX
324void LvButtonMatrixType::set_obj(lv_obj_t *lv_obj) {
325 LvCompound::set_obj(lv_obj);
326 lv_obj_add_event_cb(
327 lv_obj,
328 [](lv_event_t *event) {
329 auto *self = static_cast<LvButtonMatrixType *>(event->user_data);
330 if (self->key_callback_.size() == 0)
331 return;
332 auto key_idx = lv_btnmatrix_get_selected_btn(self->obj);
333 if (key_idx == LV_BTNMATRIX_BTN_NONE)
334 return;
335 if (self->key_map_.count(key_idx) != 0) {
336 self->send_key_(self->key_map_[key_idx]);
337 return;
338 }
339 const auto *str = lv_btnmatrix_get_btn_text(self->obj, key_idx);
340 auto len = strlen(str);
341 while (len--)
342 self->send_key_(*str++);
343 },
344 LV_EVENT_PRESSED, this);
345}
346#endif // USE_LVGL_BUTTONMATRIX
347
348#ifdef USE_LVGL_KEYBOARD
349static const char *const KB_SPECIAL_KEYS[] = {
350 "abc", "ABC", "1#",
351 // maybe add other special keys here
352};
353
354void LvKeyboardType::set_obj(lv_obj_t *lv_obj) {
355 LvCompound::set_obj(lv_obj);
356 lv_obj_add_event_cb(
357 lv_obj,
358 [](lv_event_t *event) {
359 auto *self = static_cast<LvKeyboardType *>(event->user_data);
360 if (self->key_callback_.size() == 0)
361 return;
362
363 auto key_idx = lv_btnmatrix_get_selected_btn(self->obj);
364 if (key_idx == LV_BTNMATRIX_BTN_NONE)
365 return;
366 const char *txt = lv_btnmatrix_get_btn_text(self->obj, key_idx);
367 if (txt == nullptr)
368 return;
369 for (const auto *kb_special_key : KB_SPECIAL_KEYS) {
370 if (strcmp(txt, kb_special_key) == 0)
371 return;
372 }
373 while (*txt != 0)
374 self->send_key_(*txt++);
375 },
376 LV_EVENT_PRESSED, this);
377}
378#endif // USE_LVGL_KEYBOARD
379
381 int iterations = 6 - lv_disp_get_inactive_time(this->disp_) / 60000;
382 if (iterations <= 0)
383 iterations = 1;
384 while (iterations-- != 0) {
385 auto col = random_uint32() % this->disp_drv_.hor_res;
386 col = col / this->draw_rounding * this->draw_rounding;
387 auto row = random_uint32() % this->disp_drv_.ver_res;
388 row = row / this->draw_rounding * this->draw_rounding;
389 auto size = (random_uint32() % 32) / this->draw_rounding * this->draw_rounding - 1;
390 lv_area_t area;
391 area.x1 = col;
392 area.y1 = row;
393 area.x2 = col + size;
394 area.y2 = row + size;
395 if (area.x2 >= this->disp_drv_.hor_res)
396 area.x2 = this->disp_drv_.hor_res - 1;
397 if (area.y2 >= this->disp_drv_.ver_res)
398 area.y2 = this->disp_drv_.ver_res - 1;
399
400 size_t line_len = lv_area_get_width(&area) * lv_area_get_height(&area) / 2;
401 for (size_t i = 0; i != line_len; i++) {
402 ((uint32_t *) (this->draw_buf_.buf1))[i] = random_uint32();
403 }
404 this->draw_buffer_(&area, (lv_color_t *) this->draw_buf_.buf1);
405 }
406}
407
428LvglComponent::LvglComponent(std::vector<display::Display *> displays, float buffer_frac, bool full_refresh,
429 int draw_rounding, bool resume_on_input)
430 : draw_rounding(draw_rounding),
431 displays_(std::move(displays)),
432 buffer_frac_(buffer_frac),
433 full_refresh_(full_refresh),
434 resume_on_input_(resume_on_input) {
435 lv_disp_draw_buf_init(&this->draw_buf_, nullptr, nullptr, 0);
436 lv_disp_drv_init(&this->disp_drv_);
437 this->disp_drv_.draw_buf = &this->draw_buf_;
438 this->disp_drv_.user_data = this;
439 this->disp_drv_.full_refresh = this->full_refresh_;
440 this->disp_drv_.flush_cb = static_flush_cb;
441 this->disp_drv_.rounder_cb = rounder_cb;
442 this->disp_ = lv_disp_drv_register(&this->disp_drv_);
443}
444
446 auto *display = this->displays_[0];
447 auto rounding = this->draw_rounding;
448 // cater for displays with dimensions that don't divide by the required rounding
449 auto width = (display->get_width() + rounding - 1) / rounding * rounding;
450 auto height = (display->get_height() + rounding - 1) / rounding * rounding;
451 auto frac = this->buffer_frac_;
452 if (frac == 0)
453 frac = 1;
454 size_t buffer_pixels = width * height / frac;
455 auto buf_bytes = buffer_pixels * LV_COLOR_DEPTH / 8;
456 void *buffer = nullptr;
457 if (this->buffer_frac_ >= MIN_BUFFER_FRAC / 2)
458 buffer = malloc(buf_bytes); // NOLINT
459 if (buffer == nullptr)
460 buffer = lv_custom_mem_alloc(buf_bytes); // NOLINT
461 // if specific buffer size not set and can't get 100%, try for a smaller one
462 if (buffer == nullptr && this->buffer_frac_ == 0) {
463 frac = MIN_BUFFER_FRAC;
464 buffer_pixels /= MIN_BUFFER_FRAC;
465 buf_bytes /= MIN_BUFFER_FRAC;
466 buffer = lv_custom_mem_alloc(buf_bytes); // NOLINT
467 }
468 if (buffer == nullptr) {
469 this->status_set_error("Memory allocation failure");
470 this->mark_failed();
471 return;
472 }
473 this->buffer_frac_ = frac;
474 lv_disp_draw_buf_init(&this->draw_buf_, buffer, nullptr, buffer_pixels);
475 this->disp_drv_.hor_res = display->get_width();
476 this->disp_drv_.ver_res = display->get_height();
477 lv_disp_drv_update(this->disp_, &this->disp_drv_);
478 this->rotation = display->get_rotation();
480 this->rotate_buf_ = static_cast<lv_color_t *>(lv_custom_mem_alloc(buf_bytes)); // NOLINT
481 if (this->rotate_buf_ == nullptr) {
482 this->status_set_error("Memory allocation failure");
483 this->mark_failed();
484 return;
485 }
486 }
487 if (this->draw_start_callback_ != nullptr) {
488 this->disp_drv_.render_start_cb = render_start_cb;
489 }
490 if (this->draw_end_callback_ != nullptr) {
491 this->disp_drv_.monitor_cb = monitor_cb;
492 }
493#if LV_USE_LOG
494 lv_log_register_print_cb([](const char *buf) {
495 auto next = strchr(buf, ')');
496 if (next != nullptr)
497 buf = next + 1;
498 while (isspace(*buf))
499 buf++;
500 esp_log_printf_(LVGL_LOG_LEVEL, TAG, 0, "%.*s", (int) strlen(buf) - 1, buf);
501 });
502#endif
503 // Rotation will be handled by our drawing function, so reset the display rotation.
504 for (auto *disp : this->displays_)
505 disp->set_rotation(display::DISPLAY_ROTATION_0_DEGREES);
506 this->show_page(0, LV_SCR_LOAD_ANIM_NONE, 0);
507 lv_disp_trig_activity(this->disp_);
508}
509
511 // update indicators
512 if (this->paused_) {
513 return;
514 }
515 this->idle_callbacks_.call(lv_disp_get_inactive_time(this->disp_));
516}
518 if (this->paused_) {
519 if (this->show_snow_)
520 this->write_random_();
521 } else {
522 lv_timer_handler_run_in_period(5);
523 }
524}
525
526#ifdef USE_LVGL_ANIMIMG
527void lv_animimg_stop(lv_obj_t *obj) {
528 auto *animg = (lv_animimg_t *) obj;
529 int32_t duration = animg->anim.time;
530 lv_animimg_set_duration(obj, 0);
531 lv_animimg_start(obj);
532 lv_animimg_set_duration(obj, duration);
533}
534#endif
535void LvglComponent::static_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) {
536 reinterpret_cast<LvglComponent *>(disp_drv->user_data)->flush_cb_(disp_drv, area, color_p);
537}
538} // namespace lvgl
539} // namespace esphome
540
541size_t lv_millis(void) { return esphome::millis(); }
542
543#if defined(USE_HOST) || defined(USE_RP2040) || defined(USE_ESP8266)
544void *lv_custom_mem_alloc(size_t size) {
545 auto *ptr = malloc(size); // NOLINT
546 if (ptr == nullptr) {
547 ESP_LOGE(esphome::lvgl::TAG, "Failed to allocate %zu bytes", size);
548 }
549 return ptr;
550}
551void lv_custom_mem_free(void *ptr) { return free(ptr); } // NOLINT
552void *lv_custom_mem_realloc(void *ptr, size_t size) { return realloc(ptr, size); } // NOLINT
553#else
554static unsigned cap_bits = MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT; // NOLINT
555
556void *lv_custom_mem_alloc(size_t size) {
557 void *ptr;
558 ptr = heap_caps_malloc(size, cap_bits);
559 if (ptr == nullptr) {
560 cap_bits = MALLOC_CAP_8BIT;
561 ptr = heap_caps_malloc(size, cap_bits);
562 }
563 if (ptr == nullptr) {
564 ESP_LOGE(esphome::lvgl::TAG, "Failed to allocate %zu bytes", size);
565 return nullptr;
566 }
567 ESP_LOGV(esphome::lvgl::TAG, "allocate %zu - > %p", size, ptr);
568 return ptr;
569}
570
571void lv_custom_mem_free(void *ptr) {
572 ESP_LOGV(esphome::lvgl::TAG, "free %p", ptr);
573 if (ptr == nullptr)
574 return;
575 heap_caps_free(ptr);
576}
577
578void *lv_custom_mem_realloc(void *ptr, size_t size) {
579 ESP_LOGV(esphome::lvgl::TAG, "realloc %p: %zu", ptr, size);
580 return heap_caps_realloc(ptr, size, cap_bits);
581}
582#endif
uint8_t l
Definition bl0906.h:0
virtual void mark_failed()
Mark this component as failed.
void status_set_error(const char *message=nullptr)
void set_parent(T *parent)
Set the parent of this object.
Definition helpers.h:926
void trigger(const Ts &...x)
Inform the parent automation that the event has triggered.
Definition automation.h:169
IdleTrigger(LvglComponent *parent, TemplatableValue< uint32_t > timeout)
TemplatableValue< uint32_t > timeout_
LVEncoderListener(lv_indev_type_t type, uint16_t lpt, uint16_t lprt)
LVTouchListener(uint16_t long_press_time, uint16_t long_press_repeat_time, LvglComponent *parent)
touchscreen::TouchPoint touch_point_
void update(const touchscreen::TouchPoints_t &tpoints) override
void set_obj(lv_obj_t *lv_obj) override
virtual void set_obj(lv_obj_t *lv_obj)
void set_obj(lv_obj_t *lv_obj) override
void setup(size_t index)
void set_selected_text(const std::string &text, lv_anim_enable_t anim)
void set_options(std::vector< std::string > options)
std::vector< std::string > options_
virtual void set_selected_index(size_t index, lv_anim_enable_t anim)=0
virtual size_t get_selected_index()=0
virtual void set_option_string(const char *options)=0
Component for rendering LVGL.
void set_paused(bool paused, bool show_snow)
static void static_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
std::vector< LvPageType * > pages_
static void add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event)
void show_next_page(lv_scr_load_anim_t anim, uint32_t time)
CallbackManager< void(uint32_t)> idle_callbacks_
void add_on_idle_callback(std::function< void(uint32_t)> &&callback)
lv_disp_draw_buf_t draw_buf_
display::DisplayRotation rotation
void show_page(size_t index, lv_scr_load_anim_t anim, uint32_t time)
void show_prev_page(lv_scr_load_anim_t anim, uint32_t time)
static void render_start_cb(lv_disp_drv_t *disp_drv)
std::vector< display::Display * > displays_
static void esphome_lvgl_init()
Initialize the LVGL library and register custom events.
void flush_cb_(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
LvglComponent(std::vector< display::Display * > displays, float buffer_frac, bool full_refresh, int draw_rounding, bool resume_on_input)
void add_page(LvPageType *page)
void draw_buffer_(const lv_area_t *area, lv_color_t *ptr)
static void monitor_cb(lv_disp_drv_t *disp_drv, uint32_t time, uint32_t px)
uint16_t type
uint8_t options
void * lv_custom_mem_alloc(size_t size)
size_t lv_millis(void)
void lv_custom_mem_free(void *ptr)
void * lv_custom_mem_realloc(void *ptr, size_t size)
uint8_t duration
Definition msa3xx.h:0
@ DISPLAY_ROTATION_0_DEGREES
Definition display.h:135
@ DISPLAY_ROTATION_270_DEGREES
Definition display.h:138
@ DISPLAY_ROTATION_180_DEGREES
Definition display.h:137
@ DISPLAY_ROTATION_90_DEGREES
Definition display.h:136
void lv_animimg_stop(lv_obj_t *obj)
std::string lv_event_code_name_for(uint8_t event_code)
lv_event_code_t lv_update_event
void(_lv_event_t *) event_callback_t
lv_event_code_t lv_api_event
std::vector< TouchPoint > TouchPoints_t
Definition touchscreen.h:30
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
void HOT esp_log_printf_(int level, const char *tag, int line, const char *format,...)
Definition log.cpp:11
std::string size_t len
Definition helpers.h:500
uint32_t random_uint32()
Return a random 32-bit unsigned integer.
Definition helpers.cpp:17
std::string str_sprintf(const char *fmt,...)
Definition helpers.cpp:222
uint32_t IRAM_ATTR HOT millis()
Definition core.cpp:30
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6