ESPHome 2026.10.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_esphome.h"
6
7#include "core/lv_global.h"
8#include "core/lv_obj_class_private.h"
9
10#include <numeric>
11
12static void *lv_alloc_draw_buf(size_t size, bool internal);
13static void *draw_buf_alloc_cb(size_t size, lv_color_format_t color_format) { return lv_alloc_draw_buf(size, false); };
14
15namespace esphome::lvgl {
16static const char *const TAG = "lvgl";
17
18static const size_t MIN_BUFFER_FRAC = 8; // buffer must be at least 1/8 of the display size
19static const size_t MIN_BUFFER_SIZE = 2048; // Sensible minimum buffer size
20
21static const char *const EVENT_NAMES[] = {
22 "NONE",
23 "PRESSED",
24 "PRESSING",
25 "PRESS_LOST",
26 "SHORT_CLICKED",
27 "LONG_PRESSED",
28 "LONG_PRESSED_REPEAT",
29 "CLICKED",
30 "RELEASED",
31 "SCROLL_BEGIN",
32 "SCROLL_END",
33 "SCROLL",
34 "GESTURE",
35 "KEY",
36 "FOCUSED",
37 "DEFOCUSED",
38 "LEAVE",
39 "HIT_TEST",
40 "COVER_CHECK",
41 "REFR_EXT_DRAW_SIZE",
42 "DRAW_MAIN_BEGIN",
43 "DRAW_MAIN",
44 "DRAW_MAIN_END",
45 "DRAW_POST_BEGIN",
46 "DRAW_POST",
47 "DRAW_POST_END",
48 "DRAW_PART_BEGIN",
49 "DRAW_PART_END",
50 "VALUE_CHANGED",
51 "INSERT",
52 "REFRESH",
53 "READY",
54 "CANCEL",
55 "DELETE",
56 "CHILD_CHANGED",
57 "CHILD_CREATED",
58 "CHILD_DELETED",
59 "SCREEN_UNLOAD_START",
60 "SCREEN_LOAD_START",
61 "SCREEN_LOADED",
62 "SCREEN_UNLOADED",
63 "SIZE_CHANGED",
64 "STYLE_CHANGED",
65 "LAYOUT_CHANGED",
66 "GET_SELF_SIZE",
67};
68
69static const unsigned LOG_LEVEL_MAP[] = {
70 ESPHOME_LOG_LEVEL_DEBUG, ESPHOME_LOG_LEVEL_INFO, ESPHOME_LOG_LEVEL_WARN,
71 ESPHOME_LOG_LEVEL_ERROR, ESPHOME_LOG_LEVEL_ERROR, ESPHOME_LOG_LEVEL_NONE,
72
73};
74
75std::string lv_event_code_name_for(lv_event_t *event) {
76 auto event_code = lv_event_get_code(event);
77 if (event_code < sizeof(EVENT_NAMES) / sizeof(EVENT_NAMES[0])) {
78 return EVENT_NAMES[event_code];
79 }
80 // max 4 bytes: "%u" with uint8_t (max 255, 3 digits) + null
81 char buf[4];
82 snprintf(buf, sizeof(buf), "%u", event_code);
83 return buf;
84}
85
88 ESP_LOGW(TAG, "Display rotation cannot be changed unless rotation was enabled during setup.");
89 return;
90 }
91 this->rotation_ = rotation;
92 if (this->is_ready()) {
93 this->set_resolution_();
94 this->update_orientation_();
95 lv_obj_update_layout(this->get_screen_active());
96 lv_obj_invalidate(this->get_screen_active());
97 }
98}
99
101 // Normalize to [0, 360). The DisplayRotation enum values are the angles in degrees.
102 angle %= 360;
103 if (angle < 0)
104 angle += 360;
105 if (angle % 90 != 0) {
106 ESP_LOGW(TAG, "Invalid rotation angle %d; must be a multiple of 90 degrees.", angle);
107 return;
108 }
109 this->set_rotation(static_cast<display::DisplayRotation>(angle));
110}
111
112void LvglComponent::rotate_coordinates(int32_t &x, int32_t &y) const {
113 switch (this->rotation_) {
114 default:
115 break;
116
118 x = this->width_ - x - 1;
119 y = this->height_ - y - 1;
120 break;
121 }
123 auto tmp = x;
124 x = this->height_ - y - 1;
125 y = tmp;
126 break;
127 }
129 auto tmp = y;
130 y = this->width_ - x - 1;
131 x = tmp;
132 break;
133 }
134 }
135}
136
137static void rounder_cb(lv_event_t *event) {
138 auto *comp = static_cast<LvglComponent *>(lv_event_get_user_data(event));
139 auto *area = static_cast<lv_area_t *>(lv_event_get_param(event));
140 // cater for display driver chips with special requirements for bounds of partial
141 // draw areas. Extend the draw area to satisfy:
142 // * Coordinates must be a multiple of draw_rounding
143 auto draw_rounding = comp->draw_rounding;
144 // round down the start coordinates
145 area->x1 = area->x1 / draw_rounding * draw_rounding;
146 area->y1 = area->y1 / draw_rounding * draw_rounding;
147 // round up the end coordinates
148 area->x2 = (area->x2 + draw_rounding) / draw_rounding * draw_rounding - 1;
149 area->y2 = (area->y2 + draw_rounding) / draw_rounding * draw_rounding - 1;
150}
151
152void LvglComponent::render_end_cb(lv_event_t *event) {
153 auto *comp = static_cast<LvglComponent *>(lv_event_get_user_data(event));
154 comp->draw_end_();
155}
156
157void LvglComponent::render_start_cb(lv_event_t *event) {
158 ESP_LOGVV(TAG, "Draw start");
159 auto *comp = static_cast<LvglComponent *>(lv_event_get_user_data(event));
160 comp->draw_start_();
161}
162
163lv_event_code_t lv_update_event; // NOLINT
165 ESP_LOGCONFIG(TAG,
166 "LVGL:\n"
167 " Display width/height: %d x %d\n"
168 " Buffer size: %zu%%\n"
169 " Rotation: %d\n"
170 " Draw rounding: %d",
171 this->width_, this->height_, 100 / this->buffer_frac_, this->rotation_, (int) this->draw_rounding);
172 if (this->rotation_type_ != ROTATION_UNUSED) {
173 const char *rot_type = "hardware via display driver";
175#ifdef USE_ESP32_VARIANT_ESP32P4
176 rot_type = this->ppa_client_ != nullptr ? "software (PPA accelerated)" : "software";
177#else
178 rot_type = "software";
179#endif
180 }
181 ESP_LOGCONFIG(TAG, " Rotation type: %s", rot_type);
182 }
183}
184
185void LvglComponent::set_paused(bool paused, bool show_snow) {
186 this->paused_ = paused;
187 this->show_snow_ = show_snow;
188 if (!paused && lv_screen_active() != nullptr) {
189 lv_display_trigger_activity(this->disp_); // resets the inactivity time
190 lv_obj_invalidate(lv_screen_active());
191 }
192 if (paused && this->pause_callback_ != nullptr)
193 this->pause_callback_->trigger();
194 if (!paused && this->resume_callback_ != nullptr)
195 this->resume_callback_->trigger();
196}
197
199 lv_init();
200 // override draw buf alloc to ensure proper alignment for PPA
201 LV_GLOBAL_DEFAULT()->draw_buf_handlers.buf_malloc_cb = draw_buf_alloc_cb;
202 LV_GLOBAL_DEFAULT()->draw_buf_handlers.buf_free_cb = lv_free_core;
203 LV_GLOBAL_DEFAULT()->image_cache_draw_buf_handlers.buf_malloc_cb = draw_buf_alloc_cb;
204 LV_GLOBAL_DEFAULT()->image_cache_draw_buf_handlers.buf_free_cb = lv_free_core;
205 LV_GLOBAL_DEFAULT()->font_draw_buf_handlers.buf_malloc_cb = draw_buf_alloc_cb;
206 LV_GLOBAL_DEFAULT()->font_draw_buf_handlers.buf_free_cb = lv_free_core;
207 lv_tick_set_cb([] { return millis(); });
208 lv_update_event = static_cast<lv_event_code_t>(lv_event_register_id());
209}
210
211void LvglComponent::add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event, void *user_data) {
212 lv_obj_add_event_cb(obj, callback, event, user_data);
213}
214
215void LvglComponent::add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event1,
216 lv_event_code_t event2, void *user_data) {
217 add_event_cb(obj, callback, event1, user_data);
218 add_event_cb(obj, callback, event2, user_data);
219}
220
221void LvglComponent::add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event1,
222 lv_event_code_t event2, lv_event_code_t event3, void *user_data) {
223 add_event_cb(obj, callback, event1, user_data);
224 add_event_cb(obj, callback, event2, user_data);
225 add_event_cb(obj, callback, event3, user_data);
226}
227
229 this->pages_.push_back(page);
230 page->set_parent(this);
231 lv_display_set_default(this->disp_);
232 page->setup(this->pages_.size() - 1);
233}
234
235void LvglComponent::show_page(size_t index, lv_screen_load_anim_t anim, uint32_t time) {
236 if (index >= this->pages_.size())
237 return;
238 this->current_page_ = index;
239 if (anim == LV_SCREEN_LOAD_ANIM_NONE) {
240 lv_screen_load(this->pages_[this->current_page_]->obj);
241 } else {
242 lv_screen_load_anim(this->pages_[this->current_page_]->obj, anim, time, 0, false);
243 }
244}
245
246void LvglComponent::show_next_page(lv_screen_load_anim_t anim, uint32_t time) {
247 if (this->pages_.empty() || (this->current_page_ == this->pages_.size() - 1 && !this->page_wrap_))
248 return;
249 size_t start = this->current_page_;
250 do {
251 this->current_page_ = (this->current_page_ + 1) % this->pages_.size();
252 if (this->current_page_ == start)
253 return; // all pages have skip=true (guaranteed not to happen by YAML validation)
254 } while (this->pages_[this->current_page_]->skip); // skip empty pages()
255 this->show_page(this->current_page_, anim, time);
256}
257
258void LvglComponent::show_prev_page(lv_screen_load_anim_t anim, uint32_t time) {
259 if (this->pages_.empty() || (this->current_page_ == 0 && !this->page_wrap_))
260 return;
261 size_t start = this->current_page_;
262 do {
263 this->current_page_ = (this->current_page_ + this->pages_.size() - 1) % this->pages_.size();
264 if (this->current_page_ == start)
265 return; // all pages have skip=true (guaranteed not to happen by YAML validation)
266 } while (this->pages_[this->current_page_]->skip); // skip empty pages()
267 this->show_page(this->current_page_, anim, time);
268}
269
270size_t LvglComponent::get_current_page() const { return this->current_page_; }
271bool LvPageType::is_showing() const { return this->parent_->get_current_page() == this->index; }
272
273#ifdef USE_ESP32_VARIANT_ESP32P4
274bool LvglComponent::ppa_rotate_(const lv_color_data *src, lv_color_data *dst, uint16_t width, uint16_t height,
275 uint32_t height_rounded) {
276 ppa_srm_rotation_angle_t angle;
277 uint16_t out_w, out_h;
278
279 // Map ESPHome clockwise display rotation to PPA counter-clockwise angles
280 switch (this->rotation_) {
282 angle = PPA_SRM_ROTATION_ANGLE_270; // 270° CCW = 90° CW
283 out_w = height_rounded;
284 out_h = width;
285 break;
287 angle = PPA_SRM_ROTATION_ANGLE_180;
288 out_w = width;
289 out_h = height;
290 break;
292 angle = PPA_SRM_ROTATION_ANGLE_90; // 90° CCW = 270° CW
293 out_w = height_rounded;
294 out_h = width;
295 break;
296 default:
297 return false; // No rotation needed
298 }
299
300 // Align buffer size to cache line (LV_DRAW_BUF_ALIGN) as required by PPA DMA
301 // the underlying buffer will be large enough as the size is also padded when allocating.
302 size_t out_buf_size = out_w * out_h * sizeof(lv_color_data);
303 out_buf_size = LV_ROUND_UP(out_buf_size, LV_DRAW_BUF_ALIGN);
304
305 ppa_srm_oper_config_t srm_config{};
306 srm_config.in.buffer = src;
307 srm_config.in.pic_w = width;
308 srm_config.in.pic_h = height;
309 srm_config.in.block_w = width;
310 srm_config.in.block_h = height;
311#if LV_COLOR_DEPTH == 16
312 srm_config.in.srm_cm = PPA_SRM_COLOR_MODE_RGB565;
313#elif LV_COLOR_DEPTH == 32
314 srm_config.in.srm_cm = PPA_SRM_COLOR_MODE_ARGB8888;
315#endif
316 srm_config.out.buffer = dst;
317 srm_config.out.buffer_size = out_buf_size;
318 srm_config.out.pic_w = out_w;
319 srm_config.out.pic_h = out_h;
320#if LV_COLOR_DEPTH == 16
321 srm_config.out.srm_cm = PPA_SRM_COLOR_MODE_RGB565;
322#elif LV_COLOR_DEPTH == 32
323 srm_config.out.srm_cm = PPA_SRM_COLOR_MODE_ARGB8888;
324#endif
325 srm_config.rotation_angle = angle;
326 srm_config.scale_x = 1.0f;
327 srm_config.scale_y = 1.0f;
328 srm_config.mode = PPA_TRANS_MODE_BLOCKING;
329
330 esp_err_t ret = ppa_do_scale_rotate_mirror(this->ppa_client_, &srm_config);
331 if (ret != ESP_OK) {
332 ESP_LOGW(TAG, "PPA rotation failed: %s", esp_err_to_name(ret));
333 ESP_LOGW(TAG, "PPA SRM: in=%ux%u src=%p, out=%ux%u dst=%p size=%zu, angle=%d", width, height, src, out_w, out_h,
334 dst, out_buf_size, (int) angle);
335 return false;
336 }
337 return true;
338}
339#endif // USE_ESP32_VARIANT_ESP32P4
340
341void LvglComponent::draw_buffer_(const lv_area_t *area, lv_color_data *ptr) {
342 auto width = lv_area_get_width(area);
343 auto height = lv_area_get_height(area);
344 auto height_rounded = (height + this->draw_rounding - 1) / this->draw_rounding * this->draw_rounding;
345 auto x1 = area->x1;
346 auto y1 = area->y1;
347 if (this->rotation_type_ == ROTATION_SOFTWARE) {
348 lv_color_data *dst = reinterpret_cast<lv_color_data *>(this->rotate_buf_);
349#ifdef USE_ESP32_VARIANT_ESP32P4
350 bool ppa_done = this->ppa_client_ != nullptr && this->ppa_rotate_(ptr, dst, width, height, height_rounded);
351 if (!ppa_done)
352#endif
353 {
354 switch (this->rotation_) {
356 for (lv_coord_t x = height; x-- != 0;) {
357 for (lv_coord_t y = 0; y != width; y++) {
358 dst[y * height_rounded + x] = *ptr++;
359 }
360 }
361 break;
362
364 for (lv_coord_t y = height; y-- != 0;) {
365 for (lv_coord_t x = width; x-- != 0;) {
366 dst[y * width + x] = *ptr++;
367 }
368 }
369 break;
370
372 for (lv_coord_t x = 0; x != height; x++) {
373 for (lv_coord_t y = width; y-- != 0;) {
374 dst[y * height_rounded + x] = *ptr++;
375 }
376 }
377 break;
378
379 default:
380 dst = ptr;
381 break;
382 }
383 }
384 // Coordinate adjustments apply regardless of PPA or SW rotation
385 switch (this->rotation_) {
387 y1 = x1;
388 x1 = this->width_ - area->y1 - height;
389 height = width;
390 width = height_rounded;
391 break;
392
394 x1 = this->width_ - x1 - width;
395 y1 = this->height_ - y1 - height;
396 break;
397
399 x1 = y1;
400 y1 = this->height_ - area->x1 - width;
401 height = width;
402 width = height_rounded;
403 break;
404
405 default:
406 break;
407 }
408 ptr = dst;
409 }
410 for (auto *display : this->displays_) {
411 display->draw_pixels_at(x1, y1, width, height, (const uint8_t *) ptr, display::COLOR_ORDER_RGB, LV_BITNESS,
412 this->big_endian_);
413 }
414}
415
416void LvglComponent::flush_cb_(lv_display_t *disp_drv, const lv_area_t *area, uint8_t *color_p) {
417 // no guard here for display busy, since LVGL will not call flush_cb until the refresh timer fires,
418 // and while the display is busy this is reset to 5 minutes. If that expires and the display is still
419 // busy there are bigger problems.
420 if (!this->paused_) {
421 auto now = millis();
422 this->draw_buffer_(area, reinterpret_cast<lv_color_data *>(color_p));
423 ESP_LOGV(TAG, "flush_cb, area=%d/%d, %d/%d took %dms", (int) area->x1, (int) area->y1,
424 (int) lv_area_get_width(area), (int) lv_area_get_height(area), (int) (millis() - now));
425 }
426 lv_display_flush_ready(disp_drv);
427}
428
430 parent->add_on_idle_callback([this](uint32_t idle_time) {
431 if (!this->is_idle_ && idle_time > this->timeout_.value()) {
432 this->is_idle_ = true;
433 this->trigger();
434 } else if (this->is_idle_ && idle_time < this->timeout_.value()) {
435 this->is_idle_ = false;
436 }
437 });
438}
439
440#ifdef USE_LVGL_TOUCHSCREEN
441LVTouchListener::LVTouchListener(uint16_t long_press_time, uint16_t long_press_repeat_time, LvglComponent *parent) {
442 this->set_parent(parent);
443 this->drv_ = lv_indev_create();
444 lv_indev_set_type(this->drv_, LV_INDEV_TYPE_POINTER);
445 lv_indev_set_disp(this->drv_, parent->get_disp());
446 lv_indev_set_long_press_time(this->drv_, long_press_time);
447 lv_indev_set_long_press_repeat_time(this->drv_, long_press_repeat_time);
448 lv_indev_set_user_data(this->drv_, this);
449 lv_indev_set_read_cb(this->drv_, [](lv_indev_t *d, lv_indev_data_t *data) {
450 auto *l = static_cast<LVTouchListener *>(lv_indev_get_user_data(d));
451 if (l->touch_pressed_) {
452 data->point.x = l->touch_point_.x;
453 data->point.y = l->touch_point_.y;
454 l->parent_->rotate_coordinates(data->point.x, data->point.y);
455 data->state = LV_INDEV_STATE_PRESSED;
456 } else {
457 data->state = LV_INDEV_STATE_RELEASED;
458 }
459 });
460}
461
463 this->touch_pressed_ = !this->parent_->is_paused() && !tpoints.empty();
464 if (this->touch_pressed_)
465 this->touch_point_ = tpoints[0];
466}
467#endif // USE_LVGL_TOUCHSCREEN
468
469#ifdef USE_LVGL_METER
470
471int16_t lv_get_needle_angle_for_value(lv_obj_t *obj, int32_t value) {
472 auto *scale = lv_obj_get_parent(obj);
473 auto min_value = lv_scale_get_range_min_value(scale);
474 auto max_value = lv_scale_get_range_max_value(scale);
475 value = clamp(value, min_value, max_value);
476 return ((value - min_value) * lv_scale_get_angle_range(scale) / (max_value - min_value) +
477 lv_scale_get_rotation((scale))) %
478 360;
479}
480
481void IndicatorLine::set_obj(lv_obj_t *lv_obj) {
482 LvCompound::set_obj(lv_obj);
483 lv_line_set_points(lv_obj, this->points_, 2);
484 lv_obj_add_event_cb(
485 lv_obj_get_parent(obj),
486 [](lv_event_t *e) {
487 auto *indicator = static_cast<IndicatorLine *>(lv_event_get_user_data(e));
488 indicator->update_length_();
489 ESP_LOGV(TAG, "Updated length, value = %d", indicator->angle_);
490 },
491 LV_EVENT_SIZE_CHANGED, this);
492}
493
495 auto angle = lv_get_needle_angle_for_value(this->obj, value);
496 if (angle != this->angle_) {
497 this->angle_ = angle;
498 this->update_length_();
499 }
500}
501
502void IndicatorLine::update_length_() {
503 auto cx = lv_obj_get_width(lv_obj_get_parent(this->obj)) / 2;
504 auto cy = lv_obj_get_height(lv_obj_get_parent(this->obj)) / 2;
505 auto radius = clamp_at_most(cx, cy);
506 auto length = lv_obj_get_style_length(this->obj, LV_PART_MAIN);
507 auto radial_offset = lv_obj_get_style_radial_offset(this->obj, LV_PART_MAIN);
508 if (LV_COORD_IS_PCT(radial_offset)) {
509 radial_offset = radius * LV_COORD_GET_PCT(radial_offset) / 100;
510 }
511 if (LV_COORD_IS_PCT(length)) {
512 length = radius * LV_COORD_GET_PCT(length) / 100;
513 } else if (length < 0) {
514 length += radius;
515 }
516 auto x = lv_trigo_cos(this->angle_) / 32768.0f;
517 auto y = lv_trigo_sin(this->angle_) / 32768.0f;
518 // radius here also represents the offset of the scale center from top left
519 this->points_[0].x = radius + radial_offset * x;
520 this->points_[0].y = radius + radial_offset * y;
521 this->points_[1].x = radius + x * (radial_offset + length);
522 this->points_[1].y = radius + y * (radial_offset + length);
523 lv_obj_refresh_self_size(this->obj);
524 lv_obj_invalidate(this->obj);
525}
526#endif
527
528#ifdef USE_LVGL_TABLE
530 uint32_t row;
531 uint32_t column;
532 lv_table_get_selected_cell(obj, &row, &column);
533 return row;
534}
535
537 uint32_t row;
538 uint32_t column;
539 lv_table_get_selected_cell(obj, &row, &column);
540 return column;
541}
542
543void LvTableType::set_obj(lv_obj_t *lv_obj) {
544 LvCompound::set_obj(lv_obj);
545 lv_obj_add_event_cb(
546 lv_obj,
547 [](lv_event_t *e) {
548 auto *table = static_cast<LvTableType *>(lv_event_get_user_data(e));
549 table->update_column_widths_();
550 },
551 LV_EVENT_SIZE_CHANGED, this);
552}
553
555 for (auto &i : this->column_pct_) {
556 if (i.col == col) {
557 i.pct = pct;
558 this->update_column_widths_();
559 return;
560 }
561 }
562 this->column_pct_.push_back({col, pct});
563 this->update_column_widths_();
564}
565
567 auto content_width = lv_obj_get_content_width(this->obj);
568 for (const auto &col : this->column_pct_) {
569 lv_table_set_column_width(this->obj, col.col, content_width * col.pct / 100);
570 }
571}
572#endif // USE_LVGL_TABLE
573
574#ifdef USE_LVGL_KEY_LISTENER
575LVEncoderListener::LVEncoderListener(lv_indev_type_t type, uint16_t long_press_time, uint16_t long_press_repeat_time) {
576 this->drv_ = lv_indev_create();
577 lv_indev_set_type(this->drv_, type);
578 lv_indev_set_long_press_time(this->drv_, long_press_time);
579 lv_indev_set_long_press_repeat_time(this->drv_, long_press_repeat_time);
580 lv_indev_set_user_data(this->drv_, this);
581 lv_indev_set_read_cb(this->drv_, [](lv_indev_t *d, lv_indev_data_t *data) {
582 auto *l = static_cast<LVEncoderListener *>(lv_indev_get_user_data(d));
583 data->state = l->pressed_ ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
584 data->key = l->key_;
585 data->enc_diff = (int16_t) (l->count_ - l->last_count_);
586 l->last_count_ = l->count_;
587 data->continue_reading = false;
588 });
589}
590#endif // USE_LVGL_KEY_LISTENER
591
592#if defined(USE_LVGL_DROPDOWN) || defined(LV_USE_ROLLER)
594 auto selected = this->get_selected_index();
595 if (selected >= this->options_.size())
596 return "";
597 return this->options_[selected];
598}
599
600static std::string join_string(const FixedVector<const char *> &options) {
601 return std::accumulate(
602 options.begin(), options.end(), std::string(),
603 [](const std::string &a, const char *b) -> std::string { return a + (!a.empty() ? "\n" : "") + b; });
604}
605
606void LvSelectable::set_selected_text(const std::string &text, lv_anim_enable_t anim) {
607 auto *index = std::find(this->options_.begin(), this->options_.end(), text);
608 if (index != this->options_.end()) {
609 this->set_selected_index(index - this->options_.begin(), anim);
610 lv_obj_send_event(this->obj, lv_update_event, nullptr);
611 }
612}
613
615 auto index = this->get_selected_index();
616 if (index >= options.size())
617 index = options.size() - 1;
618 this->options_ = std::move(options);
619 this->set_option_string(join_string(this->options_).c_str());
620 lv_obj_send_event(this->obj, LV_EVENT_REFRESH, nullptr);
621 this->set_selected_index(index, LV_ANIM_OFF);
622}
623#endif // USE_LVGL_DROPDOWN || LV_USE_ROLLER
624
625#ifdef USE_LVGL_BUTTONMATRIX
626void LvButtonMatrixType::set_obj(lv_obj_t *lv_obj) {
627 LvCompound::set_obj(lv_obj);
628 lv_obj_add_event_cb(
629 lv_obj,
630 [](lv_event_t *event) {
631 auto *self = static_cast<LvButtonMatrixType *>(lv_event_get_user_data(event));
632 if (self->key_callback_.size() == 0)
633 return;
634 auto key_idx = lv_buttonmatrix_get_selected_button(self->obj);
635 if (key_idx == LV_BUTTONMATRIX_BUTTON_NONE)
636 return;
637 if (self->key_map_.contains(key_idx)) {
638 self->send_key_(self->key_map_[key_idx]);
639 return;
640 }
641 const auto *str = lv_buttonmatrix_get_button_text(self->obj, key_idx);
642 auto len = strlen(str);
643 while (len--)
644 self->send_key_(*str++);
645 },
646 LV_EVENT_PRESSED, this);
647}
648#endif // USE_LVGL_BUTTONMATRIX
649
650#ifdef USE_LVGL_KEYBOARD
651static const char *const KB_SPECIAL_KEYS[] = {
652 "abc", "ABC", "1#",
653 // maybe add other special keys here
654};
655
656void LvKeyboardType::set_obj(lv_obj_t *lv_obj) {
657 LvCompound::set_obj(lv_obj);
658 lv_obj_add_event_cb(
659 lv_obj,
660 [](lv_event_t *event) {
661 auto *self = static_cast<LvKeyboardType *>(lv_event_get_user_data(event));
662 if (self->key_callback_.size() == 0)
663 return;
664
665 auto key_idx = lv_buttonmatrix_get_selected_button(self->obj);
666 if (key_idx == LV_BUTTONMATRIX_BUTTON_NONE)
667 return;
668 const char *txt = lv_buttonmatrix_get_button_text(self->obj, key_idx);
669 if (txt == nullptr)
670 return;
671 for (const auto *kb_special_key : KB_SPECIAL_KEYS) {
672 if (strcmp(txt, kb_special_key) == 0)
673 return;
674 }
675 while (*txt != 0)
676 self->send_key_(*txt++);
677 },
678 LV_EVENT_PRESSED, this);
679}
680#endif // USE_LVGL_KEYBOARD
681
683 if (this->draw_end_callback_ != nullptr)
685 // Only reachable once the display is idle again: while busy, the display's refr_timer_ is
686 // paused (see loop()), so LVGL never renders/flushes and this event never fires.
687 if (this->update_when_display_idle_) {
688 for (auto *disp : this->displays_)
689 disp->update();
690 }
691}
692
694 if (!this->update_when_display_idle_)
695 return false;
696 for (auto *disp : this->displays_) {
697 if (!disp->is_idle())
698 return true;
699 }
700 return false;
701}
702
704 int iterations = 6 - lv_display_get_inactive_time(this->disp_) / 60000;
705 if (iterations <= 0)
706 iterations = 1;
707 int16_t width = lv_display_get_horizontal_resolution(this->disp_);
708 int16_t height = lv_display_get_vertical_resolution(this->disp_);
709 while (iterations-- != 0) {
710 int32_t col = random_uint32() % width;
711 col = col / this->draw_rounding * this->draw_rounding;
712 int32_t row = random_uint32() % height;
713 row = row / this->draw_rounding * this->draw_rounding;
714 // size will be between 8 and 32, and a multiple of draw_rounding
715 int32_t size = (random_uint32() % 25 + 8) / this->draw_rounding * this->draw_rounding;
716 lv_area_t area{.x1 = col, .y1 = row, .x2 = col + size - 1, .y2 = row + size - 1};
717 // clip to display bounds just in case
718 if (area.x2 >= width)
719 area.x2 = width - 1;
720 if (area.y2 >= height)
721 area.y2 = height - 1;
722
723 // line_len can't exceed 1024, and minimum buffer size is 2048, so this won't overflow the buffer
724 size_t line_len = lv_area_get_width(&area) * lv_area_get_height(&area) / 2;
725 for (size_t i = 0; i != line_len; i++) {
726 reinterpret_cast<uint32_t *>(this->draw_buf_)[i] = random_uint32();
727 }
728 this->draw_buffer_(&area, reinterpret_cast<lv_color_data *>(this->draw_buf_));
729 }
730}
731
753LvglComponent::LvglComponent(std::vector<display::Display *> displays, float buffer_frac, bool full_refresh,
754 int draw_rounding, bool resume_on_input, bool update_when_display_idle,
755 RotationType rotation_type)
756 : draw_rounding(draw_rounding),
757 displays_(std::move(displays)),
758 buffer_frac_(buffer_frac),
759 full_refresh_(full_refresh),
760 resume_on_input_(resume_on_input),
761 update_when_display_idle_(update_when_display_idle),
762 rotation_type_(rotation_type) {
763 this->disp_ = lv_display_create(240, 240);
764}
765
767 int32_t width = this->width_;
768 int32_t height = this->height_;
771 std::swap(width, height);
772 }
773 ESP_LOGD(TAG, "Setting resolution to %u x %u (rotation %d)", (unsigned) width, (unsigned) height,
774 (int) this->rotation_);
776 for (auto *display : this->displays_)
777 display->set_rotation(this->rotation_);
778 }
779 lv_display_set_resolution(this->disp_, width, height);
780}
781
783 // A square display is treated as landscape.
785 if (orientation == this->orientation_)
786 return;
789 if (trigger != nullptr)
790 trigger->trigger();
791}
792
794 auto *display = this->displays_[0];
795 auto rounding = this->draw_rounding;
796 this->width_ = display->get_native_width();
797 this->height_ = display->get_native_height();
798 // cater for displays with dimensions that don't divide by the required rounding
799 auto width = (this->width_ + rounding - 1) / rounding * rounding;
800 auto height = (this->height_ + rounding - 1) / rounding * rounding;
801 auto frac = this->buffer_frac_;
802 if (frac == 0)
803 frac = 1;
804 auto buf_bytes = clamp_at_least(width * height / frac * LV_COLOR_DEPTH / 8, MIN_BUFFER_SIZE);
805 void *buffer = nullptr;
806 // for small buffers, try to allocate in internal memory first to improve performance
807 if (this->buffer_frac_ >= MIN_BUFFER_FRAC / 2)
808 buffer = lv_alloc_draw_buf(buf_bytes, true); // NOLINT
809 if (buffer == nullptr)
810 buffer = lv_alloc_draw_buf(buf_bytes, false); // NOLINT
811 // if specific buffer size not set and can't get 100%, try for a smaller one
812 if (buffer == nullptr && this->buffer_frac_ == 0) {
813 frac = MIN_BUFFER_FRAC;
814 buf_bytes /= MIN_BUFFER_FRAC;
815 buffer = lv_alloc_draw_buf(buf_bytes, false); // NOLINT
816 }
817 this->buffer_frac_ = frac;
818 if (buffer == nullptr) {
819 this->status_set_error(LOG_STR("Memory allocation failure"));
820 this->mark_failed();
821 return;
822 }
823 this->draw_buf_ = static_cast<uint8_t *>(buffer);
824 this->set_resolution_();
825 lv_display_set_color_format(this->disp_, LV_COLOR_FORMAT_RGB565);
826 lv_display_set_flush_cb(this->disp_, static_flush_cb);
827 lv_display_set_user_data(this->disp_, this);
828 lv_display_add_event_cb(this->disp_, rounder_cb, LV_EVENT_INVALIDATE_AREA, this);
829 lv_display_set_buffers(this->disp_, this->draw_buf_, nullptr, buf_bytes,
830 this->full_refresh_ ? LV_DISPLAY_RENDER_MODE_FULL : LV_DISPLAY_RENDER_MODE_PARTIAL);
831 if (this->rotation_type_ == ROTATION_SOFTWARE) {
832 this->rotate_buf_ = static_cast<lv_color_t *>(lv_alloc_draw_buf(buf_bytes, false)); // NOLINT
833 if (this->rotate_buf_ == nullptr) {
834 this->status_set_error(LOG_STR("Memory allocation failure"));
835 this->mark_failed();
836 return;
837 }
838#ifdef USE_ESP32_VARIANT_ESP32P4
839 ppa_client_config_t ppa_config{};
840 ppa_config.oper_type = PPA_OPERATION_SRM;
841 ppa_config.max_pending_trans_num = 1;
842 if (ppa_register_client(&ppa_config, &this->ppa_client_) != ESP_OK) {
843 ESP_LOGW(TAG, "PPA client registration failed, using software rotation");
844 this->ppa_client_ = nullptr;
845 }
846#endif
847 }
848 if (this->draw_start_callback_ != nullptr) {
849 lv_display_add_event_cb(this->disp_, render_start_cb, LV_EVENT_RENDER_START, this);
850 }
851 if (this->draw_end_callback_ != nullptr || this->update_when_display_idle_) {
852 lv_display_add_event_cb(this->disp_, render_end_cb, LV_EVENT_REFR_READY, this);
853 }
854 this->refr_timer_ = lv_display_get_refr_timer(this->disp_);
855 lv_timer_set_period(this->refr_timer_, this->refr_timer_period_);
856#if LV_USE_LOG
857 lv_log_register_print_cb([](lv_log_level_t level, const char *buf) {
858 auto next = strchr(buf, ')');
859 if (next != nullptr)
860 buf = next + 1;
861 while (isspace(*buf))
862 buf++;
863 if (level >= sizeof(LOG_LEVEL_MAP) / sizeof(LOG_LEVEL_MAP[0]))
864 level = sizeof(LOG_LEVEL_MAP) / sizeof(LOG_LEVEL_MAP[0]) - 1;
865 esp_log_printf_(LOG_LEVEL_MAP[level], TAG, 0, "%.*s", (int) strlen(buf) - 1, buf);
866 });
867#endif
868 this->show_page(0, LV_SCREEN_LOAD_ANIM_NONE, 0);
869 lv_display_trigger_activity(this->disp_);
870 this->update_orientation_();
871}
872
874 // update indicators
875 if (this->is_paused()) {
876 return;
877 }
878 this->idle_callbacks_.call(lv_display_get_inactive_time(this->disp_));
879}
880
882 if (this->paused_) {
883 if (this->show_snow_)
884 this->write_random_();
885 return;
886 }
887 // Pause/resume the display's own refresh timer to track its busy state. While paused, LVGL
888 // still keeps track of invalidated areas but won't render or flush them, so nothing needs to
889 // be discarded or replayed: once resumed, the accumulated areas are simply drawn as normal.
890 // Input events and other timers keep being processed below regardless of this state.
891 if (this->update_when_display_idle_) {
892 bool busy = this->displays_busy_();
893 if (busy && !this->refr_timer_paused_) {
894 this->refr_timer_paused_ = true;
895 // calling lv_timer_pause() here would be ineffective; LVGL pauses and resumes the timer based on its own internal
896 // state, which is not aware of the display's busy state. Instead, we extend the timer period to avoid it firing
897 // while the display is busy.
898 lv_timer_set_period(this->refr_timer_, 5 * 60 * 1000);
899 } else if (!busy && this->refr_timer_paused_) {
900 this->refr_timer_paused_ = false;
901 lv_timer_set_period(this->refr_timer_, this->refr_timer_period_);
902 // Don't wait for the timer's next natural period: refresh right away now that the
903 // display is idle again.
904 lv_timer_ready(this->refr_timer_);
905 }
906 }
907 lv_timer_handler();
908}
909
910#ifdef USE_LVGL_ANIMIMG
911void lv_animimg_stop(lv_obj_t *obj) {
912 int32_t duration = lv_animimg_get_duration(obj);
913 lv_animimg_set_duration(obj, 0);
914 lv_animimg_start(obj);
915 lv_animimg_set_duration(obj, duration);
916}
917#endif
918void LvglComponent::static_flush_cb(lv_display_t *disp_drv, const lv_area_t *area, uint8_t *color_p) {
919 reinterpret_cast<LvglComponent *>(lv_display_get_user_data(disp_drv))->flush_cb_(disp_drv, area, color_p);
920}
921
922#ifdef USE_LVGL_SCALE
930void lv_scale_draw_event_cb(lv_event_t *e, int16_t range_start, int16_t range_end, lv_color_t color_start,
931 lv_color_t color_end, int width, bool local) {
932 auto *scale = static_cast<lv_obj_t *>(lv_event_get_target(e));
933 lv_draw_task_t *task = lv_event_get_draw_task(e);
934
935 if (lv_draw_task_get_type(task) == LV_DRAW_TASK_TYPE_LINE) {
936 auto *line_dsc = static_cast<lv_draw_line_dsc_t *>(lv_draw_task_get_draw_dsc(task));
937 int tick = line_dsc->base.id2;
938 if (tick >= range_start && tick <= range_end) {
939 int ratio;
940 if (local) {
941 int range = range_end - range_start;
942 tick -= range_start;
943 ratio = range == 0 ? 0 : (tick * 255) / range;
944 } else {
945 // total tick count is guaranteed to be at least 2.
946 ratio = (line_dsc->base.id1 * 255) / (lv_scale_get_total_tick_count(scale) - 1);
947 }
948 line_dsc->color = lv_color_mix(color_end, color_start, ratio);
949 line_dsc->width += width;
950 }
951 }
952}
953#endif // USE_LVGL_SCALE
954
955#ifdef USE_LVGL_GRADIENT
963lv_color_t lv_grad_calculate_color(const lv_grad_dsc_t *dsc, int32_t pos) {
964 if (dsc->stops_count == 0)
965 return lv_color_black();
966 if (dsc->stops_count == 1 || pos <= dsc->stops[0].frac)
967 return dsc->stops[0].color;
968 if (pos >= dsc->stops[dsc->stops_count - 1].frac)
969 return dsc->stops[dsc->stops_count - 1].color;
970 int i = 1;
971 while (i < dsc->stops_count && dsc->stops[i].frac < pos)
972 i++;
973 auto *stop1 = &dsc->stops[i - 1];
974 auto *stop2 = &dsc->stops[i];
975 int32_t range = stop2->frac - stop1->frac;
976 int32_t offset = pos - stop1->frac;
977 return lv_color_mix(stop2->color, stop1->color, range == 0 ? 0 : (offset * 255) / range);
978}
979#endif // USE_LVGL_GRADIENT
980
982 auto *indev = lv_indev_get_act();
983 if (indev == nullptr) {
984 return {INT32_MAX, INT32_MAX};
985 }
986 lv_point_t point;
987 lv_indev_get_point(indev, &point);
988 lv_area_t coords;
989 lv_obj_get_coords(obj, &coords);
990 point.x -= coords.x1;
991 point.y -= coords.y1;
992 return point;
993}
994
995static void lv_container_constructor(const lv_obj_class_t *class_p, lv_obj_t *obj) {
996 LV_TRACE_OBJ_CREATE("begin");
997 LV_UNUSED(class_p);
998}
999
1000// Container class. Name is based on LVGL naming convention but upper case to keep ESPHome clang-tidy happy
1001const lv_obj_class_t LV_CONTAINER_CLASS = {
1002 .base_class = &lv_obj_class,
1003 .constructor_cb = lv_container_constructor,
1004 .name = "lv_container",
1005};
1006
1007lv_obj_t *lv_container_create(lv_obj_t *parent) {
1008 lv_obj_t *obj = lv_obj_class_create_obj(&LV_CONTAINER_CLASS, parent);
1009 lv_obj_class_init_obj(obj);
1010 return obj;
1011}
1012
1013#ifdef USE_LVGL_LIST
1014int lv_list_get_row_index(lv_obj_t *list, lv_obj_t *child) {
1015 for (lv_obj_t *obj = child; obj != nullptr; obj = lv_obj_get_parent(obj)) {
1016 if (lv_obj_get_parent(obj) == list)
1017 return lv_obj_get_index(obj);
1018 }
1019 ESP_LOGW(TAG, "lvgl.list: entry is not inside the list it was added to");
1020 return -1;
1021}
1022
1023lv_obj_t *lv_list_get_row_for_remove(lv_obj_t *list, int index) {
1024 lv_obj_t *child = index < 0 ? nullptr : lv_obj_get_child(list, index);
1025 if (child == nullptr) {
1026 ESP_LOGW(TAG, "lvgl.list.remove: index %d is out of range, ignoring", index);
1027 }
1028 return child;
1029}
1030#endif // USE_LVGL_LIST
1031} // namespace esphome::lvgl
1032
1033lv_result_t lv_mem_test_core() { return LV_RESULT_OK; }
1034
1036
1038
1039#if defined(USE_HOST) || defined(USE_RP2) || defined(USE_ESP8266)
1040void *lv_malloc_core(size_t size) {
1041 auto *ptr = malloc(size); // NOLINT
1042 if (ptr == nullptr) {
1043 ESP_LOGE(esphome::lvgl::TAG, "Failed to allocate %zu bytes", size);
1044 }
1045 return ptr;
1046}
1047void lv_free_core(void *ptr) { return free(ptr); } // NOLINT
1048void *lv_realloc_core(void *ptr, size_t size) { return realloc(ptr, size); } // NOLINT
1049
1050void lv_mem_monitor_core(lv_mem_monitor_t *mon_p) { memset(mon_p, 0, sizeof(lv_mem_monitor_t)); }
1051static void *lv_alloc_draw_buf(size_t size, bool internal) {
1052 return malloc(size); // NOLINT
1053}
1054
1055#elif defined(USE_ESP32)
1056static unsigned cap_bits = MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT; // NOLINT
1057
1058static void *lv_alloc_draw_buf(size_t size, bool internal) {
1059 void *buffer;
1060 size = LV_ROUND_UP(size, LV_DRAW_BUF_ALIGN);
1061 buffer = heap_caps_aligned_alloc(LV_DRAW_BUF_ALIGN, size, internal ? MALLOC_CAP_8BIT : cap_bits); // NOLINT
1062 if (buffer == nullptr) {
1063 ESP_LOGW(esphome::lvgl::TAG, "Failed to allocate %zu bytes for %sdraw buffer", size, internal ? "internal " : "");
1064 }
1065 return buffer;
1066}
1067
1068void lv_mem_monitor_core(lv_mem_monitor_t *mon_p) {
1069 multi_heap_info_t heap_info;
1070 heap_caps_get_info(&heap_info, cap_bits);
1071 mon_p->total_size = heap_info.total_allocated_bytes + heap_info.total_free_bytes;
1072 mon_p->free_size = heap_info.total_free_bytes;
1073 mon_p->max_used = heap_info.total_allocated_bytes;
1074 mon_p->free_biggest_size = heap_info.largest_free_block;
1075 mon_p->used_cnt = heap_info.allocated_blocks;
1076 mon_p->free_cnt = heap_info.free_blocks;
1077 mon_p->used_pct = heap_info.allocated_blocks * 100 / (heap_info.allocated_blocks + heap_info.free_blocks);
1078 mon_p->frag_pct = 0;
1079}
1080
1081void *lv_malloc_core(size_t size) {
1082 void *ptr;
1083 ptr = heap_caps_malloc(size, cap_bits);
1084 if (ptr == nullptr) {
1085 cap_bits = MALLOC_CAP_8BIT;
1086 ptr = heap_caps_malloc(size, cap_bits);
1087 }
1088 if (ptr == nullptr) {
1089 ESP_LOGE(esphome::lvgl::TAG, "Failed to allocate %zu bytes", size);
1090 return nullptr;
1091 }
1092 ESP_LOGV(esphome::lvgl::TAG, "allocate %zu - > %p", size, ptr);
1093 return ptr;
1094}
1095
1096void lv_free_core(void *ptr) {
1097 ESP_LOGV(esphome::lvgl::TAG, "free %p", ptr);
1098 if (ptr == nullptr)
1099 return;
1100 heap_caps_free(ptr);
1101}
1102
1103void *lv_realloc_core(void *ptr, size_t size) {
1104 ESP_LOGV(esphome::lvgl::TAG, "realloc %p: %zu", ptr, size);
1105 return heap_caps_realloc(ptr, size, cap_bits);
1106}
1107#endif
uint8_t l
Definition bl0906.h:0
void mark_failed()
Mark this component as failed.
bool is_ready() const
Fixed-capacity vector - allocates once at runtime, never reallocates This avoids std::vector template...
Definition helpers.h:545
size_t size() const
Definition helpers.h:711
void set_parent(T *parent)
Set the parent of this object.
Definition helpers.h:1918
Function-pointer-only templatable storage (4 bytes on 32-bit).
Definition automation.h:19
T value(X... x) const
Definition automation.h:58
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Inform the parent automation that the event has triggered.
Definition automation.h:461
TemplatableFn< uint32_t > timeout_
IdleTrigger(LvglComponent *parent, TemplatableFn< uint32_t > timeout)
void set_obj(lv_obj_t *lv_obj) override
LVEncoderListener(lv_indev_type_t type, uint16_t long_press_time, uint16_t long_press_repeat_time)
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)
FixedVector< const char * > 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
void set_options(FixedVector< const char * > options)
void set_obj(lv_obj_t *lv_obj) override
void add_column_width_pct(uint32_t col, uint8_t pct)
FixedVector< ColumnPct > column_pct_
Component for rendering LVGL.
void set_paused(bool paused, bool show_snow)
display::DisplayRotation rotation_
void rotate_coordinates(int32_t &x, int32_t &y) const
std::vector< LvPageType * > pages_
void set_rotation(display::DisplayRotation rotation)
bool ppa_rotate_(const lv_color_data *src, lv_color_data *dst, uint16_t width, uint16_t height, uint32_t height_rounded)
CallbackManager< void(uint32_t)> idle_callbacks_
void show_next_page(lv_screen_load_anim_t anim, uint32_t time)
std::vector< display::Display * > displays_
static void esphome_lvgl_init()
Initialize the LVGL library and register custom events.
void show_prev_page(lv_screen_load_anim_t anim, uint32_t time)
ppa_client_handle_t ppa_client_
LvglComponent(std::vector< display::Display * > displays, float buffer_frac, bool full_refresh, int draw_rounding, bool resume_on_input, bool update_when_display_idle, RotationType rotation_type)
static void render_start_cb(lv_event_t *event)
static lv_point_t get_touch_relative_to_obj(lv_obj_t *obj)
void add_on_idle_callback(F &&callback)
void add_page(LvPageType *page)
static void static_flush_cb(lv_display_t *disp_drv, const lv_area_t *area, uint8_t *color_p)
static void render_end_cb(lv_event_t *event)
void draw_buffer_(const lv_area_t *area, lv_color_data *ptr)
void show_page(size_t index, lv_screen_load_anim_t anim, uint32_t time)
static void add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event, void *user_data=nullptr)
void flush_cb_(lv_display_t *disp_drv, const lv_area_t *area, uint8_t *color_p)
uint16_t type
uint8_t options
int ret
void lv_mem_deinit()
void lv_mem_init()
void lv_free_core(void *ptr)
void * lv_malloc_core(size_t size)
void lv_mem_monitor_core(lv_mem_monitor_t *mon_p)
void * lv_realloc_core(void *ptr, size_t size)
lv_result_t lv_mem_test_core()
Range range
Definition msa3xx.h:0
uint8_t duration
Definition msa3xx.h:0
@ DISPLAY_ROTATION_270_DEGREES
Definition display.h:137
@ DISPLAY_ROTATION_180_DEGREES
Definition display.h:136
@ DISPLAY_ROTATION_90_DEGREES
Definition display.h:135
lv_color_t lv_grad_calculate_color(const lv_grad_dsc_t *dsc, int32_t pos)
void lv_animimg_stop(lv_obj_t *obj)
uint16_t lv_color_data
int lv_list_get_row_index(lv_obj_t *list, lv_obj_t *child)
void(lv_event_t *) event_callback_t
const lv_obj_class_t LV_CONTAINER_CLASS
uint32_t lv_table_get_selected_row(lv_obj_t *obj)
lv_event_code_t lv_update_event
int16_t lv_get_needle_angle_for_value(lv_obj_t *obj, int32_t value)
lv_obj_t * lv_container_create(lv_obj_t *parent)
lv_obj_t * lv_list_get_row_for_remove(lv_obj_t *list, int index)
std::string lv_event_code_name_for(lv_event_t *event)
void lv_scale_draw_event_cb(lv_event_t *e, int16_t range_start, int16_t range_end, lv_color_t color_start, lv_color_t color_end, int width, bool local)
Function to apply colors to ticks based on position.
uint32_t lv_table_get_selected_column(lv_obj_t *obj)
std::vector< TouchPoint > TouchPoints_t
Definition touchscreen.h:29
T clamp_at_most(T value, U max)
Definition helpers.h:2245
void HOT esp_log_printf_(int level, const char *tag, int line, const char *format,...)
Definition log.cpp:21
const void size_t len
Definition hal.h:64
uint16_t size
Definition helpers.cpp:25
T clamp_at_least(T value, U min)
Definition helpers.h:2240
uint32_t random_uint32()
Return a random 32-bit unsigned integer.
Definition helpers.cpp:12
size_t size_t pos
Definition helpers.h:1092
const void * src
Definition hal.h:64
uint32_t IRAM_ATTR HOT millis()
Definition hal.cpp:28
STL namespace.
static void uint32_t
uint16_t length
Definition tt21100.cpp:0
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6
uint8_t orientation
Definition tt21100.cpp:9