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