Don't call backlight function when backlight is disabled
This commit is contained in:
parent
1801416c13
commit
607df9ab94
|
@ -934,16 +934,9 @@ menu "LVGL TFT Display controller"
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
choice
|
choice
|
||||||
|
default LV_DISP_BACKLIGHT_SWITCH
|
||||||
prompt "Backlight Control" if \
|
prompt "Backlight Control" if \
|
||||||
(! ( LV_TFT_DISPLAY_CONTROLLER_SH1107 || LV_TFT_DISPLAY_CONTROLLER_SSD1306 ) )
|
(! ( LV_TFT_DISPLAY_CONTROLLER_SH1107 || LV_TFT_DISPLAY_CONTROLLER_SSD1306 ) )
|
||||||
default LV_DISP_BACKLIGHT_SWITCH if LV_PREDEFINED_DISPLAY_M5STACK
|
|
||||||
default LV_DISP_BACKLIGHT_OFF if LV_PREDEFINED_DISPLAY_M5CORE2
|
|
||||||
default LV_DISP_BACKLIGHT_SWITCH if LV_PREDEFINED_DISPLAY_WROVER4
|
|
||||||
default LV_DISP_BACKLIGHT_SWITCH if LV_PREDEFINED_DISPLAY_ERTFT0356
|
|
||||||
default LV_DISP_BACKLIGHT_SWITCH if LV_PREDEFINED_DISPLAY_TTGO
|
|
||||||
default LV_DISP_BACKLIGHT_SWITCH if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
|
|
||||||
default LV_DISP_BACKLIGHT_SWITCH if LV_PREDEFINED_DISPLAY_WT32_SC01
|
|
||||||
default LV_DISP_BACKLIGHT_OFF
|
|
||||||
|
|
||||||
config LV_DISP_BACKLIGHT_OFF
|
config LV_DISP_BACKLIGHT_OFF
|
||||||
bool
|
bool
|
||||||
|
@ -995,7 +988,7 @@ menu "LVGL TFT Display controller"
|
||||||
default 4 if LV_PREDEFINED_DISPLAY_TTGO
|
default 4 if LV_PREDEFINED_DISPLAY_TTGO
|
||||||
default 2 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
|
default 2 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
|
||||||
default 23 if LV_PREDEFINED_DISPLAY_WT32_SC01
|
default 23 if LV_PREDEFINED_DISPLAY_WT32_SC01
|
||||||
default 27
|
default -1
|
||||||
|
|
||||||
help
|
help
|
||||||
Configure the display BCLK (LED) pin here.
|
Configure the display BCLK (LED) pin here.
|
||||||
|
|
|
@ -47,7 +47,7 @@ void *disp_driver_init(void)
|
||||||
|
|
||||||
// We still use menuconfig for these settings
|
// We still use menuconfig for these settings
|
||||||
// It will be set up during runtime in the future
|
// It will be set up during runtime in the future
|
||||||
#ifndef CONFIG_LV_DISP_BACKLIGHT_OFF
|
#if (defined(CONFIG_LV_DISP_BACKLIGHT_SWITCH) || defined(CONFIG_LV_DISP_BACKLIGHT_PWM))
|
||||||
const disp_backlight_config_t bckl_config = {
|
const disp_backlight_config_t bckl_config = {
|
||||||
.gpio_num = CONFIG_LV_DISP_PIN_BCKL,
|
.gpio_num = CONFIG_LV_DISP_PIN_BCKL,
|
||||||
#if defined CONFIG_LV_DISP_BACKLIGHT_PWM
|
#if defined CONFIG_LV_DISP_BACKLIGHT_PWM
|
||||||
|
@ -63,15 +63,12 @@ void *disp_driver_init(void)
|
||||||
.timer_idx = 0,
|
.timer_idx = 0,
|
||||||
.channel_idx = 0 // @todo this prevents us from having two PWM controlled displays
|
.channel_idx = 0 // @todo this prevents us from having two PWM controlled displays
|
||||||
};
|
};
|
||||||
const disp_backlight_config_t *bckl_config_p = &bckl_config;
|
disp_backlight_h bckl_handle = disp_backlight_new(&bckl_config);
|
||||||
#else
|
|
||||||
const disp_backlight_config_t *bckl_config_p = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
disp_backlight_h bckl_handle = disp_backlight_new(bckl_config_p);
|
|
||||||
disp_backlight_set(bckl_handle, 100);
|
disp_backlight_set(bckl_handle, 100);
|
||||||
|
|
||||||
return bckl_handle;
|
return bckl_handle;
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void disp_driver_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
|
void disp_driver_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
|
||||||
|
|
|
@ -22,11 +22,16 @@ static const char *TAG = "disp_backlight";
|
||||||
|
|
||||||
disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config)
|
disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config)
|
||||||
{
|
{
|
||||||
|
// Check input parameters
|
||||||
if (config == NULL)
|
if (config == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (!GPIO_IS_VALID_OUTPUT_GPIO(config->gpio_num)) {
|
||||||
|
ESP_LOGW(TAG, "Invalid GPIO number");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
disp_backlight_t *bckl_dev = calloc(1, sizeof(disp_backlight_t));
|
disp_backlight_t *bckl_dev = calloc(1, sizeof(disp_backlight_t));
|
||||||
if (bckl_dev == NULL){
|
if (bckl_dev == NULL){
|
||||||
ESP_LOGW(TAG, "Could not create new LCD backlight instance");
|
ESP_LOGW(TAG, "Not enough memory");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue