@@ -35,6 +35,7 @@ static esp_err_t panel_sh8601_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool
3535static esp_err_t panel_sh8601_swap_xy (esp_lcd_panel_t * panel , bool swap_axes );
3636static esp_err_t panel_sh8601_set_gap (esp_lcd_panel_t * panel , int x_gap , int y_gap );
3737static esp_err_t panel_sh8601_disp_on_off (esp_lcd_panel_t * panel , bool off );
38+ static esp_err_t panel_sh8601_set_brightness (esp_lcd_panel_t * panel , int brightness );
3839
3940typedef struct {
4041 esp_lcd_panel_t base ;
@@ -121,6 +122,7 @@ esp_err_t esp_lcd_new_panel_sh8601(const esp_lcd_panel_io_handle_t io, const esp
121122 sh8601 -> base .mirror = panel_sh8601_mirror ;
122123 sh8601 -> base .swap_xy = panel_sh8601_swap_xy ;
123124 sh8601 -> base .disp_on_off = panel_sh8601_disp_on_off ;
125+ sh8601 -> base .set_brightness = panel_sh8601_set_brightness ;
124126 * ret_panel = & (sh8601 -> base );
125127 ESP_LOGD (TAG , "new sh8601 panel @%p" , sh8601 );
126128
@@ -345,3 +347,19 @@ static esp_err_t panel_sh8601_disp_on_off(esp_lcd_panel_t *panel, bool on_off)
345347 ESP_RETURN_ON_ERROR (tx_param (sh8601 , io , command , NULL , 0 ), TAG , "send command failed" );
346348 return ESP_OK ;
347349}
350+
351+ static esp_err_t panel_sh8601_set_brightness (esp_lcd_panel_t * panel , int brightness )
352+ {
353+ sh8601_panel_t * sh8601 = __containerof (panel , sh8601_panel_t , base );
354+ esp_lcd_panel_io_handle_t io = sh8601 -> io ;
355+
356+ // Clamp brightness to 0-1023 range (10-bit)
357+ uint16_t brightness_val = (brightness < 0 ) ? 0 : (brightness > 1023 ) ? 1023 : (uint16_t )brightness ;
358+ // Send as 2 bytes: MSB and LSB
359+ return tx_param (sh8601 , io , LCD_CMD_WRDISBV , (uint8_t []) { (brightness_val >> 8 ) & 0xFF , brightness_val & 0xFF }, 2 );
360+ }
361+
362+ esp_err_t esp_lcd_sh8601_set_brightness (esp_lcd_panel_handle_t panel , uint16_t brightness )
363+ {
364+ return esp_lcd_panel_set_brightness (panel , brightness );
365+ }
0 commit comments