Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LVGL cookbook #4110

Merged
merged 652 commits into from
Sep 15, 2024
Merged

LVGL cookbook #4110

merged 652 commits into from
Sep 15, 2024

Conversation

nagyrobi
Copy link
Member

@nagyrobi nagyrobi commented Aug 5, 2024

Description:

Cookbook originally contained in #3678, which should be merged first.

Related issue (if applicable): fixes

Pull request in esphome with YAML changes (if applicable): esphome/esphome#

Checklist:

  • I am merging into next because this is new documentation that has a matching pull-request in esphome as linked above.
    or

  • I am merging into current because this is a fix, change and/or adjustment in the current documentation and is not for a new component or feature.

  • Link added in /index.rst when creating new documents for new components or cookbook.

nagyrobi and others added 30 commits May 9, 2024 16:00
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
@probot-esphome probot-esphome bot added current and removed next labels Aug 22, 2024
Copy link
Contributor

coderabbitai bot commented Aug 22, 2024

Walkthrough

The changes primarily involve updates to versioning information across multiple configuration and documentation files, reflecting a shift to the development phase for version 2024.9.0. Additionally, several documentation files enhance user guidance by adding references to the Cookbook for practical examples. New configuration options are introduced for Tuya devices, an inverter's output source priority, and other components, improving the clarity and usability of the documentation.

Changes

Files Change Summary
Doxygen configuration files Updated PROJECT_NUMBER from 2024.8.0 to 2024.9.0-dev, indicating a new development phase.
_static/version Updated version string from 2024.8.0 to 2024.9.0-dev, signifying the transition to a development version.
components/lvgl/index.rst Added references to Cookbook for touchscreen interactivity and other functionalities.
components/lvgl/widgets.rst Enhanced documentation with Cookbook links for widget usage and properties.
components/number/tuya.rst Introduced new datapoint_hidden configuration option for handling hidden datapoints in Tuya devices.
components/pipsolar.rst Added new output_source_priority_hybrid configuration option for inverters.
components/tuya.rst Added reference to the number component documentation.
conf.py Updated version from "2024.8" to "2024.9" and release from "2024.8.0" to "2024.9.0-dev".
index.rst Added new entries for "UDP", "CH422G", "BL0906", and "LVGL Recipes" in the image table.
components/binary_sensor/udp.rst Introduced documentation for the UDP binary sensor platform.
components/canbus/esp32_can.rst Added new configuration variables rx_queue_len and tx_queue_len for the ESP32 CAN component.
components/ch422g.rst Provided documentation for the CH422G I/O expander component.
components/climate/climate_ir.rst Expanded the list of supported Daikin ARC remotes with a new entry.
components/display/ili9xxx.rst Introduced new configuration options for color inversion and test card display.
components/light/esp32_rmt_led_strip.rst Added new chipset option WS2811 and configuration variables reset_high and reset_low.
components/modbus_controller.rst Added new optional configuration variable allow_duplicate_commands.
components/sensor/bl0906.rst Provided documentation for the Belling BL0906 Energy Monitor sensor platform.
components/sensor/bl0942.rst Introduced new optional configuration variables line_frequency and address.
components/touchscreen/gt911.rst Added new optional configuration variable reset_pin.
components/udp.rst Documented the UDP component for ESPHome.

Possibly related PRs

Suggested labels

next, has-parent


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3fa2c2f and 19d7c2b.

Files selected for processing (2)
  • components/sensor/bl0942.rst (1 hunks)
  • index.rst (4 hunks)
Additional context used
Path-based instructions (2)
components/sensor/bl0942.rst (1)

Pattern **: - Do not generate or add any sequence diagrams

index.rst (1)

Pattern **: - Do not generate or add any sequence diagrams

Additional comments not posted (6)
components/sensor/bl0942.rst (2)

49-49: LGTM!

The addition of the line_frequency configuration variable enhances the adaptability of the BL0942 sensor to different AC line frequencies. The accepted values cover the two most common frequencies, and the default value is a reasonable choice.


50-50: LGTM!

The addition of the address configuration variable improves the flexibility of the BL0942 sensor configuration when using multiple sensors with different addresses set by the strapping pins. The default value is appropriate for the most common configuration.

