ESPHome 2026.2.1
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 // max 4 bytes: "%u" with uint8_t (max 255, 3 digits) + null
69 char buf[4];
70 snprintf(buf, sizeof(buf), "%u", event_code);
71 return buf;
72}
73
74static void rounder_cb(lv_disp_drv_t *disp_drv, lv_area_t *area) {
75 // cater for display driver chips with special requirements for bounds of partial
76 // draw areas. Extend the draw area to satisfy:
77 // * Coordinates must be a multiple of draw_rounding
78 auto *comp = static_cast<LvglComponent *>(disp_drv->user_data);
79 auto draw_rounding = comp->draw_rounding;
80 // round down the start coordinates
81 area->x1 = area->x1 / draw_rounding * draw_rounding;
82 area->y1 = area->y1 / draw_rounding * draw_rounding;
83 // round up the end coordinates
84 area->x2 = (area->x2 + draw_rounding) / draw_rounding * draw_rounding - 1;
85 area->y2 = (area->y2 + draw_rounding) / draw_rounding * draw_rounding - 1;
86}
87
88void LvglComponent::monitor_cb(lv_disp_drv_t *disp_drv, uint32_t time, uint32_t px) {
89 ESP_LOGVV(TAG, "Draw end: %" PRIu32 " pixels in %" PRIu32 " ms", px, time);
90 auto *comp = static_cast<LvglComponent *>(disp_drv->user_data);
91 comp->draw_end_();
92}
93
94void LvglComponent::render_start_cb(lv_disp_drv_t *disp_drv) {
95 ESP_LOGVV(TAG, "Draw start");
96 auto *comp = static_cast<LvglComponent *>(disp_drv->user_data);
97 comp->draw_start_();
98}
99
100lv_event_code_t lv_api_event; // NOLINT
101lv_event_code_t lv_update_event; // NOLINT
103 ESP_LOGCONFIG(TAG,
104 "LVGL:\n"
105 " Display width/height: %d x %d\n"
106 " Buffer size: %zu%%\n"
107 " Rotation: %d\n"
108 " Draw rounding: %d",
109 this->disp_drv_.hor_res, this->disp_drv_.ver_res, 100 / this->buffer_frac_, this->rotation,
110 (int) this->draw_rounding);
111}
112
113void LvglComponent::set_paused(bool paused, bool show_snow) {
114 this->paused_ = paused;
115 this->show_snow_ = show_snow;
116 if (!paused && lv_scr_act() != nullptr) {
117 lv_disp_trig_activity(this->disp_); // resets the inactivity time
118 lv_obj_invalidate(lv_scr_act());
119 }
120 if (paused && this->pause_callback_ != nullptr)
121 this->pause_callback_->trigger();
122 if (!paused && this->resume_callback_ != nullptr)
123 this->resume_callback_->trigger();
124}
125
127 lv_init();
128 lv_update_event = static_cast<lv_event_code_t>(lv_event_register_id());
129 lv_api_event = static_cast<lv_event_code_t>(lv_event_register_id());
130}
131
132void LvglComponent::add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event) {
133 lv_obj_add_event_cb(obj, callback, event, nullptr);
134}
135
136void LvglComponent::add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event1,
137 lv_event_code_t event2) {
138 add_event_cb(obj, callback, event1);
139 add_event_cb(obj, callback, event2);
140}
141
142void LvglComponent::add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event1,
143 lv_event_code_t event2, lv_event_code_t event3) {
144 add_event_cb(obj, callback, event1);
145 add_event_cb(obj, callback, event2);
146 add_event_cb(obj, callback, event3);
147}
148
150 this->pages_.push_back(page);
151 page->set_parent(this);
152 lv_disp_set_default(this->disp_);
153 page->setup(this->pages_.size() - 1);
154}
155
156void LvglComponent::show_page(size_t index, lv_scr_load_anim_t anim, uint32_t time) {
157 if (index >= this->pages_.size())
158 return;
159 this->current_page_ = index;
160 lv_scr_load_anim(this->pages_[this->current_page_]->obj, anim, time, 0, false);
161}
162
163void LvglComponent::show_next_page(lv_scr_load_anim_t anim, uint32_t time) {
164 if (this->pages_.empty() || (this->current_page_ == this->pages_.size() - 1 && !this->page_wrap_))
165 return;
166 do {
167 this->current_page_ = (this->current_page_ + 1) % this->pages_.size();
168 } while (this->pages_[this->current_page_]->skip); // skip empty pages()
169 this->show_page(this->current_page_, anim, time);
170}
171
172void LvglComponent::show_prev_page(lv_scr_load_anim_t anim, uint32_t time) {
173 if (this->pages_.empty() || (this->current_page_ == 0 && !this->page_wrap_))
174 return;
175 do {
176 this->current_page_ = (this->current_page_ + this->pages_.size() - 1) % this->pages_.size();
177 } while (this->pages_[this->current_page_]->skip); // skip empty pages()
178 this->show_page(this->current_page_, anim, time);
179}
180
181size_t LvglComponent::get_current_page() const { return this->current_page_; }
182bool LvPageType::is_showing() const { return this->parent_->get_current_page() == this->index; }
183
184void LvglComponent::draw_buffer_(const lv_area_t *area, lv_color_t *ptr) {
185 auto width = lv_area_get_width(area);
186 auto height = lv_area_get_height(area);
187 auto height_rounded = (height + this->draw_rounding - 1) / this->draw_rounding * this->draw_rounding;
188 auto x1 = area->x1;
189 auto y1 = area->y1;
190 lv_color_t *dst = this->rotate_buf_;
191 switch (this->rotation) {
193 for (lv_coord_t x = height; x-- != 0;) {
194 for (lv_coord_t y = 0; y != width; y++) {
195 dst[y * height_rounded + x] = *ptr++;
196 }
197 }
198 y1 = x1;
199 x1 = this->disp_drv_.ver_res - area->y1 - height;
200 height = width;
201 width = height_rounded;
202 break;
203
205 for (lv_coord_t y = height; y-- != 0;) {
206 for (lv_coord_t x = width; x-- != 0;) {
207 dst[y * width + x] = *ptr++;
208 }
209 }
210 x1 = this->disp_drv_.hor_res - x1 - width;
211 y1 = this->disp_drv_.ver_res - y1 - height;
212 break;
213
215 for (lv_coord_t x = 0; x != height; x++) {
216 for (lv_coord_t y = width; y-- != 0;) {
217 dst[y * height_rounded + x] = *ptr++;
218 }
219 }
220 x1 = y1;
221 y1 = this->disp_drv_.hor_res - area->x1 - width;
222 height = width;
223 width = height_rounded;
224 break;
225
226 default:
227 dst = ptr;
228 break;
229 }
230 for (auto *display : this->displays_) {
231 ESP_LOGV(TAG, "draw buffer x1=%d, y1=%d, width=%d, height=%d", x1, y1, width, height);
232 display->draw_pixels_at(x1, y1, width, height, (const uint8_t *) dst, display::COLOR_ORDER_RGB, LV_BITNESS,
233 LV_COLOR_16_SWAP);
234 }
235}
236
237void LvglComponent::flush_cb_(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) {
238 if (!this->is_paused()) {
239 auto now = millis();
240 this->draw_buffer_(area, color_p);
241 ESP_LOGVV(TAG, "flush_cb, area=%d/%d, %d/%d took %dms", area->x1, area->y1, lv_area_get_width(area),
242 lv_area_get_height(area), (int) (millis() - now));
243 }
244 lv_disp_flush_ready(disp_drv);
245}
246
247IdleTrigger::IdleTrigger(LvglComponent *parent, TemplatableValue<uint32_t> timeout) : timeout_(std::move(timeout)) {
248 parent->add_on_idle_callback([this](uint32_t idle_time) {
249 if (!this->is_idle_ && idle_time > this->timeout_.value()) {
250 this->is_idle_ = true;
251 this->trigger();
252 } else if (this->is_idle_ && idle_time < this->timeout_.value()) {
253 this->is_idle_ = false;
254 }
255 });
256}
257
258#ifdef USE_LVGL_TOUCHSCREEN
259LVTouchListener::LVTouchListener(uint16_t long_press_time, uint16_t long_press_repeat_time, LvglComponent *parent) {
260 this->set_parent(parent);
261 lv_indev_drv_init(&this->drv_);
262 this->drv_.disp = parent->get_disp();
263 this->drv_.long_press_repeat_time = long_press_repeat_time;
264 this->drv_.long_press_time = long_press_time;
265 this->drv_.type = LV_INDEV_TYPE_POINTER;
266 this->drv_.user_data = this;
267 this->drv_.read_cb = [](lv_indev_drv_t *d, lv_indev_data_t *data) {
268 auto *l = static_cast<LVTouchListener *>(d->user_data);
269 if (l->touch_pressed_) {
270 data->point.x = l->touch_point_.x;
271 data->point.y = l->touch_point_.y;
272 data->state = LV_INDEV_STATE_PRESSED;
273 } else {
274 data->state = LV_INDEV_STATE_RELEASED;
275 }
276 };
277}
278
280 this->touch_pressed_ = !this->parent_->is_paused() && !tpoints.empty();
281 if (this->touch_pressed_)
282 this->touch_point_ = tpoints[0];
283}
284#endif // USE_LVGL_TOUCHSCREEN
285
286#ifdef USE_LVGL_KEY_LISTENER
287LVEncoderListener::LVEncoderListener(lv_indev_type_t type, uint16_t lpt, uint16_t lprt) {
288 lv_indev_drv_init(&this->drv_);
289 this->drv_.type = type;
290 this->drv_.user_data = this;
291 this->drv_.long_press_time = lpt;
292 this->drv_.long_press_repeat_time = lprt;
293 this->drv_.read_cb = [](lv_indev_drv_t *d, lv_indev_data_t *data) {
294 auto *l = static_cast<LVEncoderListener *>(d->user_data);
295 data->state = l->pressed_ ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
296 data->key = l->key_;
297 data->enc_diff = (int16_t) (l->count_ - l->last_count_);
298 l->last_count_ = l->count_;
299 data->continue_reading = false;
300 };
301}
302#endif // USE_LVGL_KEY_LISTENER
303
304#if defined(USE_LVGL_DROPDOWN) || defined(LV_USE_ROLLER)
306 auto selected = this->get_selected_index();
307 if (selected >= this->options_.size())
308 return "";
309 return this->options_[selected];
310}
311
312static std::string join_string(std::vector<std::string> options) {
313 return std::accumulate(
314 options.begin(), options.end(), std::string(),
315 [](const std::string &a, const std::string &b) -> std::string { return a + (!a.empty() ? "\n" : "") + b; });
316}
317
318void LvSelectable::set_selected_text(const std::string &text, lv_anim_enable_t anim) {
319 auto index = std::find(this->options_.begin(), this->options_.end(), text);
320 if (index != this->options_.end()) {
321 this->set_selected_index(index - this->options_.begin(), anim);
322 lv_event_send(this->obj, lv_api_event, nullptr);
323 }
324}
325
326void LvSelectable::set_options(std::vector<std::string> options) {
327 auto index = this->get_selected_index();
328 if (index >= options.size())
329 index = options.size() - 1;
330 this->options_ = std::move(options);
331 this->set_option_string(join_string(this->options_).c_str());
332 lv_event_send(this->obj, LV_EVENT_REFRESH, nullptr);
333 this->set_selected_index(index, LV_ANIM_OFF);
334}
335#endif // USE_LVGL_DROPDOWN || LV_USE_ROLLER
336
337#ifdef USE_LVGL_BUTTONMATRIX
338void LvButtonMatrixType::set_obj(lv_obj_t *lv_obj) {
339 LvCompound::set_obj(lv_obj);
340 lv_obj_add_event_cb(
341 lv_obj,
342 [](lv_event_t *event) {
343 auto *self = static_cast<LvButtonMatrixType *>(event->user_data);
344 if (self->key_callback_.size() == 0)
345 return;
346 auto key_idx = lv_btnmatrix_get_selected_btn(self->obj);
347 if (key_idx == LV_BTNMATRIX_BTN_NONE)
348 return;
349 if (self->key_map_.count(key_idx) != 0) {
350 self->send_key_(self->key_map_[key_idx]);
351 return;
352 }
353 const auto *str = lv_btnmatrix_get_btn_text(self->obj, key_idx);
354 auto len = strlen(str);
355 while (len--)
356 self->send_key_(*str++);
357 },
358 LV_EVENT_PRESSED, this);
359}
360#endif // USE_LVGL_BUTTONMATRIX
361
362#ifdef USE_LVGL_KEYBOARD
363static const char *const KB_SPECIAL_KEYS[] = {
364 "abc", "ABC", "1#",
365 // maybe add other special keys here
366};
367
368void LvKeyboardType::set_obj(lv_obj_t *lv_obj) {
369 LvCompound::set_obj(lv_obj);
370 lv_obj_add_event_cb(
371 lv_obj,
372 [](lv_event_t *event) {
373 auto *self = static_cast<LvKeyboardType *>(event->user_data);
374 if (self->key_callback_.size() == 0)
375 return;
376
377 auto key_idx = lv_btnmatrix_get_selected_btn(self->obj);
378 if (key_idx == LV_BTNMATRIX_BTN_NONE)
379 return;
380 const char *txt = lv_btnmatrix_get_btn_text(self->obj, key_idx);
381 if (txt == nullptr)
382 return;
383 for (const auto *kb_special_key : KB_SPECIAL_KEYS) {
384 if (strcmp(txt, kb_special_key) == 0)
385 return;
386 }
387 while (*txt != 0)
388 self->send_key_(*txt++);
389 },
390 LV_EVENT_PRESSED, this);
391}
392#endif // USE_LVGL_KEYBOARD
393
395 if (this->draw_end_callback_ != nullptr)
397 if (this->update_when_display_idle_) {
398 for (auto *disp : this->displays_)
399 disp->update();
400 }
401}
402
404 if (this->paused_)
405 return true;
406 if (this->update_when_display_idle_) {
407 for (auto *disp : this->displays_) {
408 if (!disp->is_idle())
409 return true;
410 }
411 }
412 return false;
413}
414
416 int iterations = 6 - lv_disp_get_inactive_time(this->disp_) / 60000;
417 if (iterations <= 0)
418 iterations = 1;
419 while (iterations-- != 0) {
420 auto col = random_uint32() % this->disp_drv_.hor_res;
421 col = col / this->draw_rounding * this->draw_rounding;
422 auto row = random_uint32() % this->disp_drv_.ver_res;
423 row = row / this->draw_rounding * this->draw_rounding;
424 auto size = (random_uint32() % 32) / this->draw_rounding * this->draw_rounding - 1;
425 lv_area_t area;
426 area.x1 = col;
427 area.y1 = row;
428 area.x2 = col + size;
429 area.y2 = row + size;
430 if (area.x2 >= this->disp_drv_.hor_res)
431 area.x2 = this->disp_drv_.hor_res - 1;
432 if (area.y2 >= this->disp_drv_.ver_res)
433 area.y2 = this->disp_drv_.ver_res - 1;
434
435 size_t line_len = lv_area_get_width(&area) * lv_area_get_height(&area) / 2;
436 for (size_t i = 0; i != line_len; i++) {
437 ((uint32_t *) (this->draw_buf_.buf1))[i] = random_uint32();
438 }
439 this->draw_buffer_(&area, (lv_color_t *) this->draw_buf_.buf1);
440 }
441}
442
463LvglComponent::LvglComponent(std::vector<display::Display *> displays, float buffer_frac, bool full_refresh,
464 int draw_rounding, bool resume_on_input, bool update_when_display_idle)
465 : draw_rounding(draw_rounding),
466 displays_(std::move(displays)),
467 buffer_frac_(buffer_frac),
468 full_refresh_(full_refresh),
469 resume_on_input_(resume_on_input),
470 update_when_display_idle_(update_when_display_idle) {
471 lv_disp_draw_buf_init(&this->draw_buf_, nullptr, nullptr, 0);
472 lv_disp_drv_init(&this->disp_drv_);
473 this->disp_drv_.draw_buf = &this->draw_buf_;
474 this->disp_drv_.user_data = this;
475 this->disp_drv_.full_refresh = this->full_refresh_;
476 this->disp_drv_.flush_cb = static_flush_cb;
477 this->disp_drv_.rounder_cb = rounder_cb;
478 this->disp_ = lv_disp_drv_register(&this->disp_drv_);
479}
480
482 auto *display = this->displays_[0];
483 auto rounding = this->draw_rounding;
484 // cater for displays with dimensions that don't divide by the required rounding
485 auto width = (display->get_width() + rounding - 1) / rounding * rounding;
486 auto height = (display->get_height() + rounding - 1) / rounding * rounding;
487 auto frac = this->buffer_frac_;
488 if (frac == 0)
489 frac = 1;
490 size_t buffer_pixels = width * height / frac;
491 auto buf_bytes = buffer_pixels * LV_COLOR_DEPTH / 8;
492 void *buffer = nullptr;
493 if (this->buffer_frac_ >= MIN_BUFFER_FRAC / 2)
494 buffer = malloc(buf_bytes); // NOLINT
495 if (buffer == nullptr)
496 buffer = lv_custom_mem_alloc(buf_bytes); // NOLINT
497 // if specific buffer size not set and can't get 100%, try for a smaller one
498 if (buffer == nullptr && this->buffer_frac_ == 0) {
499 frac = MIN_BUFFER_FRAC;
500 buffer_pixels /= MIN_BUFFER_FRAC;
501 buf_bytes /= MIN_BUFFER_FRAC;
502 buffer = lv_custom_mem_alloc(buf_bytes); // NOLINT
503 }
504 this->buffer_frac_ = frac;
505 if (buffer == nullptr) {
506 this->status_set_error(LOG_STR("Memory allocation failure"));
507 this->mark_failed();
508 return;
509 }
510 lv_disp_draw_buf_init(&this->draw_buf_, buffer, nullptr, buffer_pixels);
511 this->disp_drv_.hor_res = display->get_width();
512 this->disp_drv_.ver_res = display->get_height();
513 lv_disp_drv_update(this->disp_, &this->disp_drv_);
514 this->rotation = display->get_rotation();
516 this->rotate_buf_ = static_cast<lv_color_t *>(lv_custom_mem_alloc(buf_bytes)); // NOLINT
517 if (this->rotate_buf_ == nullptr) {
518 this->status_set_error(LOG_STR("Memory allocation failure"));
519 this->mark_failed();
520 return;
521 }
522 }
523 if (this->draw_start_callback_ != nullptr) {
524 this->disp_drv_.render_start_cb = render_start_cb;
525 }
526 if (this->draw_end_callback_ != nullptr || this->update_when_display_idle_) {
527 this->disp_drv_.monitor_cb = monitor_cb;
528 }
529#if LV_USE_LOG
530 lv_log_register_print_cb([](const char *buf) {
531 auto next = strchr(buf, ')');
532 if (next != nullptr)
533 buf = next + 1;
534 while (isspace(*buf))
535 buf++;
536 esp_log_printf_(LVGL_LOG_LEVEL, TAG, 0, "%.*s", (int) strlen(buf) - 1, buf);
537 });
538#endif
539 // Rotation will be handled by our drawing function, so reset the display rotation.
540 for (auto *disp : this->displays_)
541 disp->set_rotation(display::DISPLAY_ROTATION_0_DEGREES);
542 this->show_page(0, LV_SCR_LOAD_ANIM_NONE, 0);
543 lv_disp_trig_activity(this->disp_);
544}
545
547 // update indicators
548 if (this->is_paused()) {
549 return;
550 }
551 this->idle_callbacks_.call(lv_disp_get_inactive_time(this->disp_));
552}
553
555 if (this->is_paused()) {
556 if (this->paused_ && this->show_snow_)
557 this->write_random_();
558 } else {
559 lv_timer_handler_run_in_period(5);
560 }
561}
562
563#ifdef USE_LVGL_ANIMIMG
564void lv_animimg_stop(lv_obj_t *obj) {
565 auto *animg = (lv_animimg_t *) obj;
566 int32_t duration = animg->anim.time;
567 lv_animimg_set_duration(obj, 0);
568 lv_animimg_start(obj);
569 lv_animimg_set_duration(obj, duration);
570}
571#endif
572void LvglComponent::static_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) {
573 reinterpret_cast<LvglComponent *>(disp_drv->user_data)->flush_cb_(disp_drv, area, color_p);
574}
575} // namespace lvgl
576} // namespace esphome
577
578size_t lv_millis(void) { return esphome::millis(); }
579
580#if defined(USE_HOST) || defined(USE_RP2040) || defined(USE_ESP8266)
581void *lv_custom_mem_alloc(size_t size) {
582 auto *ptr = malloc(size); // NOLINT
583 if (ptr == nullptr) {
584 ESP_LOGE(esphome::lvgl::TAG, "Failed to allocate %zu bytes", size);
585 }
586 return ptr;
587}
588void lv_custom_mem_free(void *ptr) { return free(ptr); } // NOLINT
589void *lv_custom_mem_realloc(void *ptr, size_t size) { return realloc(ptr, size); } // NOLINT
590#else
591static unsigned cap_bits = MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT; // NOLINT
592
593void *lv_custom_mem_alloc(size_t size) {
594 void *ptr;
595 ptr = heap_caps_malloc(size, cap_bits);
596 if (ptr == nullptr) {
597 cap_bits = MALLOC_CAP_8BIT;
598 ptr = heap_caps_malloc(size, cap_bits);
599 }
600 if (ptr == nullptr) {
601 ESP_LOGE(esphome::lvgl::TAG, "Failed to allocate %zu bytes", size);
602 return nullptr;
603 }
604 ESP_LOGV(esphome::lvgl::TAG, "allocate %zu - > %p", size, ptr);
605 return ptr;
606}
607
608void lv_custom_mem_free(void *ptr) {
609 ESP_LOGV(esphome::lvgl::TAG, "free %p", ptr);
610 if (ptr == nullptr)
611 return;
612 heap_caps_free(ptr);
613}
614
615void *lv_custom_mem_realloc(void *ptr, size_t size) {
616 ESP_LOGV(esphome::lvgl::TAG, "realloc %p: %zu", ptr, size);
617 return heap_caps_realloc(ptr, size, cap_bits);
618}
619#endif
uint8_t l
Definition bl0906.h:0
virtual void mark_failed()
Mark this component as failed.
void set_parent(T *parent)
Set the parent of this object.
Definition helpers.h:1479
T value(X... x) const
Definition automation.h:149
void trigger(const Ts &...x)
Inform the parent automation that the event has triggered.
Definition automation.h:279
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)
LvglComponent(std::vector< display::Display * > displays, float buffer_frac, bool full_refresh, int draw_rounding, bool resume_on_input, bool update_when_display_idle)
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)
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:692
size_t size
Definition helpers.h:729
uint32_t random_uint32()
Return a random 32-bit unsigned integer.
Definition helpers.cpp:17
uint32_t IRAM_ATTR HOT millis()
Definition core.cpp:25
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6