ESPHome  2024.11.0
Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
esphome::lvgl::LvglComponent Class Reference

Component for rendering LVGL. More...

#include <lvgl_esphome.h>

Inheritance diagram for esphome::lvgl::LvglComponent:
esphome::PollingComponent esphome::Component

Public Member Functions

 LvglComponent (std::vector< display::Display *> displays, float buffer_frac, bool full_refresh, int draw_rounding, bool resume_on_input)
 
float get_setup_priority () const override
 
void setup () override
 
void update () override
 
void loop () override
 
void add_on_idle_callback (std::function< void(uint32_t)> &&callback)
 
void add_on_pause_callback (std::function< void(bool)> &&callback)
 
void dump_config () override
 
bool is_idle (uint32_t idle_ms)
 
lv_disp_t * get_disp ()
 
lv_obj_t * get_scr_act ()
 
void set_paused (bool paused, bool show_snow)
 
bool is_paused () const
 
void maybe_wakeup ()
 
void add_page (LvPageType *page)
 
void show_page (size_t index, lv_scr_load_anim_t anim, uint32_t time)
 
void show_next_page (lv_scr_load_anim_t anim, uint32_t time)
 
void show_prev_page (lv_scr_load_anim_t anim, uint32_t time)
 
void set_page_wrap (bool wrap)
 
void set_focus_mark (lv_group_t *group)
 
void restore_focus_mark (lv_group_t *group)
 
- Public Member Functions inherited from esphome::PollingComponent
 PollingComponent ()
 
 PollingComponent (uint32_t update_interval)
 Initialize this polling component with the given update interval in ms. More...
 
virtual void set_update_interval (uint32_t update_interval)
 Manually set the update interval in ms for this polling object. More...
 
void call_setup () override
 
virtual uint32_t get_update_interval () const
 Get the update interval in ms of this sensor. More...
 
void start_poller ()
 
void stop_poller ()
 
- Public Member Functions inherited from esphome::Component
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
virtual float get_loop_priority () const
 priority of loop(). More...
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
uint32_t get_component_state () const
 
virtual void mark_failed ()
 Mark this component as failed. More...
 
bool is_failed () const
 
bool is_ready () const
 
virtual bool can_proceed ()
 
bool status_has_warning () const
 
bool status_has_error () const
 
void status_set_warning (const char *message="unspecified")
 
void status_set_error (const char *message="unspecified")
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const std::string &name, uint32_t length=5000)
 
void status_momentary_error (const std::string &name, uint32_t length=5000)
 
bool has_overridden_loop () const
 
void set_component_source (const char *source)
 Set where this component was loaded from for some debug messages. More...
 
const char * get_component_source () const
 Get the integration where this component was declared as a string. More...
 

Static Public Member Functions

static void static_flush_cb (lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
 
static void esphome_lvgl_init ()
 Initialize the LVGL library and register custom events. More...
 
static void add_event_cb (lv_obj_t *obj, event_callback_t callback, lv_event_code_t event)
 
static void add_event_cb (lv_obj_t *obj, event_callback_t callback, lv_event_code_t event1, lv_event_code_t event2)
 
static void add_event_cb (lv_obj_t *obj, event_callback_t callback, lv_event_code_t event1, lv_event_code_t event2, lv_event_code_t event3)
 

Data Fields

size_t draw_rounding {2}
 
display::DisplayRotation rotation {display::DISPLAY_ROTATION_0_DEGREES}
 

Protected Member Functions

void write_random_ ()
 
void draw_buffer_ (const lv_area_t *area, lv_color_t *ptr)
 
void flush_cb_ (lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
 
- Protected Member Functions inherited from esphome::Component
virtual void call_loop ()
 
virtual void call_dump_config ()
 
void set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a unique name. More...
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const std::string &name)
 Cancel an interval function. More...
 
void set_retry (const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f)
 Set an retry function with a unique name. More...
 
void set_retry (uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f)
 
bool cancel_retry (const std::string &name)
 Cancel a retry function. More...
 
void set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a unique name. More...
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const std::string &name)
 Cancel a timeout function. More...
 
