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