feat(esp_lcd_sh8601): add brightness control to the panel (AEGHB-1429)#668
feat(esp_lcd_sh8601): add brightness control to the panel (AEGHB-1429)#668ldab wants to merge 1 commit into
Conversation
👋 Hello ldab, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
There was a problem hiding this comment.
Pull request overview
Adds brightness control support for the SH8601 LCD panel driver so users (and potentially generic panel ops) can adjust display brightness.
Changes:
- Exposes a new public brightness-setting API in
esp_lcd_sh8601.h. - Implements SH8601 brightness control via
LCD_CMD_WRDISBVand wires it into the panel driver ops.
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| components/display/lcd/esp_lcd_sh8601/include/esp_lcd_sh8601.h | Adds a public API declaration for setting SH8601 brightness. |
| components/display/lcd/esp_lcd_sh8601/esp_lcd_sh8601.c | Implements brightness command handling and registers the new brightness op on the panel handle. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| static esp_err_t panel_sh8601_set_brightness(esp_lcd_panel_t *panel, int brightness) | ||
| { | ||
| sh8601_panel_t *sh8601 = __containerof(panel, sh8601_panel_t, base); | ||
| esp_lcd_panel_io_handle_t io = sh8601->io; | ||
|
|
||
| // Clamp brightness to 0-1023 range (10-bit) | ||
| uint16_t brightness_val = (brightness < 0) ? 0 : (brightness > 1023) ? 1023 : (uint16_t)brightness; | ||
| // Send as 2 bytes: MSB and LSB | ||
| return tx_param(sh8601, io, LCD_CMD_WRDISBV, (uint8_t[]) { (brightness_val >> 8) & 0xFF, brightness_val & 0xFF }, 2); | ||
| } |
There was a problem hiding this comment.
Brightness support is introduced here, but there are existing Unity hardware tests for SH8601 under test_apps/ and none exercise the new brightness path. Please add at least a basic call (and error check) in the test app(s) so the new API is built and executed in CI/hardware test runs.
| sh8601->base.swap_xy = panel_sh8601_swap_xy; | ||
| sh8601->base.disp_on_off = panel_sh8601_disp_on_off; | ||
| sh8601->base.set_brightness = panel_sh8601_set_brightness; | ||
| *ret_panel = &(sh8601->base); |
There was a problem hiding this comment.
Assigning sh8601->base.set_brightness assumes the set_brightness function pointer exists in esp_lcd_panel_t. If this component is meant to support IDF versions where that field is absent, this assignment will break the build. Please guard this assignment with an appropriate IDF version/feature check or avoid touching the base struct when building against older IDF versions.
There was a problem hiding this comment.
New public API name esp_lcd_sh8601_set_brightness() is inconsistent with the naming used by other panel drivers that expose extra panel APIs (e.g. esp_lcd_panel_co5300_set_brightness() in components/display/lcd/esp_lcd_co5300/include/esp_lcd_co5300.h:88). Consider renaming to esp_lcd_panel_sh8601_set_brightness() (and optionally keeping esp_lcd_sh8601_set_brightness() as a backward-compatible alias) to align with existing naming patterns.
| @@ -35,6 +35,7 @@ static esp_err_t panel_sh8601_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool | |||
| static esp_err_t panel_sh8601_swap_xy(esp_lcd_panel_t *panel, bool swap_axes); | |||
| static esp_err_t panel_sh8601_set_gap(esp_lcd_panel_t *panel, int x_gap, int y_gap); | |||
| static esp_err_t panel_sh8601_disp_on_off(esp_lcd_panel_t *panel, bool off); | |||
There was a problem hiding this comment.
The forward declaration panel_sh8601_disp_on_off(…, bool off) uses a parameter name (off) that doesn't match the implementation (bool on_off). This is minor but can be confusing when reading stack traces or debugging; consider renaming the parameter in the prototype to match the definition.
| static esp_err_t panel_sh8601_disp_on_off(esp_lcd_panel_t *panel, bool off); | |
| static esp_err_t panel_sh8601_disp_on_off(esp_lcd_panel_t *panel, bool on_off); |
Description
Add display brightness controll
Related
Goes with IDF espressif/esp-idf#18273
Testing
Checklist
Before submitting a Pull Request, please ensure the following: