4 #ifdef USE_BINARY_SENSOR 6 #endif // USE_BINARY_SENSOR 7 #ifdef USE_LVGL_ROTARY_ENCODER 9 #endif // USE_LVGL_ROTARY_ENCODER 13 #define LV_CONF_SKIP 1 // NOLINT 25 #endif // USE_LVGL_IMAGE 29 #endif // USE_LVGL_FONT 30 #ifdef USE_LVGL_TOUCHSCREEN 32 #endif // USE_LVGL_TOUCHSCREEN 34 #if defined(USE_LVGL_BUTTONMATRIX) || defined(USE_LVGL_KEYBOARD) 36 #endif // USE_LVGL_BUTTONMATRIX 45 #if LV_COLOR_DEPTH == 16 47 #elif LV_COLOR_DEPTH == 32 49 #else // LV_COLOR_DEPTH 51 #endif // LV_COLOR_DEPTH 56 virtual void set_obj(lv_obj_t *lv_obj) { this->
obj = lv_obj; }
66 this->
obj = lv_obj_create(
nullptr);
82 void play(Ts...
x)
override { this->lamb_(
x...); }
85 std::function<void(Ts...)>
lamb_;
91 const lv_font_t *get_lv_font();
100 uint32_t last_letter_{};
102 lv_font_t lv_font_{};
104 #endif // USE_LVGL_FONT 105 #ifdef USE_LVGL_ANIMIMG 107 #endif // USE_LVGL_ANIMIMG 110 constexpr
static const char *
const TAG =
"lvgl";
113 static void static_flush_cb(lv_disp_drv_t *disp_drv,
const lv_area_t *area, lv_color_t *color_p);
116 void setup()
override;
117 void update()
override;
118 void loop()
override;
120 this->idle_callbacks_.add(std::move(callback));
124 void dump_config()
override;
126 bool is_idle(uint32_t idle_ms) {
return lv_disp_get_inactive_time(this->disp_) > idle_ms; }
129 void set_paused(
bool paused,
bool show_snow);
130 void add_event_cb(lv_obj_t *obj,
event_callback_t callback, lv_event_code_t event);
131 void add_event_cb(lv_obj_t *obj,
event_callback_t callback, lv_event_code_t event1, lv_event_code_t event2);
132 void add_event_cb(lv_obj_t *obj,
event_callback_t callback, lv_event_code_t event1, lv_event_code_t event2,
133 lv_event_code_t event3);
136 void show_page(
size_t index, lv_scr_load_anim_t anim, uint32_t time);
137 void show_next_page(lv_scr_load_anim_t anim, uint32_t time);
138 void show_prev_page(lv_scr_load_anim_t anim, uint32_t time);
140 void set_focus_mark(lv_group_t *group) { this->focus_marks_[group] = lv_group_get_focused(group); }
142 auto *mark = this->focus_marks_[group];
143 if (mark !=
nullptr) {
144 lv_group_focus_obj(mark);
149 void write_random_();
150 void draw_buffer_(
const lv_area_t *area,
const uint8_t *ptr);
151 void flush_cb_(lv_disp_drv_t *disp_drv,
const lv_area_t *area, lv_color_t *color_p);
152 std::vector<display::Display *> displays_{};
153 lv_disp_draw_buf_t draw_buf_{};
154 lv_disp_drv_t disp_drv_{};
157 std::vector<LvPageType *> pages_{};
158 size_t current_page_{0};
160 lv_coord_t snow_line_{};
161 bool page_wrap_{
true};
162 std::map<lv_group_t *, lv_obj_t *> focus_marks_{};
164 std::vector<std::function<void(LvglComponent *lv_component)>>
init_lambdas_;
166 size_t buffer_frac_{1};
167 bool full_refresh_{};
182 void play(Ts...
x)
override { this->action_(this->parent_); }
185 std::function<void(LvglComponent *)> action_{};
191 : condition_lambda_(
std::move(condition_lambda)) {}
192 bool check(Ts...
x)
override {
return this->condition_lambda_(this->parent_); }
195 std::function<bool(LvglComponent *)> condition_lambda_{};
198 #ifdef USE_LVGL_TOUCHSCREEN 201 LVTouchListener(uint16_t long_press_time, uint16_t long_press_repeat_time);
203 void release()
override { touch_pressed_ =
false; }
204 lv_indev_drv_t *
get_drv() {
return &this->drv_; }
207 lv_indev_drv_t drv_{};
209 bool touch_pressed_{};
211 #endif // USE_LVGL_TOUCHSCREEN 213 #ifdef USE_LVGL_KEY_LISTENER 229 #ifdef USE_LVGL_ROTARY_ENCODER 233 #endif // USE_LVGL_ROTARY_ENCODER 236 if (!this->parent_->is_paused()) {
237 this->pressed_ = pressed;
243 if (!this->parent_->is_paused())
244 this->count_ = count;
247 lv_indev_drv_t *
get_drv() {
return &this->drv_; }
250 lv_indev_drv_t drv_{};
253 int32_t last_count_{};
256 #endif // USE_LVGL_KEY_LISTENER 258 #ifdef USE_LVGL_BUTTONMATRIX 261 void set_obj(lv_obj_t *lv_obj)
override;
262 uint16_t
get_selected() {
return lv_btnmatrix_get_selected_btn(this->obj); }
263 void set_key(
size_t idx, uint8_t key) { this->key_map_[idx] = key; }
266 std::map<size_t, uint8_t> key_map_{};
268 #endif // USE_LVGL_BUTTONMATRIX 270 #ifdef USE_LVGL_KEYBOARD 273 void set_obj(lv_obj_t *lv_obj)
override;
275 #endif // USE_LVGL_KEYBOARD
std::string lv_event_code_name_for(uint8_t event_code)
void add_on_idle_callback(std::function< void(uint32_t)> &&callback)
void set_sensor(rotary_encoder::RotaryEncoderSensor *sensor)
LvglCondition(std::function< bool(LvglComponent *)> &&condition_lambda)
bool check(Ts... x) override
std::vector< TouchPoint > TouchPoints_t
bool is_idle(uint32_t idle_ms)
void register_listener(std::function< void(uint32_t)> listener)
interface for components that provide keypresses
float get_setup_priority() const override
void set_full_refresh(bool full_refresh)
lv_indev_drv_t * get_drv()
void play(Ts... x) override
This class simplifies creating components that periodically check a state.
void add_display(display::Display *display)
std::vector< std::function< void(LvglComponent *lv_component)> > init_lambdas_
void(_lv_event_t *) event_callback_t
void set_left_button(binary_sensor::BinarySensor *left_button)
lv_event_code_t lv_update_event
std::function< void(float)> set_value_lambda_t
lv_event_code_t lv_api_event
void restore_focus_mark(lv_group_t *group)
void set_right_button(binary_sensor::BinarySensor *right_button)
void set_enter_button(binary_sensor::BinarySensor *enter_button)
virtual void set_obj(lv_obj_t *lv_obj)
Base class for all automation conditions.
void set_page_wrap(bool wrap)
std::function< void(Ts...)> lamb_
LvglAction(std::function< void(LvglComponent *)> &&lamb)
bool lv_is_pre_initialise()
const float PROCESSOR
For components that use data from sensors like displays.
TemplatableValue< uint32_t > timeout_
std::function< void(lv_obj_t *)> LvLambdaType
void event(int key, bool pressed)
void add_init_lambda(const std::function< void(LvglComponent *)> &lamb)
std::function< const char *()> text_lambda_t
void add_on_state_callback(std::function< void(bool)> &&callback)
Add a callback to be notified of state changes.
void set_focus_mark(lv_group_t *group)
Implementation of SPI Controller mode.
Base class for all binary_sensor-type classes.
lv_indev_drv_t * get_drv()
void set_count(int32_t count)
void set_buffer_frac(size_t frac)
void lv_animimg_stop(lv_obj_t *obj)
ObjUpdateAction(std::function< void(Ts...)> &&lamb)
esphome::sensor::Sensor * sensor
Helper class to easily give an object a parent of type T.
void play(Ts... x) override