void defer (const std::string &name, std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
bool cancel_defer (const std::string &name)
 Cancel a defer callback using the specified name, name must not be empty. More...
 

Protected Attributes

std::vector< display::Display * > displays_ {}
 
size_t buffer_frac_ {1}
 
bool full_refresh_ {}
 
bool resume_on_input_ {}
 
lv_disp_draw_buf_t draw_buf_ {}
 
lv_disp_drv_t disp_drv_ {}
 
lv_disp_t * disp_ {}
 
bool paused_ {}
 
std::vector< LvPageType * > pages_ {}
 
size_t current_page_ {0}
 
bool show_snow_ {}
 
bool page_wrap_ {true}
 
std::map< lv_group_t *, lv_obj_t * > focus_marks_ {}
 
CallbackManager< void(uint32_t)> idle_callbacks_ {}
 
CallbackManager< void(bool)> pause_callbacks_ {}
 
lv_color_t * rotate_buf_ {}
 
- Protected Attributes inherited from esphome::PollingComponent
uint32_t update_interval_
 
- Protected Attributes inherited from esphome::Component
uint32_t component_state_ {0x0000}
 State of this component. More...
 
float setup_priority_override_ {NAN}
 
const char * component_source_ {nullptr}
 

Detailed Description

Component for rendering LVGL.

This component renders LVGL widgets on a display. Some initialisation must be done in the constructor since LVGL needs to be initialised before any widgets can be created.

Parameters
displaysa list of displays to render onto. All displays must have the same resolution.
buffer_fracthe fraction of the display resolution to use for the LVGL draw buffer. A higher value will make animations smoother but also increase memory usage.
full_refreshif true, the display will be fully refreshed on every frame. If false, only changed areas will be updated.
draw_roundingthe rounding to use when drawing. A value of 1 will draw without any rounding, a value of 2 will round to the nearest multiple of 2, and so on.
resume_on_inputif true, this component will resume rendering when the user presses a key or clicks on the screen.

Definition at line 117 of file lvgl_esphome.h.

Constructor & Destructor Documentation

◆ LvglComponent()

esphome::lvgl::LvglComponent::LvglComponent ( std::vector< display::Display *>  displays,
float  buffer_frac,
bool  full_refresh,
int  draw_rounding,
bool  resume_on_input 
)

Definition at line 409 of file lvgl_esphome.cpp.

Member Function Documentation

◆ add_event_cb() [1/3]

void esphome::lvgl::LvglComponent::add_event_cb ( lv_obj_t *  obj,
event_callback_t  callback,
lv_event_code_t  event 
)
static

Definition at line 106 of file lvgl_esphome.cpp.

◆ add_event_cb() [2/3]

void esphome::lvgl::LvglComponent::add_event_cb ( lv_obj_t *  obj,
event_callback_t  callback,
lv_event_code_t  event1,
lv_event_code_t  event2 
)
static

Definition at line 109 of file lvgl_esphome.cpp.

◆ add_event_cb() [3/3]

void esphome::lvgl::LvglComponent::add_event_cb ( lv_obj_t *  obj,
event_callback_t  callback,
lv_event_code_t  event1,
lv_event_code_t  event2,
lv_event_code_t  event3 
)
static

Definition at line 114 of file lvgl_esphome.cpp.

◆ add_on_idle_callback()

void esphome::lvgl::LvglComponent::add_on_idle_callback ( std::function< void(uint32_t)> &&  callback)
inline

Definition at line 129 of file lvgl_esphome.h.

◆ add_on_pause_callback()

void esphome::lvgl::LvglComponent::add_on_pause_callback ( std::function< void(bool)> &&  callback)
inline

Definition at line 132 of file lvgl_esphome.h.

◆ add_page()

void esphome::lvgl::LvglComponent::add_page ( LvPageType page)

Definition at line 120 of file lvgl_esphome.cpp.

◆ draw_buffer_()

void esphome::lvgl::LvglComponent::draw_buffer_ ( const lv_area_t *  area,
lv_color_t *  ptr 
)
protected

Definition at line 146 of file lvgl_esphome.cpp.

◆ dump_config()

void esphome::lvgl::LvglComponent::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 85 of file lvgl_esphome.cpp.

◆ esphome_lvgl_init()

void esphome::lvgl::LvglComponent::esphome_lvgl_init ( )
static

Initialize the LVGL library and register custom events.

Definition at line 101 of file lvgl_esphome.cpp.

◆ flush_cb_()

void esphome::lvgl::LvglComponent::flush_cb_ ( lv_disp_drv_t *  disp_drv,
const lv_area_t *  area,
lv_color_t *  color_p 
)
protected

Definition at line 198 of file lvgl_esphome.cpp.

◆ get_disp()

lv_disp_t* esphome::lvgl::LvglComponent::get_disp ( )
inline

Definition at line 135 of file lvgl_esphome.h.

◆ get_scr_act()

lv_obj_t* esphome::lvgl::LvglComponent::get_scr_act ( )
inline

Definition at line 136 of file lvgl_esphome.h.

◆ get_setup_priority()

float esphome::lvgl::LvglComponent::get_setup_priority ( ) const
inlineoverridevirtual

Reimplemented from esphome::Component.

Definition at line 125 of file lvgl_esphome.h.

◆ is_idle()

bool esphome::lvgl::LvglComponent::is_idle ( uint32_t  idle_ms)
inline

Definition at line 134 of file lvgl_esphome.h.

◆ is_paused()

bool esphome::lvgl::LvglComponent::is_paused ( ) const
inline

Definition at line 141 of file lvgl_esphome.h.

◆ loop()

void esphome::lvgl::LvglComponent::loop ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 472 of file lvgl_esphome.cpp.

◆ maybe_wakeup()

void esphome::lvgl::LvglComponent::maybe_wakeup ( )
inline

Definition at line 143 of file lvgl_esphome.h.

◆ restore_focus_mark()

void esphome::lvgl::LvglComponent::restore_focus_mark ( lv_group_t *  group)
inline

Definition at line 163 of file lvgl_esphome.h.

◆ set_focus_mark()

void esphome::lvgl::LvglComponent::set_focus_mark ( lv_group_t *  group)
inline

Definition at line 162 of file lvgl_esphome.h.

◆ set_page_wrap()

void esphome::lvgl::LvglComponent::set_page_wrap ( bool  wrap)
inline

Definition at line 161 of file lvgl_esphome.h.

◆ set_paused()

void esphome::lvgl::LvglComponent::set_paused ( bool  paused,
bool  show_snow 
)

Definition at line 91 of file lvgl_esphome.cpp.

◆ setup()

void esphome::lvgl::LvglComponent::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 440 of file lvgl_esphome.cpp.

◆ show_next_page()

void esphome::lvgl::LvglComponent::show_next_page ( lv_scr_load_anim_t  anim,
uint32_t  time 
)

Definition at line 130 of file lvgl_esphome.cpp.

◆ show_page()

void esphome::lvgl::LvglComponent::show_page ( size_t  index,
lv_scr_load_anim_t  anim,
uint32_t  time 
)

Definition at line 124 of file lvgl_esphome.cpp.

◆ show_prev_page()

void esphome::lvgl::LvglComponent::show_prev_page ( lv_scr_load_anim_t  anim,
uint32_t  time 
)

Definition at line 138 of file lvgl_esphome.cpp.

◆ static_flush_cb()

void esphome::lvgl::LvglComponent::static_flush_cb ( lv_disp_drv_t *  disp_drv,
const lv_area_t *  area,
lv_color_t *  color_p 
)
static

Definition at line 489 of file lvgl_esphome.cpp.

◆ update()

void esphome::lvgl::LvglComponent::update ( )
overridevirtual

Implements esphome::PollingComponent.

Definition at line 465 of file lvgl_esphome.cpp.

◆ write_random_()

void esphome::lvgl::LvglComponent::write_random_ ( )
protected

Definition at line 361 of file lvgl_esphome.cpp.

Field Documentation

◆ buffer_frac_

size_t esphome::lvgl::LvglComponent::buffer_frac_ {1}
protected

Definition at line 180 of file lvgl_esphome.h.

◆ current_page_

size_t esphome::lvgl::LvglComponent::current_page_ {0}
protected

Definition at line 189 of file lvgl_esphome.h.

◆ disp_

lv_disp_t* esphome::lvgl::LvglComponent::disp_ {}
protected

Definition at line 186 of file lvgl_esphome.h.

◆ disp_drv_

lv_disp_drv_t esphome::lvgl::LvglComponent::disp_drv_ {}
protected

Definition at line 185 of file lvgl_esphome.h.

◆ displays_

std::vector<display::Display *> esphome::lvgl::LvglComponent::displays_ {}
protected

Definition at line 179 of file lvgl_esphome.h.

◆ draw_buf_

lv_disp_draw_buf_t esphome::lvgl::LvglComponent::draw_buf_ {}
protected

Definition at line 184 of file lvgl_esphome.h.

◆ draw_rounding

size_t esphome::lvgl::LvglComponent::draw_rounding {2}

Definition at line 170 of file lvgl_esphome.h.

◆ focus_marks_

std::map<lv_group_t *, lv_obj_t *> esphome::lvgl::LvglComponent::focus_marks_ {}
protected

Definition at line 192 of file lvgl_esphome.h.

◆ full_refresh_

bool esphome::lvgl::LvglComponent::full_refresh_ {}
protected

Definition at line 181 of file lvgl_esphome.h.

◆ idle_callbacks_

CallbackManager<void(uint32_t)> esphome::lvgl::LvglComponent::idle_callbacks_ {}
protected

Definition at line 194 of file lvgl_esphome.h.

◆ page_wrap_

bool esphome::lvgl::LvglComponent::page_wrap_ {true}
protected

Definition at line 191 of file lvgl_esphome.h.

◆ pages_

std::vector<LvPageType *> esphome::lvgl::LvglComponent::pages_ {}
protected

Definition at line 188 of file lvgl_esphome.h.

◆ pause_callbacks_

CallbackManager<void(bool)> esphome::lvgl::LvglComponent::pause_callbacks_ {}
protected

Definition at line 195 of file lvgl_esphome.h.

◆ paused_

bool esphome::lvgl::LvglComponent::paused_ {}
protected

Definition at line 187 of file lvgl_esphome.h.

◆ resume_on_input_

bool esphome::lvgl::LvglComponent::resume_on_input_ {}
protected

Definition at line 182 of file lvgl_esphome.h.

◆ rotate_buf_

lv_color_t* esphome::lvgl::LvglComponent::rotate_buf_ {}
protected

Definition at line 196 of file lvgl_esphome.h.

◆ rotation

display::DisplayRotation esphome::lvgl::LvglComponent::rotation {display::DISPLAY_ROTATION_0_DEGREES}

Definition at line 172 of file lvgl_esphome.h.

◆ show_snow_

bool esphome::lvgl::LvglComponent::show_snow_ {}
protected

Definition at line 190 of file lvgl_esphome.h.


The documentation for this class was generated from the following files: