Skip to content

[lvgl] Add radial and conical gradient support#143

Draft
Copilot wants to merge 1 commit into
devfrom
copilot/add-radial-conical-gradient-support
Draft

[lvgl] Add radial and conical gradient support#143
Copilot wants to merge 1 commit into
devfrom
copilot/add-radial-conical-gradient-support

Conversation

Copy link
Copy Markdown

Copilot AI commented May 3, 2026

What does this implement/fix?

LVGL 9.5.0 added support for radial and conical gradient types via lv_grad_radial_init(), lv_grad_radial_set_focal(), and lv_grad_conical_init(). This PR adds the necessary ESPHome Python configuration code to expose these new gradient types, alongside a new LV_GRAD_EXTEND constant (PAD/REPEAT/REFLECT) used by all three positional gradient types (linear, radial, conical).

The existing HOR/VER gradient handling is unchanged. The new LINEAR type exposes the full lv_grad_linear_init() API (previously only accessible via the HOR/VER shortcuts).

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — policy
  • Developer breaking change (an API change that could break external components) — policy
  • Undocumented C++ API change (removal or change of undocumented public methods that lambda users may depend on) — policy
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable):

Pull request in esphome-docs with documentation (if applicable):

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040/RP2350
  • BK72xx
  • RTL87xx
  • LN882x
  • nRF52840

Example entry for config.yaml:

lvgl:
  gradients:
    # Linear gradient with custom start/end points and extend mode
    - id: diagonal_grad
      direction: LINEAR
      linear:
        from_x: 0%
        from_y: 0%
        to_x: 100%
        to_y: 100%
        extend: PAD
      stops:
        - color: 0xFF0000
          position: 0
        - color: 0x0000FF
          position: 255

    # Radial gradient (circle expanding from center)
    - id: radial_grad
      direction: RADIAL
      radial:
        center_x: 50%
        center_y: 50%
        to_x: 100%
        to_y: 50%
        extend: PAD
      stops:
        - color: 0xFFFFFF
          position: 0
        - color: 0x000000
          position: 255

    # Radial gradient with a focal point (offset inner circle)
    - id: radial_focal_grad
      direction: RADIAL
      radial:
        center_x: 50%
        center_y: 50%
        to_x: 100%
        to_y: 50%
        focal_x: 30%
        focal_y: 40%
        focal_radius: 10
        extend: REPEAT
      stops:
        - color: 0xFF8800
          position: 0
        - color: 0x0088FF
          position: 255

    # Conical gradient (angular sweep around a center point)
    - id: conical_grad
      direction: CONICAL
      conical:
        center_x: 50%
        center_y: 50%
        start_angle: 0
        end_angle: 360
        extend: PAD
      stops:
        - color: 0xFF0000
          position: 0
        - color: 0x00FF00
          position: 127
        - color: 0xFF0000
          position: 255

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

Agent-Logs-Url: https://github.com/clydebarrow/esphome/sessions/442ec099-d163-4102-b27a-70af7755a583

Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com>
@clydebarrow clydebarrow force-pushed the copilot/add-radial-conical-gradient-support branch from 756db22 to 7e4f769 Compare May 3, 2026 10:23
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

To use the changes from this PR as an external component, add the following to your ESPHome configuration YAML file:

external_components:
  - source: github://clydebarrow/esphome@pull/143/head
    components: [lvgl]
    refresh: 1h

(Added by the PR bot)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

Memory Impact Analysis

Components: lvgl
Platform: esp32-idf

Metric Target Branch This PR Change
RAM 56,284 bytes 56,660 bytes 📈 🔸 +376 bytes (+0.67%)
Flash 1,259,903 bytes 1,261,107 bytes 📈 🔸 +1,204 bytes (+0.10%)
📊 Component Memory Breakdown
Component Target Flash PR Flash Change
[esphome]core 118,355 bytes 119,065 bytes 📈 🔸 +710 bytes (+0.60%)
[lib]lvgl 318,750 bytes 319,009 bytes 📈 +259 bytes (+0.08%)
libc 60,419 bytes 60,505 bytes 📈 +86 bytes (+0.14%)
[lib]mdns 25,267 bytes 25,275 bytes 📈 +8 bytes (+0.03%)
🔍 Symbol-Level Changes (click to expand)

Changed Symbols

Symbol Target Size PR Size Change
setup() 26,638 bytes 27,330 bytes 📈 +692 bytes (+2.60%)
mdns_priv_browse_sync 79 bytes 87 bytes 📈 +8 bytes (+10.13%)

New Symbols (top 15)

Symbol Size
lv_grad_radial_init 78 bytes
esphome__radial_focal_grad__pstorage 76 bytes
esphome__radial_grad__pstorage 76 bytes
esphome__linear_grad__pstorage 76 bytes
esphome__conical_grad__pstorage 76 bytes
lv_grad_conical_init 70 bytes
lv_grad_linear_init 67 bytes
C$1651$8 44 bytes
lv_grad_radial_set_focal 44 bytes
C$1559$6 40 bytes
C$1566$7 40 bytes
C$484$3 28 bytes
setup()::conical_grad_colors_ 9 bytes
guard variable for setup()::radial_focal_grad_colors_ 8 bytes
guard variable for setup()::linear_grad_colors_ 8 bytes
14 more new symbols... Total: 800 bytes

Removed Symbols (top 15)

Symbol Size
C$1643$8 44 bytes
C$1551$6 40 bytes
C$1558$7 40 bytes
C$476$3 28 bytes
C$64$2 8 bytes

Note: This analysis measures static RAM and Flash usage only (compile-time allocation).
Dynamic memory (heap) cannot be measured automatically.
⚠️ You must test this PR on a real device to measure free heap and ensure no runtime memory issues.

This analysis runs automatically when components change. Memory usage is measured from a representative test configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants