ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
lvgl_esphome.h
Go to the documentation of this file.
1#pragma once
3
4#ifdef USE_BINARY_SENSOR
6#endif // USE_BINARY_SENSOR
7#ifdef USE_IMAGE
9#endif // USE_IMAGE
10#ifdef USE_LVGL_ROTARY_ENCODER
12#endif // USE_LVGL_ROTARY_ENCODER
13
14// required for clang-tidy
15#ifndef LV_CONF_H
16#define LV_CONF_SKIP 1 // NOLINT
17#endif // LV_CONF_H
18
22
23#include <list>
24#include <lvgl.h>
25#include <map>
26#include <utility>
27#include <vector>
28
29#ifdef USE_ESP32_VARIANT_ESP32P4
30#include "driver/ppa.h"
31#endif
32
33#ifdef USE_FONT
35#endif // USE_FONT
36#ifdef USE_TOUCHSCREEN
38#endif // USE_TOUCHSCREEN
39
40#if defined(USE_LVGL_BUTTONMATRIX) || defined(USE_LVGL_KEYBOARD)
42#endif // USE_LVGL_BUTTONMATRIX
43
44namespace esphome::lvgl {
45
46#if LV_COLOR_DEPTH == 16
47using lv_color_data = uint16_t;
48#endif
49#if LV_COLOR_DEPTH == 32
51#endif
52
53extern lv_event_code_t lv_update_event; // NOLINT
54extern std::string lv_event_code_name_for(lv_event_t *event);
55
56lv_obj_t *lv_container_create(lv_obj_t *parent);
57#ifdef USE_LVGL_SCALE
58void lv_scale_draw_event_cb(lv_event_t *e, int16_t range_start, int16_t range_end, lv_color_t color_start,
59 lv_color_t color_end, int width, bool local);
60#endif
61#ifdef USE_LVGL_TABLE
64#endif
65#if LV_COLOR_DEPTH == 16
67#elif LV_COLOR_DEPTH == 32
69#else // LV_COLOR_DEPTH
71#endif // LV_COLOR_DEPTH
72
73#if defined(USE_FONT) && defined(USE_LVGL_FONT)
74inline void lv_obj_set_style_text_font(lv_obj_t *obj, const font::Font *font, lv_style_selector_t part) {
75 lv_obj_set_style_text_font(obj, font->get_lv_font(), part);
76}
77inline void lv_style_set_text_font(lv_style_t *style, const font::Font *font) {
78 lv_style_set_text_font(style, font->get_lv_font());
79}
80#endif
81
82#ifdef USE_IMAGE
83#ifdef USE_LVGL_IMAGE
84// Shortcut / overload, so that the source of an image widget can easily be updated from within a lambda.
85inline void lv_image_set_src(lv_obj_t *obj, image::Image *image) {
87 image->add_lvgl_widget(obj);
88}
89
90inline void lv_obj_set_style_bitmap_mask_src(lv_obj_t *obj, image::Image *image, lv_style_selector_t selector) {
92}
93
94inline void lv_obj_set_style_bg_image_src(lv_obj_t *obj, image::Image *image, lv_style_selector_t selector) {
96}
97inline void lv_style_set_bg_image_src(lv_style_t *style, image::Image *image) {
99}
100inline void lv_style_set_bitmap_mask_src(lv_style_t *style, image::Image *image) {
102}
103#endif
104
105#ifdef USE_LVGL_ANIMIMG
106inline void lv_animimg_set_src(lv_obj_t *img, std::vector<image::Image *> images) {
107 auto *dsc = static_cast<std::vector<lv_image_dsc_t *> *>(lv_obj_get_user_data(img));
108 if (dsc == nullptr) {
109 // object will be lazily allocated but never freed.
110 dsc = new std::vector<lv_image_dsc_t *>(images.size()); // NOLINT
111 lv_obj_set_user_data(img, dsc);
112 }
113 dsc->clear();
114 for (auto &image : images) {
115 dsc->push_back(image->get_lv_image_dsc());
116 }
117 lv_animimg_set_src(img, (const void **) dsc->data(), dsc->size());
118}
119#endif // USE_LVGL_ANIMIMG
120#endif // USE_IMAGE
121
122#ifdef USE_LVGL_METER
123int16_t lv_get_needle_angle_for_value(lv_obj_t *obj, int32_t value);
124#endif
125
126#ifdef USE_LVGL_LIST
127// Returns the index, within `list`, of the entry that contains `child`: `child` itself if it's a
128// direct child of `list`, or the ancestor of `child` that is, when `child` is nested inside a
129// widget hierarchy added via `lvgl.list.add`. Returns -1 if `child` isn't inside `list` at all.
130int lv_list_get_row_index(lv_obj_t *list, lv_obj_t *child);
131
132// Returns the entry at `index` within `list`, or nullptr (logging why) if `index` is out of
133// range -- shared by every `lvgl.list.remove` call site, since a templatable index can go out of
134// range at runtime in ways config validation can't catch (e.g. driven by a sensor value).
135lv_obj_t *lv_list_get_row_for_remove(lv_obj_t *list, int index);
136#endif
137
138#ifdef USE_LVGL_GRADIENT
146lv_color_t lv_grad_calculate_color(const lv_grad_dsc_t *dsc, int32_t pos);
147#endif // USE_LVGL_GRADIENT
148
149#ifdef USE_LVGL_MENU
150// True if `e` is a click on `menu`'s back button while already at the root page -- the one
151// case LVGL's own docs say the app must handle itself (there is no default behavior).
152bool lv_menu_back_button_is_root_click(lv_obj_t *menu, lv_event_t *e);
153#endif // USE_LVGL_MENU
154
155// Parent class for things that wrap an LVGL object
157 public:
158 virtual ~LvCompound() = default;
159 virtual void set_obj(lv_obj_t *lv_obj) { this->obj = lv_obj; }
160 lv_obj_t *obj{};
161};
162
163// Frees a heap-allocated LvCompound wrapper on LV_EVENT_DELETE, since lv_obj_del() only knows how to destroy LVGL's own
164// object tree, not a separate C++ object paired with one of its nodes.
165template<typename T> void delete_lv_compound_on_delete(lv_event_t *e) {
166 delete static_cast<T *>(lv_event_get_user_data(e));
167}
168
169class LvglComponent;
170
171class LvPageType : public Parented<LvglComponent> {
172 public:
174
175 void setup(size_t index) {
176 this->index = index;
177 this->obj = lv_obj_create(nullptr);
178 }
179
180 bool is_showing() const;
181
182 lv_obj_t *obj{};
183 size_t index{};
184 bool skip;
185};
186
187using event_callback_t = void(lv_event_t *);
188
189class LvLambdaComponent final : public Component {
190 public:
191 LvLambdaComponent(void (*callback)()) : callback_(callback) {}
192
193 void setup() override { this->callback_(); }
194 // execute after the LvglComponent is setup
195 float get_setup_priority() const override { return setup_priority::PROCESSOR - 5; }
196
197 protected:
198 void (*callback_)();
199};
200
201template<typename... Ts> class ObjUpdateAction final : public Action<Ts...> {
202 public:
203 explicit ObjUpdateAction(std::function<void(Ts...)> &&lamb) : lamb_(std::move(lamb)) {}
204
205 protected:
206 void play(const Ts &...x) override { this->lamb_(x...); }
207
208 std::function<void(Ts...)> lamb_;
209};
210#ifdef USE_LVGL_ANIMIMG
211void lv_animimg_stop(lv_obj_t *obj);
212#endif // USE_LVGL_ANIMIMG
218
219enum class Orientation : uint8_t {
220 UNKNOWN,
221 LANDSCAPE,
222 PORTRAIT,
223};
224
225class LvglComponent final : public PollingComponent {
226 constexpr static const char *const TAG = "lvgl"; // NOLINT: lvgl does not build for ESP8266
227
228 public:
229 LvglComponent(std::vector<display::Display *> displays, float buffer_frac, bool full_refresh, int draw_rounding,
230 bool resume_on_input, bool update_when_display_idle, RotationType rotation_type);
231 static void static_flush_cb(lv_display_t *disp_drv, const lv_area_t *area, uint8_t *color_p);
237 static lv_point_t get_touch_relative_to_obj(lv_obj_t *obj);
238
239 float get_setup_priority() const override { return setup_priority::PROCESSOR; }
240 void setup() override;
241 void update() override;
242 void loop() override;
243 template<typename F> void add_on_idle_callback(F &&callback) { this->idle_callbacks_.add(std::forward<F>(callback)); }
244
245 static void render_end_cb(lv_event_t *event);
246 static void render_start_cb(lv_event_t *event);
247 void dump_config() override;
248 lv_display_t *get_disp() { return this->disp_; }
249 lv_obj_t *get_screen_active() { return lv_display_get_screen_active(this->disp_); }
250 // Pause or resume the display.
251 // @param paused If true, pause the display. If false, resume the display.
252 // @param show_snow If true, show the snow effect when paused.
253 void set_paused(bool paused, bool show_snow);
255 this->refr_timer_period_ = period;
256 if (this->refr_timer_ != nullptr)
257 lv_timer_set_period(this->refr_timer_, period);
258 }
259
260 // Returns true if the display has been explicitly paused via set_paused().
261 bool is_paused() const { return this->paused_; }
262 // If the display is paused and we have resume_on_input_ set to true, resume the display.
264 if (this->paused_ && this->resume_on_input_) {
265 this->set_paused(false, false);
266 }
267 }
268
272 static void esphome_lvgl_init();
273
274 // Convenience overloads for adding a callback for one or more events
275 static void add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event, void *user_data = nullptr);
276 static void add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event1, lv_event_code_t event2,
277 void *user_data = nullptr);
278 static void add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event1, lv_event_code_t event2,
279 lv_event_code_t event3, void *user_data = nullptr);
280
281 // Set or clear LV_OBJ_FLAG_LAYOUT_2, LV_OBJ_FLAG_WIDGET_1 or LV_OBJ_FLAG_WIDGET_2, which have no setter in LVGL 9.6
282 static void lv_obj_set_custom_flag(lv_obj_t *obj, lv_obj_flag_t flag, bool value);
283
284 // change the state of a widget and fire an event if changed (only needed for CHECKED)
285
286 static void lv_obj_set_state_value(lv_obj_t *obj, lv_state_t state, bool value) {
287 if (value != lv_obj_has_state(obj, state)) {
288 if (value) {
289 lv_obj_add_state(obj, state);
290 } else {
291 lv_obj_remove_state(obj, state);
292 }
293 if (state == LV_STATE_CHECKED)
294 lv_obj_send_event(obj, lv_update_event, nullptr);
295 }
296 }
297
298 // change the state of a buttonmatrix button and fire an event if changed (only needed for CHECKED)
299#ifdef USE_LVGL_BUTTONMATRIX
300 static void lv_buttonmatrix_set_button_ctrl_value(lv_obj_t *obj, uint32_t index, lv_buttonmatrix_ctrl_t ctrl,
301 bool value) {
302 if (value != lv_buttonmatrix_has_button_ctrl(obj, index, ctrl)) {
303 if (value) {
304 lv_buttonmatrix_set_button_ctrl(obj, index, ctrl);
305 } else {
306 lv_buttonmatrix_clear_button_ctrl(obj, index, ctrl);
307 }
308 if (ctrl == LV_BUTTONMATRIX_CTRL_CHECKED)
309 lv_obj_send_event(obj, lv_update_event, nullptr);
310 }
311 }
312#endif
313
314 void add_page(LvPageType *page);
315 void show_page(size_t index, lv_screen_load_anim_t anim, uint32_t time);
316 void show_next_page(lv_screen_load_anim_t anim, uint32_t time);
317 void show_prev_page(lv_screen_load_anim_t anim, uint32_t time);
318 void set_page_wrap(bool wrap) { this->page_wrap_ = wrap; }
319 void set_big_endian(bool big_endian) { this->big_endian_ = big_endian; }
320 size_t get_current_page() const;
321 void set_focus_mark(lv_group_t *group) { this->focus_marks_[group] = lv_group_get_focused(group); }
322 void restore_focus_mark(lv_group_t *group) {
323 auto *mark = this->focus_marks_[group];
324 if (mark != nullptr) {
325 lv_group_focus_obj(mark);
326 }
327 }
328 // rounding factor to align bounds of update area when drawing
329 size_t draw_rounding{2};
330
331 void set_pause_trigger(Trigger<> *trigger) { this->pause_callback_ = trigger; }
332 void set_resume_trigger(Trigger<> *trigger) { this->resume_callback_ = trigger; }
333 void set_draw_start_trigger(Trigger<> *trigger) { this->draw_start_callback_ = trigger; }
334 void set_draw_end_trigger(Trigger<> *trigger) { this->draw_end_callback_ = trigger; }
335 void set_landscape_trigger(Trigger<> *trigger) { this->landscape_callback_ = trigger; }
336 void set_portrait_trigger(Trigger<> *trigger) { this->portrait_callback_ = trigger; }
339 void set_rotation(int angle);
341 void rotate_coordinates(int32_t &x, int32_t &y) const;
342
343 uint16_t get_width() const { return lv_display_get_horizontal_resolution(this->disp_); }
344 uint16_t get_height() const { return lv_display_get_vertical_resolution(this->disp_); }
345
346 protected:
347 void set_resolution_() const;
348 // Determine the current orientation from the effective resolution and fire the
349 // landscape/portrait trigger if it has changed since the last check.
350 void update_orientation_();
351 void draw_end_();
352 // Not checking for non-null callback since the
353 // LVGL callback that calls it is not set in that case
354 void draw_start_() const { this->draw_start_callback_->trigger(); }
355 // Returns true if update_when_display_idle is enabled and at least one underlying display
356 // component is currently busy (e.g. mid-refresh).
357 bool displays_busy_() const;
358
359 void write_random_();
360 void draw_buffer_(const lv_area_t *area, lv_color_data *ptr);
361#ifdef USE_ESP32_VARIANT_ESP32P4
362 bool ppa_rotate_(const lv_color_data *src, lv_color_data *dst, uint16_t width, uint16_t height,
363 uint32_t height_rounded);
364#endif
365 void flush_cb_(lv_display_t *disp_drv, const lv_area_t *area, uint8_t *color_p);
366
367 std::vector<display::Display *> displays_{};
368 size_t buffer_frac_{1};
372
373 uint8_t *draw_buf_{};
374 lv_display_t *disp_{};
375 // The display's own periodic refresh timer, effectively paused while the display is busy (see
376 // displays_busy_()) so LVGL neither renders nor flushes to it, without losing track of
377 // invalidated areas. Other timers (indev reading, animations, ...) keep running as normal.
378 lv_timer_t *refr_timer_{};
379 // Tracks whether refr_timer_ is currently paused, so loop() can detect the busy -> idle edge
380 // and kick off an immediate refresh instead of waiting for the timer's next natural period.
383 uint16_t width_{};
384 uint16_t height_{};
385 bool paused_{};
386 std::vector<LvPageType *> pages_{};
387 size_t current_page_{0};
389 bool page_wrap_{true};
391 std::map<lv_group_t *, lv_obj_t *> focus_marks_{};
392
401 void *rotate_buf_{};
404#ifdef USE_ESP32_VARIANT_ESP32P4
405 ppa_client_handle_t ppa_client_{};
406#endif
407};
408
409class IdleTrigger final : public Trigger<> {
410 public:
411 explicit IdleTrigger(LvglComponent *parent, TemplatableFn<uint32_t> timeout);
412
413 protected:
415 bool is_idle_{};
416};
417
418template<typename... Ts> class LvglAction final : public Action<Ts...>, public Parented<LvglComponent> {
419 public:
420 explicit LvglAction(std::function<void(LvglComponent *)> &&lamb) : action_(std::move(lamb)) {}
421
422 protected:
423 void play(const Ts &...x) override { this->action_(this->parent_); }
424 std::function<void(LvglComponent *)> action_{};
425};
426
427template<typename Tc, typename... Ts> class LvglCondition final : public Condition<Ts...>, public Parented<Tc> {
428 public:
429 LvglCondition(std::function<bool(Tc *)> &&condition_lambda) : condition_lambda_(std::move(condition_lambda)) {}
430 bool check(const Ts &...x) override { return this->condition_lambda_(this->parent_); }
431
432 protected:
433 std::function<bool(Tc *)> condition_lambda_{};
434};
435
436#ifdef USE_LVGL_TOUCHSCREEN
437class LVTouchListener final : public touchscreen::TouchListener, public Parented<LvglComponent> {
438 public:
439 LVTouchListener(uint16_t long_press_time, uint16_t long_press_repeat_time, LvglComponent *parent);
440 void update(const touchscreen::TouchPoints_t &tpoints) override;
441 void release() override {
442 touch_pressed_ = false;
443 this->parent_->maybe_wakeup();
444 }
445 lv_indev_t *get_drv() { return this->drv_; }
446
447 protected:
448 lv_indev_t *drv_{};
451};
452#endif // USE_LVGL_TOUCHSCREEN
453
454#ifdef USE_LVGL_METER
455
456class IndicatorLine : public LvCompound {
457 public:
458 IndicatorLine() = default;
459
460 void set_obj(lv_obj_t *lv_obj) override;
461
462 void set_value(int value);
463
464 private:
465 void update_length_();
466
467 int16_t angle_{};
468 lv_point_precise_t points_[2]{};
469};
470#endif
471
472#ifdef USE_LVGL_KEY_LISTENER
473class LVEncoderListener final : public Parented<LvglComponent> {
474 public:
475 LVEncoderListener(lv_indev_type_t type, uint16_t long_press_time, uint16_t long_press_repeat_time);
476
477#ifdef USE_BINARY_SENSOR
479 button->add_on_state_callback([this, key](bool state) { this->event(key, state); });
480 }
481#endif
482
483#ifdef USE_LVGL_ROTARY_ENCODER
485 sensor->register_listener([this](int32_t count) { this->set_count(count); });
486 }
487#endif // USE_LVGL_ROTARY_ENCODER
488
489 void event(int key, bool pressed) {
490 if (!this->parent_->is_paused()) {
491 this->pressed_ = pressed;
492 this->key_ = key;
493 } else if (!pressed) {
494 // maybe wakeup on release if paused
495 this->parent_->maybe_wakeup();
496 }
497 }
498
499 void set_count(int32_t count) {
500 if (!this->parent_->is_paused()) {
501 this->count_ = count;
502 } else {
503 this->parent_->maybe_wakeup();
504 }
505 }
506
507 lv_indev_t *get_drv() { return this->drv_; }
508
509 protected:
510 lv_indev_t *drv_{};
511 bool pressed_{};
512 int32_t count_{};
513 int32_t last_count_{};
514 int key_{};
515};
516#endif // USE_LVGL_KEY_LISTENER
517
518#ifdef USE_LVGL_LINE
519class LvLineType : public LvCompound {
520 public:
522 this->points_ = std::move(points);
523 lv_line_set_points(this->obj, this->points_.begin(), this->points_.size());
524 }
525
526 protected:
528};
529#endif
530#ifdef USE_LVGL_TABLE
531// Unlike most size properties, lv_table_set_column_width() only accepts a literal pixel
532// count, so percentage column widths must be recomputed by hand whenever the table's own
533// content width changes.
534class LvTableType : public LvCompound {
535 public:
536 void set_obj(lv_obj_t *lv_obj) override;
537 // count is the number of percentage-width columns, known at code-generation time.
538 void init_column_pct(size_t count) { this->column_pct_.init(count); }
539 void add_column_width_pct(uint32_t col, uint8_t pct);
540
541 protected:
543
544 struct ColumnPct {
546 uint8_t pct;
547 };
549};
550#endif // USE_LVGL_TABLE
551#if defined(USE_LVGL_DROPDOWN) || defined(LV_USE_ROLLER)
552class LvSelectable : public LvCompound {
553 public:
554 virtual size_t get_selected_index() = 0;
555 virtual void set_selected_index(size_t index, lv_anim_enable_t anim) = 0;
556 void set_selected_text(const std::string &text, lv_anim_enable_t anim);
557 std::string get_selected_text();
560
561 protected:
562 virtual void set_option_string(const char *options) = 0;
564};
565
566#ifdef USE_LVGL_DROPDOWN
568 public:
569 size_t get_selected_index() override { return lv_dropdown_get_selected(this->obj); }
570 void set_selected_index(size_t index, lv_anim_enable_t anim) override { lv_dropdown_set_selected(this->obj, index); }
571
572 protected:
573 void set_option_string(const char *options) override { lv_dropdown_set_options(this->obj, options); }
574};
575#endif // USE_LVGL_DROPDOWN
576
577#ifdef USE_LVGL_ROLLER
579 public:
580 size_t get_selected_index() override { return lv_roller_get_selected(this->obj); }
581 void set_selected_index(size_t index, lv_anim_enable_t anim) override {
582 lv_roller_set_selected(this->obj, index, anim);
583 }
584 void set_mode(lv_roller_mode_t mode) { this->mode_ = mode; }
585
586 protected:
587 void set_option_string(const char *options) override { lv_roller_set_options(this->obj, options, this->mode_); }
588 lv_roller_mode_t mode_{LV_ROLLER_MODE_NORMAL};
589};
590#endif
591#endif // defined(USE_LVGL_DROPDOWN) || defined(LV_USE_ROLLER)
592
593#ifdef USE_LVGL_BUTTONMATRIX
595 public:
596 void set_obj(lv_obj_t *lv_obj) override;
597 uint16_t get_selected() { return lv_buttonmatrix_get_selected_button(this->obj); }
598 void set_key(size_t idx, uint8_t key) { this->key_map_[idx] = key; }
599
600 protected:
601 std::map<size_t, uint8_t> key_map_{};
602};
603#endif // USE_LVGL_BUTTONMATRIX
604
605#ifdef USE_LVGL_KEYBOARD
607 public:
608 void set_obj(lv_obj_t *lv_obj) override;
609};
610#endif // USE_LVGL_KEYBOARD
611} // namespace esphome::lvgl
BedjetMode mode
BedJet operating mode.
Base class for all automation conditions.
Definition automation.h:534
Fixed-capacity vector - sized once through init() or try_init(); push_back never reallocates This avo...
Definition helpers.h:669
Helper class to easily give an object a parent of type T.
Definition helpers.h:2160
This class simplifies creating components that periodically check a state.
Definition component.h:532
void add_on_state_callback(F &&callback)
Function-pointer-only templatable storage (4 bytes on 32-bit).
Definition automation.h:21
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Inform the parent automation that the event has triggered.
Definition automation.h:557
Base class for all binary_sensor-type classes.
const lv_font_t * get_lv_font() const
Definition font.h:90
virtual lv_image_dsc_t * get_lv_image_dsc()
Definition image.cpp:168
virtual void add_lvgl_widget(lv_obj_t *obj)
Called when an LVGL image widget is given this image.
Definition image.h:51
interface for components that provide keypresses
Definition key_provider.h:9
TemplatableFn< uint32_t > timeout_
IdleTrigger(LvglComponent *parent, TemplatableFn< uint32_t > timeout)
void set_obj(lv_obj_t *lv_obj) override
void add_button(binary_sensor::BinarySensor *button, lv_key_t key)
void event(int key, bool pressed)
void set_sensor(rotary_encoder::RotaryEncoderSensor *sensor)
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_key(size_t idx, uint8_t key)
std::map< size_t, uint8_t > key_map_
void set_obj(lv_obj_t *lv_obj) override
virtual ~LvCompound()=default
virtual void set_obj(lv_obj_t *lv_obj)
size_t get_selected_index() override
void set_option_string(const char *options) override
void set_selected_index(size_t index, lv_anim_enable_t anim) override
void set_obj(lv_obj_t *lv_obj) override
LvLambdaComponent(void(*callback)())
float get_setup_priority() const override
void set_points(FixedVector< lv_point_precise_t > points)
FixedVector< lv_point_precise_t > points_
void setup(size_t index)
void set_mode(lv_roller_mode_t mode)
void set_option_string(const char *options) override
void set_selected_index(size_t index, lv_anim_enable_t anim) override
size_t get_selected_index() override
const FixedVector< const char * > & get_options()
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 init_column_pct(size_t count)
void set_obj(lv_obj_t *lv_obj) override
void add_column_width_pct(uint32_t col, uint8_t pct)
FixedVector< ColumnPct > column_pct_
void play(const Ts &...x) override
LvglAction(std::function< void(LvglComponent *)> &&lamb)
std::function< void(LvglComponent *)> action_
Component for rendering LVGL.
void set_paused(bool paused, bool show_snow)
void set_pause_trigger(Trigger<> *trigger)
void set_landscape_trigger(Trigger<> *trigger)
display::DisplayRotation rotation_
void rotate_coordinates(int32_t &x, int32_t &y) const
std::vector< LvPageType * > pages_
void set_rotation(display::DisplayRotation rotation)
void set_focus_mark(lv_group_t *group)
bool ppa_rotate_(const lv_color_data *src, lv_color_data *dst, uint16_t width, uint16_t height, uint32_t height_rounded)
void set_draw_end_trigger(Trigger<> *trigger)
static void lv_obj_set_state_value(lv_obj_t *obj, lv_state_t state, bool value)
void set_refresh_interval(uint32_t period)
CallbackManager< void(uint32_t)> idle_callbacks_
void set_portrait_trigger(Trigger<> *trigger)
void set_big_endian(bool big_endian)
void show_next_page(lv_screen_load_anim_t anim, uint32_t time)
void set_resume_trigger(Trigger<> *trigger)
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)
static void lv_buttonmatrix_set_button_ctrl_value(lv_obj_t *obj, uint32_t index, lv_buttonmatrix_ctrl_t ctrl, bool value)
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)
float get_setup_priority() const override
static void static_flush_cb(lv_display_t *disp_drv, const lv_area_t *area, uint8_t *color_p)
std::map< lv_group_t *, lv_obj_t * > focus_marks_
static void render_end_cb(lv_event_t *event)
static void lv_obj_set_custom_flag(lv_obj_t *obj, lv_obj_flag_t flag, bool value)
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)
display::DisplayRotation get_rotation() const
static void add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_event_code_t event, void *user_data=nullptr)
void set_draw_start_trigger(Trigger<> *trigger)
void restore_focus_mark(lv_group_t *group)
void flush_cb_(lv_display_t *disp_drv, const lv_area_t *area, uint8_t *color_p)
LvglCondition(std::function< bool(Tc *)> &&condition_lambda)
bool check(const Ts &...x) override
std::function< bool(Tc *)> condition_lambda_
void play(const Ts &...x) override
std::function< void(Ts...)> lamb_
ObjUpdateAction(std::function< void(Ts...)> &&lamb)
uint8_t options
uint8_t type
const char * key
bool state
Definition fan.h:2
unsigned count
Definition gif.cpp:51
@ DISPLAY_ROTATION_0_DEGREES
Definition display.h:136
bool lv_menu_back_button_is_root_click(lv_obj_t *menu, lv_event_t *e)
void lv_obj_set_style_bitmap_mask_src(lv_obj_t *obj, image::Image *image, lv_style_selector_t selector)
lv_color_t lv_grad_calculate_color(const lv_grad_dsc_t *dsc, int32_t pos)
void lv_style_set_text_font(lv_style_t *style, const font::Font *font)
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
void lv_animimg_set_src(lv_obj_t *img, std::vector< image::Image * > images)
void lv_image_set_src(lv_obj_t *obj, image::Image *image)
void lv_style_set_bg_image_src(lv_style_t *style, image::Image *image)
uint32_t lv_table_get_selected_row(lv_obj_t *obj)
void lv_style_set_bitmap_mask_src(lv_style_t *style, image::Image *image)
void lv_obj_set_style_text_font(lv_obj_t *obj, const font::Font *font, lv_style_selector_t part)
void lv_obj_set_style_bg_image_src(lv_obj_t *obj, image::Image *image, lv_style_selector_t selector)
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.
void delete_lv_compound_on_delete(lv_event_t *e)
uint32_t lv_table_get_selected_column(lv_obj_t *obj)
constexpr float PROCESSOR
For components that use data from sensors like displays.
Definition component.h:47
std::vector< TouchPoint > TouchPoints_t
Definition touchscreen.h:29
uint32_t value
Definition hal.cpp:41
size_t size_t pos
Definition helpers.h:1333
const void * src
Definition hal.h:68
STL namespace.
static void uint32_t
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6