Skip to content

feat(lcd): add brightness control for LCD panels (IDFGH-17284)#18273

Open
ldab wants to merge 1 commit intoespressif:release/v5.5from
ldab:release/v5.5
Open

feat(lcd): add brightness control for LCD panels (IDFGH-17284)#18273
ldab wants to merge 1 commit intoespressif:release/v5.5from
ldab:release/v5.5

Conversation

@ldab
Copy link
Contributor

@ldab ldab commented Feb 24, 2026

Description

This pull request introduces a new API for setting the brightness of LCD panels in the ESP-IDF LCD driver. The changes add both a high-level function and an interface method to support brightness control, allowing panels that implement this feature to expose it in a standardized way.

New brightness control API:

  • Added the esp_lcd_panel_set_brightness function to the public API in esp_lcd_panel_ops.h, allowing users to set the display brightness for panels that support this feature.
  • Implemented the esp_lcd_panel_set_brightness function in esp_lcd_panel_ops.c, including input validation and error handling if the panel does not support brightness control.

Panel interface extension:

  • Added a new set_brightness function pointer to the esp_lcd_panel_t struct in esp_lcd_panel_interface.h, enabling panel drivers to implement their own brightness control logic.

Related

Testing


Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

Note

Medium Risk
Adds a new public API and extends the core esp_lcd_panel_t interface struct, which can affect ABI/compatibility and any out-of-tree panel implementations that initialize the struct.

Overview
Adds a new optional brightness-control API for LCD panels via esp_lcd_panel_set_brightness().

Extends esp_lcd_panel_t with a set_brightness function pointer and wires the public wrapper to validate the handle, return ESP_ERR_NOT_SUPPORTED when unimplemented, and delegate to the panel driver implementation.

Written by Cursor Bugbot for commit 7d58f1b. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings February 24, 2026 14:41
@CLAassistant
Copy link

CLAassistant commented Feb 24, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

github-actions bot commented Feb 24, 2026

Warnings
⚠️
	The **target branch** for this Pull Request **must be the default branch** of the project (`master`).

	If you would like to add this feature to a different branch, please state this in the PR description and we will consider it.

👋 Hello ldab, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests via this public GitHub repository.

This GitHub project is public mirror of our internal git repository

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved, we synchronize it into our internal git repository.
4. In the internal git repository we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
5. If the change is approved and passes the tests it is merged into the default branch.
5. On next sync from the internal git repository merged change will appear in this public GitHub repository.

Generated by 🚫 dangerJS against 7d58f1b

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on March 20

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
*/
esp_err_t (*set_brightness)(esp_lcd_panel_t *panel, int brightness);

Copy link

Choose a reason for hiding this comment

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

ABI break from interface struct change

High Severity

Adding set_brightness to struct esp_lcd_panel_t changes the struct layout, which can break binary compatibility for any out-of-tree/prebuilt panel drivers that allocate or embed esp_lcd_panel_t with the old size/layout. This can manifest as memory corruption when user_data is accessed or when the struct is initialized.

Fix in Cursor Fix in Web

ESP_RETURN_ON_FALSE(panel, ESP_ERR_INVALID_ARG, TAG, "invalid panel handle");
ESP_RETURN_ON_FALSE(panel->set_brightness, ESP_ERR_NOT_SUPPORTED, TAG, "set_brightness is not supported by this panel");
return panel->set_brightness(panel, brightness);
}
Copy link

Choose a reason for hiding this comment

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

Brightness API lacks input validation

Medium Severity

esp_lcd_panel_set_brightness() forwards brightness directly to panel->set_brightness() without any validation (e.g., negative values). If callers pass an out-of-range int, panel drivers may cast to unsigned or program invalid hardware values, leading to unexpected behavior.

Fix in Cursor Fix in Web

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new brightness-control entry point to the ESP-IDF LCD panel abstraction so panel drivers can optionally expose brightness adjustment through a common API.

Changes:

  • Introduces esp_lcd_panel_set_brightness() as a new public LCD panel ops API.
  • Extends esp_lcd_panel_t with a set_brightness function pointer.
  • Implements the new wrapper in esp_lcd_panel_ops.c with basic handle/support checks.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
components/esp_lcd/src/esp_lcd_panel_ops.c Adds the public wrapper that dispatches brightness control to the panel implementation.
components/esp_lcd/interface/esp_lcd_panel_interface.h Extends the panel vtable with a set_brightness hook and documents it.
components/esp_lcd/include/esp_lcd_panel_ops.h Exposes the new brightness API in the public header and documents it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +134 to 145
/**
* @brief Set the brightness of the display
*
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
* @param[in] brightness Brightness value (range depends on panel implementation, typically 0-255 or 0-100)
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
*/
esp_err_t (*set_brightness)(esp_lcd_panel_t *panel, int brightness);

void *user_data; /*!< User data, used to store externally customized data */
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

esp_lcd_panel_t is a public struct; inserting set_brightness before user_data changes the offset of user_data. This can break binary compatibility (and even source compatibility for any code using positional aggregate initialization). Consider appending the new function pointer after user_data, or adding reserved fields for future expansion to keep existing offsets stable.

Copilot uses AI. Check for mistakes.
Comment on lines +147 to +156
/**
* @brief Set the brightness of the display
*
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
* @param[in] brightness Brightness value (range depends on panel implementation, typically 0-255, 0-1023, or 0-100)
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
*/
esp_err_t esp_lcd_panel_set_brightness(esp_lcd_panel_handle_t panel, int brightness);
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The documentation says the brightness range depends on the panel implementation (and the range examples differ between this header and esp_lcd_panel_interface.h). For a “standardized” API, this ambiguity makes it hard for applications to use consistently. Consider defining a single unit/range for brightness (e.g., 0–100 percent) or adding an accompanying capability/range query so callers can scale appropriately.

Copilot uses AI. Check for mistakes.
Comment on lines +135 to +143
* @brief Set the brightness of the display
*
* @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
* @param[in] brightness Brightness value (range depends on panel implementation, typically 0-255 or 0-100)
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
*/
esp_err_t (*set_brightness)(esp_lcd_panel_t *panel, int brightness);
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The brightness range examples are inconsistent between the interface (typically 0-255 or 0-100) and the public ops header (0-255, 0-1023, or 0-100). Please align these docs so panel authors and API users get the same guidance.

Copilot uses AI. Check for mistakes.
@github-actions github-actions bot changed the title feat(lcd): add brightness control for LCD panels feat(lcd): add brightness control for LCD panels (IDFGH-17284) Feb 24, 2026
@espressif-bot espressif-bot added the Status: Opened Issue is new label Feb 24, 2026
@ldab ldab changed the base branch from release/v5.5 to master February 24, 2026 15:03
@ldab ldab closed this Feb 24, 2026
@ldab ldab reopened this Feb 24, 2026
@ldab ldab changed the base branch from master to release/v5.5 February 24, 2026 15:05
ldab added a commit to ldab/esp-iot-solution that referenced this pull request Feb 24, 2026
ldab added a commit to ldab/esp-iot-solution that referenced this pull request Feb 24, 2026
@suda-morris
Copy link
Collaborator

sha=7d58f1b0099d57199090d33e1a9e0b08e0f55e38

@suda-morris suda-morris added the PR-Sync-Merge Pull request sync as merge commit label Feb 25, 2026
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Feb 25, 2026
@suda-morris suda-morris added PR-Sync-Merge Pull request sync as merge commit and removed PR-Sync-Merge Pull request sync as merge commit labels Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Sync-Merge Pull request sync as merge commit Status: In Progress Work is in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants