LVGL cookbook (#4110)
Co-authored-by: Keith Burzinski <kbx81x@gmail.com> Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
@ -16,6 +16,7 @@ The graphic display should be configured with ``auto_clear_enabled: false`` and
|
||||
|
||||
For interactivity, a :doc:`Touchscreen </components/touchscreen/index>` (capacitive highly preferred), a :doc:`/components/sensor/rotary_encoder` or a custom keypad made up from discrete :doc:`Binary Sensors </components/binary_sensor/index>` can be used.
|
||||
|
||||
Check out the detailed examples in :ref:`the Cookbook <lvgl-cookbook>` which demonstrate a number of ways you can integrate your environment with LVGL and ESPHome.
|
||||
|
||||
Basics
|
||||
------
|
||||
@ -146,6 +147,7 @@ The following configuration variables apply to the main ``lvgl`` component, in o
|
||||
align: CENTER
|
||||
text: 'Hello World!'
|
||||
|
||||
See :ref:`lvgl-cookbook-navigator` in the Cookbook for an example which demonstrates how to implement a page navigation bar at the bottom of the screen.
|
||||
|
||||
.. _lvgl-color:
|
||||
|
||||
@ -176,6 +178,7 @@ You can use :ref:`fonts configured normally<display-fonts>`, the glyphs will be
|
||||
|
||||
For best results, set ``bpp: 4`` to get the glyphs rendered with proper anti-aliasing.
|
||||
|
||||
Check out :ref:`lvgl-cookbook-icontext`, :ref:`lvgl-cookbook-iconstat` and :ref:`lvgl-cookbook-iconbatt` in the Cookbook for examples which demonstrate how to use icons and text with TrueType/OpenType fonts.
|
||||
|
||||
**Library fonts**
|
||||
|
||||
@ -378,6 +381,7 @@ So the precedence happens like this: state based styles override the locally spe
|
||||
|
||||
Feel free to experiment to discover inheritance and precedence of the styles based on states between the nested widgets.
|
||||
|
||||
:ref:`lvgl-cookbook-theme` The Cookbook contains an example which demonstrates how to implement a gradient style for your widgets.
|
||||
|
||||
.. _lvgl-layouts:
|
||||
|
||||
@ -388,6 +392,7 @@ Layouts aim to position widgets automatically, eliminating the need to specify `
|
||||
|
||||
The layout configuration options are applied to any parent widget or page, influencing the appearance of the children. The position and size calculated by the layout overwrites the *normal* ``x``, ``y``, ``width``, and ``height`` settings of the children.
|
||||
|
||||
Check out :ref:`lvgl-cookbook-flex`, :ref:`lvgl-cookbook-grid` and :ref:`lvgl-cookbook-weather` in the Cookbook for examples which demonstrate how to automate widget positioning, potentially reducing the size of your device's YAML configuration, and saving you from lots of manual calculations.
|
||||
|
||||
The ``hidden``, ``ignore_layout`` and ``floating`` :ref:`flags <lvgl-widget-flags>` can be used on widgets to ignore them in layout calculations.
|
||||
|
||||
@ -594,7 +599,7 @@ This :ref:`action <actions-action>` redraws the entire screen, or optionally onl
|
||||
|
||||
This :ref:`action <actions-action>` pauses the activity of LVGL, including rendering.
|
||||
|
||||
- **show_snow** (*Optional*, boolean): When paused, display random colored pixels across the entire screen in order to minimize screen burn-in, to relief the tension put on each individual pixel.
|
||||
- **show_snow** (*Optional*, boolean): When paused, display random colored pixels across the entire screen in order to minimize screen burn-in, to relief the tension put on each individual pixel. See :ref:`lvgl-cookbook-antiburn` for an example which demonstrates how to use this.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
@ -801,6 +806,7 @@ The ``on_idle`` :ref:`triggers <automation>` are activated when inactivity time
|
||||
- light.turn_off: display_backlight
|
||||
- lvgl.pause:
|
||||
|
||||
See :ref:`lvgl-cookbook-idlescreen` for an example which demonstrates how to implement screen saving with idle settings.
|
||||
|
||||
See Also
|
||||
--------
|
||||
@ -811,6 +817,7 @@ See Also
|
||||
|
||||
*
|
||||
|
||||
- :doc:`LVGL Examples in the Cookbook </cookbook/lvgl>`
|
||||
- :doc:`/components/display/index`
|
||||
- :doc:`/components/touchscreen/index`
|
||||
- :doc:`/components/sensor/rotary_encoder`
|
||||
|
@ -83,6 +83,8 @@ To apply styles to the states, you need to specify them one level above, for exa
|
||||
|
||||
The state itself can be can be changed by interacting with the widget, or through :ref:`actions <lvgl-automation-actions>` with ``lvgl.widget.update``.
|
||||
|
||||
See :ref:`lvgl-cookbook-cover` for a cookbook example which demonstrates how to use styling and properties to show different states of a Home Assistant entity.
|
||||
|
||||
.. _lvgl-widget-flags:
|
||||
|
||||
In addition to visual styling, each widget supports some boolean **flags** to influence the behavior:
|
||||
@ -114,7 +116,7 @@ In addition to visual styling, each widget supports some boolean **flags** to in
|
||||
|
||||
.. note::
|
||||
|
||||
LVGL only supports **integers** for numeric ``value``. Visualizer widgets can't display floats directly, but they allow scaling by 10s.
|
||||
LVGL only supports **integers** for numeric ``value``. Visualizer widgets can't display floats directly, but they allow scaling by 10s. Some examples in the :doc:`Cookbook </cookbook/lvgl>` cover how to do that.
|
||||
|
||||
.. _lvgl-widget-parts:
|
||||
|
||||
@ -264,6 +266,8 @@ The animation image is similar to the normal ``image`` widget. The main differen
|
||||
repeat_count: 100
|
||||
duration: 300ms
|
||||
|
||||
See :ref:`lvgl-cookbook-animbatt` in the Cookbook for a more detailed example.
|
||||
|
||||
.. _lvgl-widget-arc:
|
||||
|
||||
``arc``
|
||||
@ -345,7 +349,9 @@ If the ``adv_hittest`` :ref:`flag <lvgl-widget-flags>` is enabled the arc can be
|
||||
|
||||
The ``on_value`` trigger is sent as the arc knob is dragged or changed with keys. The event is sent *continuously* while the arc knob is being dragged; this generally has a negative effect on performance. To mitigate this, consider using a :ref:`universal interaction trigger <lvgl-automation-triggers>` like ``on_release``, to get the ``x`` variable once after the interaction has completed.
|
||||
|
||||
The ``arc`` can be also integrated as :doc:`Number </components/number/lvgl>` or :doc:`Sensor </components/sensor/lvgl>` component.
|
||||
The ``arc`` can be also integrated as a :doc:`Number </components/number/lvgl>` or :doc:`Sensor </components/sensor/lvgl>` component.
|
||||
|
||||
See :ref:`lvgl-cookbook-bright` and :ref:`lvgl-cookbook-volume` for examples which demonstrate how to use a slider (or an arc) to control entities in Home Assistant.
|
||||
|
||||
.. _lvgl-widget-bar:
|
||||
|
||||
@ -466,6 +472,8 @@ To have a button with a text label on it, add a child :ref:`lvgl-widget-label` w
|
||||
|
||||
The ``button`` can be also integrated as a :doc:`Binary Sensor </components/binary_sensor/lvgl>` or as a :doc:`Switch </components/switch/lvgl>` component.
|
||||
|
||||
See :ref:`lvgl-cookbook-binent` for an example which demonstrates how to use a checkable button to act on a Home Assistant service.
|
||||
|
||||
.. _lvgl-widget-buttonmatrix:
|
||||
|
||||
``buttonmatrix``
|
||||
@ -596,7 +604,7 @@ The button matrix widget is a lightweight way to display multiple buttons in row
|
||||
|
||||
.. tip::
|
||||
|
||||
The Button Matrix widget supports the :ref:`key_collector` to collect the button presses as key press sequences for further automations.
|
||||
The Button Matrix widget supports the :ref:`key_collector` to collect the button presses as key press sequences for further automations. Check out :ref:`lvgl-cookbook-keypad` for an example.
|
||||
|
||||
.. _lvgl-widget-checkbox:
|
||||
|
||||
@ -656,7 +664,7 @@ The checkbox widget is made internally from a *tick box* and a label. When the c
|
||||
|
||||
.. note::
|
||||
|
||||
In case you configure ``default_font`` in the main section to a custom font, the checkmark will not be shown correctly when the checkbox is in the checked state.
|
||||
In case you configure ``default_font`` in the main section to a custom font, the checkmark will not be shown correctly when the checkbox is in the checked state. See :ref:`lvgl-cookbook-ckboxmark` for how to easily resolve this.
|
||||
|
||||
The ``checkbox`` can be also integrated as a :doc:`Switch </components/switch/lvgl>` component.
|
||||
|
||||
@ -988,6 +996,8 @@ The ``led`` can be also integrated as :doc:`Light </components/light/lvgl>` comp
|
||||
|
||||
If configured as a light component, ``color`` and ``brightness`` are overridden by the light at startup, according to its ``restore_mode`` setting.
|
||||
|
||||
Check out :ref:`lvgl-cookbook-keypad` in the Cookbook for an example which demonstrates how to change the ``led`` styling properties from an automation.
|
||||
|
||||
.. _lvgl-widget-line:
|
||||
|
||||
``line``
|
||||
@ -1139,6 +1149,8 @@ The meter widget can visualize data in very flexible ways. It can use arcs, need
|
||||
id: temperature_needle
|
||||
value: 3
|
||||
|
||||
See :ref:`lvgl-cookbook-gauge`, :ref:`lvgl-cookbook-thermometer` and :ref:`lvgl-cookbook-clock` in the Cookbook for examples which demonstrate how to effectively use this widget.
|
||||
|
||||
.. _lvgl-widget-msgbox:
|
||||
|
||||
``msgboxes``
|
||||
@ -1362,6 +1374,8 @@ Normally, the slider can be adjusted either by dragging the knob, or by clicking
|
||||
|
||||
The ``slider`` can be also integrated as :doc:`Number </components/number/lvgl>` or :doc:`Sensor </components/sensor/lvgl>` component.
|
||||
|
||||
See :ref:`lvgl-cookbook-bright` and :ref:`lvgl-cookbook-volume` for examples which demonstrate how to use a slider to control entities in Home Assistant.
|
||||
|
||||
.. _lvgl-widget-spinbox:
|
||||
|
||||
``spinbox``
|
||||
@ -1437,7 +1451,9 @@ The spinbox contains a numeric value (as text) which can be increased or decreas
|
||||
format: "Spinbox value is %f"
|
||||
args: [ x ]
|
||||
|
||||
The ``spinbox`` can be also integrated as :doc:`Number </components/number/lvgl>` or :doc:`Sensor </components/sensor/lvgl>` component.
|
||||
The ``spinbox`` can be also integrated as a :doc:`Number </components/number/lvgl>` or :doc:`Sensor </components/sensor/lvgl>` component.
|
||||
|
||||
See :ref:`lvgl-cookbook-climate` for an example which demonstrates how to implement a thermostat control using the spinbox.
|
||||
|
||||
.. _lvgl-widget-spinner:
|
||||
|
||||
@ -1531,6 +1547,8 @@ The switch looks like a little slider and can be used to turn something on and o
|
||||
|
||||
The ``switch`` can be also integrated as a :doc:`Switch </components/switch/lvgl>` component.
|
||||
|
||||
See :ref:`lvgl-cookbook-relay` for an example which demonstrates how to use a switch to act on a local component.
|
||||
|
||||
.. _lvgl-widget-tabview:
|
||||
|
||||
``tabview``
|
||||
@ -1781,6 +1799,7 @@ This powerful :ref:`action <actions-action>` allows changing/updating any widget
|
||||
id: my_label_id
|
||||
hidden: true
|
||||
|
||||
Check out in the Cookbook :ref:`lvgl-cookbook-binent` for an example which demonstrates how to use a template to update the state.
|
||||
|
||||
.. _lvgl-automation-shorthands:
|
||||
|
||||
|
BIN
cookbook/images/lvgl_cook_animimg_batt.gif
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
cookbook/images/lvgl_cook_climate.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
cookbook/images/lvgl_cook_clock.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
cookbook/images/lvgl_cook_cover.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
cookbook/images/lvgl_cook_flex_layout.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
cookbook/images/lvgl_cook_font_batt.png
Normal file
After Width: | Height: | Size: 243 B |
BIN
cookbook/images/lvgl_cook_font_binstat.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
cookbook/images/lvgl_cook_font_roboto_mdi.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
cookbook/images/lvgl_cook_gauge.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
cookbook/images/lvgl_cook_gradient_styles.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
cookbook/images/lvgl_cook_keypad.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
cookbook/images/lvgl_cook_pagenav.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
cookbook/images/lvgl_cook_remligbut.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
cookbook/images/lvgl_cook_statico.png
Normal file
After Width: | Height: | Size: 700 B |
BIN
cookbook/images/lvgl_cook_thermometer.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
cookbook/images/lvgl_cook_thermometer_gauge.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
cookbook/images/lvgl_cook_titlebar.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
cookbook/images/lvgl_cook_volume.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
cookbook/images/lvgl_cook_weather.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
2242
cookbook/lvgl.rst
Normal file
@ -1155,6 +1155,7 @@ Cookbook
|
||||
.. imgtable::
|
||||
|
||||
Lambda Magic: Tips and Tricks, cookbook/lambda_magic, head-lightbulb-outline.svg, dark-invert
|
||||
LVGL Recipes, cookbook/lvgl, lvgl.png
|
||||
Garage Door Template Cover, cookbook/garage-door, garage-variant.svg, dark-invert
|
||||
Time & Temperature on OLED Display, cookbook/display_time_temp_oled, display_time_temp_oled_2.jpg
|
||||
ESP32 Water Leak Detector, cookbook/leak-detector-m5stickC, leak-detector-m5stickC_main_index.jpg
|
||||
|