esp-arduino-libs / ESP32_Display_Panel

Arduino library of driving display panel for the ESP SoCs
Apache License 2.0
98 stars 23 forks source link

Backlight control requirements #131

Open Y1hsiaochunnn opened 3 days ago

Y1hsiaochunnn commented 3 days ago

According to contact with a variety of screen backlight control, can be classified as the following:


so, i know you have the plan to implement backlight control next. Maybe you can consider the above several types of backlight control scheme? Please let me know if you need anything

Lzw655 commented 3 days ago

Hi @Y1hsiaochunnn,

Thank you very much for your suggestions. They are extremely comprehensive. Although I haven’t encountered the last method using QSPI or MIPI-DSI protocols for control.

I also realize that the current library’s approach to backlight control, using Switch (GPIO) and PWM (LEDC) methods, doesn’t meet the requirements of many development boards. Therefore, I am restactoring this library and plan to introduce a Custom method on top of the Switch and PWM methods to accommodate different development board requirements. The expected updated configuration file is as follows:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// Please update the following macros to configure the backlight ////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ESP_PANEL_USE_BACKLIGHT         (1)         // 0/1
#if ESP_PANEL_USE_BACKLIGHT
/**
 * Backlight control mode. Choose one of the following:
 *  - ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO: Use GPIO switch to control the backlight, only support on/off
 *  - ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC:    Use LEDC PWM to control the backlight, support brightness adjustment
 *  - ESP_PANEL_BACKLIGHT_TYPE_CUSTOM:      Use custom function to control the backlight
 *
 */
#define ESP_PANEL_BACKLIGHT_TYPE        (ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC)

#if ESP_PANEL_BACKLIGHT_TYPE != ESP_PANEL_BACKLIGHT_TYPE_CUSTOM
/* IO num of backlight pin */
#define ESP_PANEL_BACKLIGHT_IO          (47)
#define ESP_PANEL_BACKLIGHT_ON_LEVEL    (1)         // 0: low level, 1: high level
#else
/**
 * @brief Custom backlight control function
 *
 * @param[in] percent   Brightness percentage, 0-100
 * @param[in] user_data User data, default is a pointer of `Board`
 *
 */
#define ESP_PANEL_BACKLIGHT_CUSTOM_FUNCTION( percent, user_data )  \
    {  \
        Board *board = static_cast<Board *>(user_data);  \
    }
#endif /* ESP_PANEL_BACKLIGHT_TYPE */

/* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */
#define ESP_PANEL_BACKLIGHT_IDLE_OFF    (0)         // 0: on, 1: off

#endif /* ESP_PANEL_USE_BACKLIGHT */
Y1hsiaochunnn commented 3 days ago

Hi @Y1hsiaochunnn,

Thank you very much for your suggestions. They are extremely comprehensive. Although I haven’t encountered the last method using QSPI or MIPI-DSI protocols for control.

I also realize that the current library’s approach to backlight control, using Switch (GPIO) and PWM (LEDC) methods, doesn’t meet the requirements of many development boards. Therefore, I am restactoring this library and plan to introduce a Custom method on top of the Switch and PWM methods to accommodate different development board requirements. The expected updated configuration file is as follows:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// Please update the following macros to configure the backlight ////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ESP_PANEL_USE_BACKLIGHT         (1)         // 0/1
#if ESP_PANEL_USE_BACKLIGHT
/**
 * Backlight control mode. Choose one of the following:
 *  - ESP_PANEL_BACKLIGHT_TYPE_SWITCH_GPIO: Use GPIO switch to control the backlight, only support on/off
 *  - ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC:    Use LEDC PWM to control the backlight, support brightness adjustment
 *  - ESP_PANEL_BACKLIGHT_TYPE_CUSTOM:      Use custom function to control the backlight
 *
 */
#define ESP_PANEL_BACKLIGHT_TYPE        (ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC)

#if ESP_PANEL_BACKLIGHT_TYPE != ESP_PANEL_BACKLIGHT_TYPE_CUSTOM
/* IO num of backlight pin */
#define ESP_PANEL_BACKLIGHT_IO          (47)
#define ESP_PANEL_BACKLIGHT_ON_LEVEL    (1)         // 0: low level, 1: high level
#else
/**
 * @brief Custom backlight control function
 *
 * @param[in] percent   Brightness percentage, 0-100
 * @param[in] user_data User data, default is a pointer of `Board`
 *
 */
#define ESP_PANEL_BACKLIGHT_CUSTOM_FUNCTION( percent, user_data )  \
    {  \
        Board *board = static_cast<Board *>(user_data);  \
    }
#endif /* ESP_PANEL_BACKLIGHT_TYPE */

/* Set to 1 if you want to turn off the backlight after initializing the panel; otherwise, set it to turn on */
#define ESP_PANEL_BACKLIGHT_IDLE_OFF    (0)         // 0: on, 1: off

#endif /* ESP_PANEL_USE_BACKLIGHT */

Maybe after some time, I can lend you a piece of product based on ESP32-S3 SH8601 QSPI communication, just to verify the function of SH8601. At present, I can't adjust it, this may be some of my Settings. This product also uses QSPI to configure the screen (of course it also supports MIPI 1-lane, but it does not do this at present, P4 may be more suitable), and changes the backlight by modifying the register 0x51

Lzw655 commented 3 days ago

Great! I'm looking forward to it.