index.rst (4)

207-207: LGTM!

The addition of the UDP protocol under "Network Protocols" enhances the documentation's coverage of network communication methods.


270-270: LGTM!

The addition of the CH422G under "I/O Expanders/Multiplexers" enhances the documentation's coverage of available I/O expander components.


406-406: LGTM!

The addition of the BL0906 sensor under "Electricity" broadens the documentation's coverage of available electrical sensors. The description accurately captures the key measurements of voltage, current, power and energy.


1153-1153: Approve the addition. Verify the removal.

The addition of "LVGL Recipes" under "Cookbook" provides valuable resources for leveraging LVGL in ESPHome projects.

However, please verify if the removal of "Share data directly between ESPHome nodes" is intentional, as it's not mentioned in the summary. Ensure that this entry is no longer needed or has been moved elsewhere before removing it.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (21)
cookbook/lvgl.rst (21)

10-10: Clarify the introduction.

Consider rephrasing the introduction to make it more engaging and informative.

- Here are a couple recipes for various interesting things you can do with :doc:`/components/lvgl/index` in ESPHome.
+ Explore a variety of recipes showcasing interesting applications of :doc:`/components/lvgl/index` in ESPHome.

14-14: Enhance clarity in the note about Home Assistant.

The note could be more explicit about the steps required in Home Assistant.

- Many of the examples below call service actions in Home Assistant; however, Home Assistant does not allow such action calls by default.
+ Many of the examples below involve calling service actions in Home Assistant. By default, Home Assistant does not permit these action calls.

28-28: Provide additional context for the example.

Consider adding more context about the use case and benefits of integrating a local light switch with LVGL.

- The easiest way to integrate an LVGL :ref:`lvgl-widget-switch` widget and a switch or light is with :ref:`automations <automation>`:
+ Integrating an LVGL :ref:`lvgl-widget-switch` widget with a switch or light can be easily achieved using :ref:`automations <automation>`. This approach allows for seamless control and synchronization between the physical switch and the virtual widget.

61-61: Expand on the explanation for remote light control.

Consider providing more details on the benefits and potential use cases for controlling a remote light with LVGL.

- If you'd like to control a remote light which appears as an entity in Home Assistant from a checkable (toggle) :ref:`lvgl-widget-button`, first you need to import the light state into ESPHome, and then control it using a action call:
+ To control a remote light entity in Home Assistant using a checkable (toggle) :ref:`lvgl-widget-button`, first import the light state into ESPHome. This setup allows for intuitive control and feedback directly from the LVGL interface, enhancing user interaction and system integration.

143-143: Clarify the conversion explanation.

The explanation about converting float to integer for brightness could be more explicit.

- Note that Home Assistant expects an integer at the ``brightness`` parameter of the ``light.turn_on`` action call, and since ESPHome uses floats, ``x`` needs to be converted.
+ Note that Home Assistant requires an integer for the ``brightness`` parameter in the ``light.turn_on`` action call. Since ESPHome uses floats, the value ``x`` must be converted to an integer.

157-157: Expand on the conversion explanation for volume control.

Consider providing more details on the conversion process between float and integer values for volume control.

- With a sensor we retrieve the current volume level of the media player, which is stored in Home Assistant as an attribute of the entity, and is a float value between ``0`` (min) and ``1`` (max).
+ A sensor retrieves the current volume level of the media player, stored in Home Assistant as a float value between ``0`` (min) and ``1`` (max). To align with LVGL's integer handling, convert these values by multiplying by ``100`` for display and dividing by ``100`` for action calls.

209-209: Enhance the explanation of widget arrangement.

Consider providing more details on the arrangement and purpose of each widget in the semicircle gauge.

- The trick here is to have a parent :ref:`lvgl-widget-obj` which contains the other widgets as children.
+ The key is to use a parent :ref:`lvgl-widget-obj` to contain the other widgets as children. This setup allows for a cohesive design where the :ref:`lvgl-widget-meter` serves as the central gauge, complemented by :ref:`lvgl-widget-label` widgets for displaying numeric information.

309-309: Clarify the scaling approach for the thermometer.

