Merge pull request #99 from lvgl/fix/backlight-off
Don't call backlight function when backlight is disabled
This commit is contained in:
commit
6a3e46e509
|
@ -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)
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "driver/ledc.h"
|
#include "driver/ledc.h"
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_rom_gpio.h" // for output signal inversion
|
|
||||||
#include "soc/ledc_periph.h" // to invert LEDC output on IDF version < v4.3
|
#include "soc/ledc_periph.h" // to invert LEDC output on IDF version < v4.3
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -22,11 +21,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +56,7 @@ disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config)
|
||||||
|
|
||||||
ESP_ERROR_CHECK(ledc_timer_config(&LCD_backlight_timer));
|
ESP_ERROR_CHECK(ledc_timer_config(&LCD_backlight_timer));
|
||||||
ESP_ERROR_CHECK(ledc_channel_config(&LCD_backlight_channel));
|
ESP_ERROR_CHECK(ledc_channel_config(&LCD_backlight_channel));
|
||||||
esp_rom_gpio_connect_out_signal(config->gpio_num, ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + config->channel_idx, config->output_invert, 0);
|
gpio_matrix_out(config->gpio_num, ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + config->channel_idx, config->output_invert, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -60,7 +64,7 @@ disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config)
|
||||||
bckl_dev->index = config->gpio_num;
|
bckl_dev->index = config->gpio_num;
|
||||||
gpio_pad_select_gpio(config->gpio_num);
|
gpio_pad_select_gpio(config->gpio_num);
|
||||||
ESP_ERROR_CHECK(gpio_set_direction(config->gpio_num, GPIO_MODE_OUTPUT));
|
ESP_ERROR_CHECK(gpio_set_direction(config->gpio_num, GPIO_MODE_OUTPUT));
|
||||||
esp_rom_gpio_connect_out_signal(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert, false);
|
gpio_matrix_out(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (disp_backlight_h)bckl_dev;
|
return (disp_backlight_h)bckl_dev;
|
||||||
|
|
Loading…
Reference in a new issue