The explanation about scaling could be more explicit regarding the use of multiple scales.

- Since LVGL only handles integer values on the :ref:`lvgl-widget-meter` scale, but the sensor's value is a ``float``, we use the same approach as in the examples above; we multiply the sensor's values by ``10`` and feed this value to the :ref:`lvgl-widget-meter`.
+ Since LVGL handles only integer values on the :ref:`lvgl-widget-meter` scale, while the sensor's value is a ``float``, multiply the sensor's values by ``10`` before feeding them to the :ref:`lvgl-widget-meter`. This approach allows for precise needle positioning and accurate label display.

463-463: Expand on the spinbox usage explanation.

Consider providing more details on the benefits and functionality of using a spinbox for climate control.

- First we import from Home Assistant the current target temperature of the climate component, and we update the value of the spinbox with it whenever it changes.
+ First, import the current target temperature of the climate component from Home Assistant and update the spinbox value whenever it changes. The spinbox allows for precise temperature adjustments, enhancing user control over the climate settings.

535-535: Enhance the explanation of button functionality for cover control.

Consider providing more details on the functionality and interaction of the buttons for cover control.

- Just as in the previous examples, we need to get the state of the cover first.
+ Similar to previous examples, first retrieve the cover's state. The buttons provide intuitive control over the cover's position, with dynamic label updates reflecting the cover's current status and movement.

655-655: Expand on the benefits of using themes and styles.

Consider providing more details on the advantages of defining themes and styles in LVGL.

- Since LVGL uses inheritance to apply styles across the widgets, it's possible to apply them at the top level, and only make modifications on demand, if necessary.
+ LVGL's inheritance model allows styles to be applied at the top level, enabling consistent design across widgets. This approach simplifies customization, as modifications can be made on demand, reducing redundancy and improving maintainability.

762-762: Enhance the explanation of navigation bar benefits.

Consider providing more details on the advantages of using a navigation bar in LVGL.

- If using multiple pages, a navigation bar can be useful at the bottom of the screen:
+ When working with multiple pages, a navigation bar at the bottom of the screen enhances user experience by providing quick access to different sections, improving navigation efficiency and usability.

815-815: Expand on the status icon functionality explanation.

Consider providing more details on the functionality and benefits of displaying an API connection status icon.

- In the example below, we only show the icon when the connection with Home Assistant is established:
+ In the example below, the icon is displayed only when the connection with Home Assistant is established. This visual indicator provides real-time feedback on the connection status, enhancing user awareness and system monitoring.

862-862: Enhance the explanation of title bar benefits.

Consider providing more details on the advantages of using a title bar for each LVGL page.

- Each page can have its own title bar:
+ Adding a title bar to each page provides clear context and identification, enhancing the user interface by displaying relevant information and improving navigation clarity.

901-901: Expand on the benefits of using Flex layout.

Consider providing more details on the advantages of using Flex layout in LVGL.

- :ref:`lvgl-layouts` aim to position widgets automatically, eliminating the need to specify coordinates to position each widget.
+ :ref:`lvgl-layouts` automatically position widgets, eliminating the need for manual coordinate specification. This approach simplifies configuration, reduces errors, and enhances the adaptability of the user interface to different screen sizes and orientations.

1028-1028: Enhance the explanation of Grid layout benefits.

Consider providing more details on the advantages of using Grid layout in LVGL.

- But there's even more! With the **Grid** layout, you don't need to specify width and height for your widgets.
+ The **Grid** layout offers a powerful way to organize widgets without specifying their width and height. By dividing space into rows and columns, it ensures consistent alignment and spacing, simplifying layout management and enhancing design flexibility.

1178-1178: Expand on the boot screen functionality explanation.

Consider providing more details on the functionality and benefits of using a boot screen in LVGL.

- To display a boot image with a spinner animation which disappears automatically after a few moments or on touch of the screen you can use the *top layer*.
+ Displaying a boot image with a spinner animation provides a visually appealing startup sequence. By using the *top layer*, this screen can automatically disappear after a set duration or upon user interaction, enhancing the user experience during device initialization.

1237-1237: Enhance the explanation of using MDI icons.

Consider providing more details on the advantages of integrating MDI icons into text in LVGL.

- One example is when you'd like some MDI icons to be used in line with the text (similar to how LVGL's internal fonts and symbols coexist).
+ Integrating MDI icons inline with text allows for rich visual representation, enhancing the interface's aesthetic and functional appeal. This approach provides flexibility in design, enabling the use of symbols and icons alongside text for improved user interaction.

1283-1283: Clarify the issue and solution for restoring checkbox mark.

Consider providing more details on the issue with the checkbox mark and how the solution addresses it.

- If you configure a custom font as the ``default_font`` used by LVGL and this font does not contain the `FontAwesome <https://fontawesome.com/>`__ symbols, you may observe that some widgets won't display correctly; specifically :ref:`lvgl-widget-checkbox` won't show the checkmark when it's checked.
+ When using a custom font as the ``default_font`` in LVGL, missing `FontAwesome <https://fontawesome.com/>`__ symbols can lead to display issues, such as the :ref:`lvgl-widget-checkbox` not showing the checkmark. The solution involves importing only the necessary checkmark symbol, ensuring proper display without bloating the binary size.

1316-1316: Expand on the toggle button functionality explanation.

Consider providing more details on the functionality and benefits of using a toggle state icon button.

- A common use case for icons is a status display. For example, a checkable (toggle) button will display different icons based on the status of a light or switch.
+ Icons are commonly used for status displays. A checkable (toggle) button can dynamically display different icons based on the status of a light or switch, providing immediate visual feedback and enhancing user interaction.

1388-1388: Enhance the explanation of battery status display.

Consider providing more details on the benefits and functionality of displaying battery status with icons.

- Another example for using MDI icons is to display battery percentage in 10 steps.
+ MDI icons can effectively represent battery percentage in 10 steps, providing a clear visual indication of battery status. This approach enhances user awareness and allows for quick assessment of battery levels.

@nagyrobi nagyrobi changed the base branch from current to next September 3, 2024 14:07
@probot-esphome probot-esphome bot added next and removed current labels Sep 3, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (2)
components/binary_sensor/udp.rst (1)

26-26: Improve the description of the internal option.

The description of the internal option is slightly inconsistent. It states that the option "Defaults to true if name is not set, required if name is provided." However, the previous sentence mentions that the option determines whether the sensor should be exposed via API.

Consider rephrasing the description to improve clarity, for example:

-  **internal** (*Optional*, boolean): Whether the sensor should be exposed via API (e.g. to Home Assistant.) Defaults to ``true`` if name is not set, required if name is provided.
+  **internal** (*Optional*, boolean): Whether the sensor should be exposed via API (e.g. to Home Assistant.) Defaults to ``true``. If a name is provided, this option must be explicitly set to ``false`` to expose the sensor.
components/lvgl/widgets.rst (1)

Line range hint 1-1: Reminder: Add tests.

The TODO comment indicates that tests are missing. Adding tests is a best practice to ensure code quality and catch regressions.

Do you want me to help create a test plan or open a GitHub issue to track adding tests?

jesserockz
jesserockz previously approved these changes Sep 15, 2024
@jesserockz jesserockz changed the base branch from next to current September 15, 2024 09:47
@jesserockz jesserockz dismissed their stale review September 15, 2024 09:47

The base branch was changed.

@probot-esphome probot-esphome bot added current and removed next labels Sep 15, 2024
@jesserockz jesserockz changed the base branch from current to next September 15, 2024 09:59
@probot-esphome probot-esphome bot added next and removed current labels Sep 15, 2024
@jesserockz jesserockz added this to the 2024.9.0b2 milestone Sep 15, 2024
@jesserockz jesserockz merged commit 7d61eb1 into esphome:next Sep 15, 2024
3 of 6 checks passed
@nagyrobi nagyrobi deleted the lvgl-next-cookbook branch September 15, 2024 10:11
jesserockz added a commit that referenced this pull request Sep 15, 2024
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>
@jesserockz jesserockz mentioned this pull request Sep 15, 2024
@coderabbitai coderabbitai bot mentioned this pull request Sep 16, 2024
3 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Sep 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants