Merge pull request #95 from lvgl/feature/esp_lcd_backlight

LCD backlight controller
This commit is contained in:
Tomas Rezucha 2021-08-05 15:34:11 +02:00 committed by GitHub
commit 1801416c13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 284 additions and 545 deletions

View file

@ -3,8 +3,7 @@ if(ESP_PLATFORM)
file(GLOB SOURCES *.c) file(GLOB SOURCES *.c)
set(LVGL_INCLUDE_DIRS . lvgl_tft) set(LVGL_INCLUDE_DIRS . lvgl_tft)
list(APPEND SOURCES "lvgl_tft/disp_driver.c") list(APPEND SOURCES "lvgl_tft/disp_driver.c")
list(APPEND SOURCES "lvgl_tft/esp_lcd_backlight.c")
#@todo add SimleInclude macro here
# Include only the source file of the selected # Include only the source file of the selected
# display controller. # display controller.
@ -79,11 +78,6 @@ if(CONFIG_LV_TOUCH_CONTROLLER)
endif() endif()
endif() endif()
# Add backlight control to compilation only if it is selected in menuconfig
if(CONFIG_LV_ENABLE_BACKLIGHT_CONTROL)
list(APPEND SOURCES "lvgl_tft/esp_lcd_backlight.c")
endif()
if(CONFIG_LV_I2C) if(CONFIG_LV_I2C)
list(APPEND SOURCES "lvgl_i2c/i2c_manager.c") list(APPEND SOURCES "lvgl_i2c/i2c_manager.c")
endif() endif()

View file

@ -7,6 +7,7 @@ For a ready to use ESP32 project take look at the [lv_port_esp32](https://github
- [Supported indev controllers](#supported-indev-controllers) - [Supported indev controllers](#supported-indev-controllers)
- [Support for predefined development kits](#support-for-predefined-development-kits) - [Support for predefined development kits](#support-for-predefined-development-kits)
- [Thread-safe I2C with I2C Manager](#thread-safe-i2c-with-i2c-manager) - [Thread-safe I2C with I2C Manager](#thread-safe-i2c-with-i2c-manager)
- [Backlight control](#backlight-control)
**NOTE:** You need to set the display horizontal and vertical size, color depth and **NOTE:** You need to set the display horizontal and vertical size, color depth and
swap of RGB565 color on the LVGL configuration menuconfig (it's not handled automatically). swap of RGB565 color on the LVGL configuration menuconfig (it's not handled automatically).
@ -79,3 +80,14 @@ talk to devices on the I2C ports without getting in each other's way. These driv
use a built-in copy of I2C Manager to talk to the I2C port, but you can also use use a built-in copy of I2C Manager to talk to the I2C port, but you can also use
the I2C Manager component itself and have others play nice with LVGL and vice-versa. the I2C Manager component itself and have others play nice with LVGL and vice-versa.
[Click here](i2c_manager/README.md) for details. [Click here](i2c_manager/README.md) for details.
## Backlight control
Control of LCD's backlight is provided by separate module that is independent from the display driver.
Configuration of the backlight controller can be found in menuconfig `LVGL ESP Drivers -> LVGL TFT Display controller`.
There are three modes of operation:
1. Off - No backlight control
2. Switch - Allows ON/OFF control
3. PWM - Allows brightness control (by Pulse-Width-Modulated signal)

View file

@ -111,31 +111,14 @@ void GC9A01_init(void)
}; };
#if GC9A01_BCKL == 15
gpio_config_t io_conf;
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = GPIO_SEL_15;
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
gpio_config(&io_conf);
#endif
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
gpio_pad_select_gpio(GC9A01_DC); gpio_pad_select_gpio(GC9A01_DC);
gpio_set_direction(GC9A01_DC, GPIO_MODE_OUTPUT); gpio_set_direction(GC9A01_DC, GPIO_MODE_OUTPUT);
#if GC9A01_USE_RST #if GC9A01_USE_RST
gpio_pad_select_gpio(GC9A01_RST); gpio_pad_select_gpio(GC9A01_RST);
gpio_set_direction(GC9A01_RST, GPIO_MODE_OUTPUT); gpio_set_direction(GC9A01_RST, GPIO_MODE_OUTPUT);
#endif
#if GC9A01_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(GC9A01_BCKL);
gpio_set_direction(GC9A01_BCKL, GPIO_MODE_OUTPUT);
#endif
#if GC9A01_USE_RST
//Reset the display //Reset the display
gpio_set_level(GC9A01_RST, 0); gpio_set_level(GC9A01_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS); vTaskDelay(100 / portTICK_RATE_MS);
@ -156,8 +139,6 @@ void GC9A01_init(void)
cmd++; cmd++;
} }
GC9A01_enable_backlight(true);
GC9A01_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION); GC9A01_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
#if GC9A01_INVERT_COLORS == 1 #if GC9A01_INVERT_COLORS == 1
@ -197,22 +178,6 @@ void GC9A01_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
GC9A01_send_color((void*)color_map, size * 2); GC9A01_send_color((void*)color_map, size * 2);
} }
void GC9A01_enable_backlight(bool backlight)
{
#if GC9A01_ENABLE_BACKLIGHT_CONTROL
ESP_LOGI(TAG, "%s backlight.", backlight ? "Enabling" : "Disabling");
uint32_t tmp = 0;
#if (GC9A01_BCKL_ACTIVE_LVL==1)
tmp = backlight ? 1 : 0;
#else
tmp = backlight ? 0 : 1;
#endif
gpio_set_level(GC9A01_BCKL, tmp);
#endif
}
void GC9A01_sleep_in() void GC9A01_sleep_in()
{ {
uint8_t data[] = {0x08}; uint8_t data[] = {0x08};

View file

@ -25,19 +25,9 @@ extern "C" {
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#define GC9A01_DC CONFIG_LV_DISP_PIN_DC #define GC9A01_DC CONFIG_LV_DISP_PIN_DC
#define GC9A01_RST CONFIG_LV_DISP_PIN_RST #define GC9A01_RST CONFIG_LV_DISP_PIN_RST
#define GC9A01_USE_RST CONFIG_LV_DISP_USE_RST #define GC9A01_USE_RST CONFIG_LV_DISP_USE_RST
#define GC9A01_BCKL CONFIG_LV_DISP_PIN_BCKL
#define GC9A01_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define GC9A01_BCKL_ACTIVE_LVL 1
#else
#define GC9A01_BCKL_ACTIVE_LVL 0
#endif
#define GC9A01_INVERT_COLORS CONFIG_LV_INVERT_COLORS #define GC9A01_INVERT_COLORS CONFIG_LV_INVERT_COLORS
/********************** /**********************
@ -50,7 +40,6 @@ extern "C" {
void GC9A01_init(void); void GC9A01_init(void);
void GC9A01_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map); void GC9A01_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
void GC9A01_enable_backlight(bool backlight);
void GC9A01_sleep_in(void); void GC9A01_sleep_in(void);
void GC9A01_sleep_out(void); void GC9A01_sleep_out(void);

View file

@ -910,51 +910,6 @@ menu "LVGL TFT Display controller"
help help
Configure the display Busy pin here. Configure the display Busy pin here.
config LV_ENABLE_BACKLIGHT_CONTROL
bool "Enable control of the display backlight by using an GPIO." if \
( LV_PREDEFINED_DISPLAY_NONE && ! ( LV_TFT_DISPLAY_CONTROLLER_SH1107 || LV_TFT_DISPLAY_CONTROLLER_SSD1306 ) ) \
|| LV_PREDEFINED_DISPLAY_RPI_MPI3501
default y if LV_PREDEFINED_DISPLAY_M5STACK
default n if LV_PREDEFINED_DISPLAY_M5CORE2
default y if LV_PREDEFINED_DISPLAY_WROVER4
default y if LV_PREDEFINED_DISPLAY_ERTFT0356
default y if LV_PREDEFINED_DISPLAY_TTGO
default y if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
default y if LV_PREDEFINED_DISPLAY_WT32_SC01
help
Enable controlling the display backlight using an GPIO
config LV_BACKLIGHT_ACTIVE_LVL
bool "Is backlight turn on with a HIGH (1) logic level?"
depends on LV_ENABLE_BACKLIGHT_CONTROL
default y if LV_PREDEFINED_DISPLAY_M5STACK
default y if LV_PREDEFINED_DISPLAY_ERTFT0356
default y if LV_PREDEFINED_DISPLAY_TTGO
default y if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
default y if LV_PREDEFINED_DISPLAY_WT32_SC01
help
Some backlights are turned on with a high signal, others held low.
If enabled, a value of 1 will be sent to the display to enable the backlight,
otherwise a 0 will be expected to enable it.
config LV_DISP_PIN_BCKL
int "GPIO for Backlight Control"
depends on LV_ENABLE_BACKLIGHT_CONTROL
default 23 if LV_PREDEFINED_PINS_38V1
default 26 if LV_PREDEFINED_PINS_38V4
default 32 if LV_PREDEFINED_DISPLAY_M5STACK
default 5 if LV_PREDEFINED_DISPLAY_WROVER4
default 2 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
default 27 if LV_PREDEFINED_DISPLAY_ERTFT0356
default 0 if LV_PREDEFINED_PINS_TKOALA
default 4 if LV_PREDEFINED_DISPLAY_TTGO
default 2 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
default 23 if LV_PREDEFINED_DISPLAY_WT32_SC01
default 27
help
Configure the display BCLK (LED) pin here.
endmenu endmenu
choice choice
@ -978,6 +933,73 @@ menu "LVGL TFT Display controller"
endchoice endchoice
choice
prompt "Backlight Control" if \
(! ( 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
bool
prompt "Not Used"
help
Display backlight is not controlled by this driver, must be hardwired in hardware.
config LV_DISP_BACKLIGHT_SWITCH
bool
prompt "Switch control"
help
Display backlight can be switched on or off.
config LV_DISP_BACKLIGHT_PWM
bool
prompt "PWM control"
help
Display backlight is controlled by pulse-width modulation, allowing brightness settings.
endchoice
config LV_BACKLIGHT_ACTIVE_LVL
bool "Is backlight turn on with a HIGH (1) logic level?" if \
( LV_PREDEFINED_DISPLAY_NONE && ! ( LV_TFT_DISPLAY_CONTROLLER_SH1107 || LV_TFT_DISPLAY_CONTROLLER_SSD1306 ) ) \
|| LV_PREDEFINED_DISPLAY_RPI_MPI3501
depends on !LV_DISP_BACKLIGHT_OFF
default y if LV_PREDEFINED_DISPLAY_M5STACK
default y if LV_PREDEFINED_DISPLAY_ERTFT0356
default y if LV_PREDEFINED_DISPLAY_TTGO
default y if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
default y if LV_PREDEFINED_DISPLAY_WT32_SC01
help
Some backlights are turned on with a high signal, others held low.
If enabled, a value of 1 will be sent to the display to enable the backlight,
otherwise a 0 will be expected to enable it.
config LV_DISP_PIN_BCKL
int "GPIO for Backlight Control" if \
( LV_PREDEFINED_DISPLAY_NONE && ! ( LV_TFT_DISPLAY_CONTROLLER_SH1107 || LV_TFT_DISPLAY_CONTROLLER_SSD1306 ) ) \
|| LV_PREDEFINED_DISPLAY_RPI_MPI3501
depends on !LV_DISP_BACKLIGHT_OFF
default 23 if LV_PREDEFINED_PINS_38V1
default 26 if LV_PREDEFINED_PINS_38V4
default 32 if LV_PREDEFINED_DISPLAY_M5STACK
default 5 if LV_PREDEFINED_DISPLAY_WROVER4
default 2 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
default 27 if LV_PREDEFINED_DISPLAY_ERTFT0356
default 0 if LV_PREDEFINED_PINS_TKOALA
default 4 if LV_PREDEFINED_DISPLAY_TTGO
default 2 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
default 23 if LV_PREDEFINED_DISPLAY_WT32_SC01
default 27
help
Configure the display BCLK (LED) pin here.
config LV_I2C config LV_I2C
bool bool
default y if LV_I2C_DISPLAY default y if LV_I2C_DISPLAY

View file

@ -4,8 +4,10 @@
#include "disp_driver.h" #include "disp_driver.h"
#include "disp_spi.h" #include "disp_spi.h"
#include "esp_lcd_backlight.h"
#include "sdkconfig.h"
void disp_driver_init(void) void *disp_driver_init(void)
{ {
#if defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9341 #if defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9341
ili9341_init(); ili9341_init();
@ -42,6 +44,34 @@ void disp_driver_init(void)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9163C #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9163C
ili9163c_init(); ili9163c_init();
#endif #endif
// We still use menuconfig for these settings
// It will be set up during runtime in the future
#ifndef CONFIG_LV_DISP_BACKLIGHT_OFF
const disp_backlight_config_t bckl_config = {
.gpio_num = CONFIG_LV_DISP_PIN_BCKL,
#if defined CONFIG_LV_DISP_BACKLIGHT_PWM
.pwm_control = true,
#else
.pwm_control = false,
#endif
#if defined CONFIG_LV_BACKLIGHT_ACTIVE_LVL
.output_invert = false, // Backlight on high
#else
.output_invert = true, // Backlight on low
#endif
.timer_idx = 0,
.channel_idx = 0 // @todo this prevents us from having two PWM controlled displays
};
const disp_backlight_config_t *bckl_config_p = &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);
return bckl_handle;
} }
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)

View file

@ -67,7 +67,7 @@ extern "C" {
**********************/ **********************/
/* Initialize display */ /* Initialize display */
void disp_driver_init(void); void *disp_driver_init(void);
/* Display flush callback */ /* Display flush callback */
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);

View file

@ -8,51 +8,96 @@
*********************/ *********************/
#include "esp_lcd_backlight.h" #include "esp_lcd_backlight.h"
#include "driver/ledc.h" #include "driver/ledc.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
static const char *TAG = "disp_brightness"; typedef struct {
bool pwm_control; // true: LEDC is used, false: GPIO is used
int index; // Either GPIO or LEDC channel
} disp_backlight_t;
void disp_brightness_control_enable(void) static const char *TAG = "disp_backlight";
disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config)
{ {
/* if (config == NULL)
Configure LED (Backlight) pin as PWM for Brightness control. return NULL;
*/ disp_backlight_t *bckl_dev = calloc(1, sizeof(disp_backlight_t));
ledc_channel_config_t LCD_backlight_channel = { if (bckl_dev == NULL){
.gpio_num = DISP_PIN_BCKL, ESP_LOGW(TAG, "Could not create new LCD backlight instance");
.speed_mode = LEDC_LOW_SPEED_MODE, return NULL;
.channel = LEDC_CHANNEL_0, }
.intr_type = LEDC_INTR_DISABLE,
.timer_sel = LEDC_TIMER_0,
.duty = 0,
.hpoint = 0,
.flags.output_invert = 0
};
ledc_timer_config_t LCD_backlight_timer = {
.speed_mode = LEDC_LOW_SPEED_MODE,
.bit_num = LEDC_TIMER_10_BIT,
.timer_num = LEDC_TIMER_0,
.freq_hz = 5000,
.clk_cfg = LEDC_AUTO_CLK
};
ESP_ERROR_CHECK( ledc_timer_config(&LCD_backlight_timer) ); if (config->pwm_control){
ESP_ERROR_CHECK( ledc_channel_config(&LCD_backlight_channel) ); // Configure LED (Backlight) pin as PWM for Brightness control.
bckl_dev->pwm_control = true;
bckl_dev->index = config->channel_idx;
const ledc_channel_config_t LCD_backlight_channel = {
.gpio_num = config->gpio_num,
.speed_mode = LEDC_LOW_SPEED_MODE,
.channel = config->channel_idx,
.intr_type = LEDC_INTR_DISABLE,
.timer_sel = config->timer_idx,
.duty = 0,
.hpoint = 0
};
const ledc_timer_config_t LCD_backlight_timer = {
.speed_mode = LEDC_LOW_SPEED_MODE,
.bit_num = LEDC_TIMER_10_BIT,
.timer_num = config->timer_idx,
.freq_hz = 5000,
.clk_cfg = LEDC_AUTO_CLK};
ESP_ERROR_CHECK(ledc_timer_config(&LCD_backlight_timer));
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);
}
else
{
// Configure GPIO for output
bckl_dev->index = config->gpio_num;
gpio_pad_select_gpio(config->gpio_num);
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);
}
return (disp_backlight_h)bckl_dev;
} }
void disp_set_brightness(uint16_t brightness) void disp_backlight_set(disp_backlight_h bckl, int brightness_percent)
{ {
/* // Check input paramters
Set brightness. if (bckl == NULL)
0 -> Display off return;
100 -> Full brightness if (brightness_percent > 100)
NOTE: brightness value must be between 0 - 100 brightness_percent = 100;
*/ if (brightness_percent < 0)
if(brightness > 100) brightness_percent = 0;
{
ESP_LOGE(TAG, "Brightness value must be between 0 - 100"); disp_backlight_t *bckl_dev = (disp_backlight_t *) bckl;
return; ESP_LOGI(TAG, "Setting LCD backlight: %d%%", brightness_percent);
}
ESP_ERROR_CHECK( ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, brightness*10) ); if (bckl_dev->pwm_control) {
ESP_ERROR_CHECK( ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0) ); uint32_t duty_cycle = (1023 * brightness_percent) / 100; // LEDC resolution set to 10bits, thus: 100% = 1023
ESP_ERROR_CHECK(ledc_set_duty(LEDC_LOW_SPEED_MODE, bckl_dev->index, duty_cycle));
ESP_ERROR_CHECK(ledc_update_duty(LEDC_LOW_SPEED_MODE, bckl_dev->index));
} else {
ESP_ERROR_CHECK(gpio_set_level(bckl_dev->index, brightness_percent));
}
}
void disp_backlight_delete(disp_backlight_h bckl)
{
if (bckl == NULL)
return;
disp_backlight_t *bckl_dev = (disp_backlight_t *) bckl;
if (bckl_dev->pwm_control) {
ledc_stop(LEDC_LOW_SPEED_MODE, bckl_dev->index, 0);
} else {
gpio_reset_pin(bckl_dev->index);
}
free (bckl);
} }

View file

@ -9,26 +9,56 @@
* INCLUDES * INCLUDES
*********************/ *********************/
#include <stdbool.h> #include <stdbool.h>
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
#ifdef __cplusplus
/********************* extern "C" { /* extern "C" */
* DEFINES
*********************/
#if CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#define DISP_PIN_BCKL CONFIG_LV_DISP_PIN_BCKL
#endif #endif
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
**********************/ **********************/
void disp_brightness_control_enable(void);
void disp_set_brightness(uint16_t brightness);
/**
* @brief Display backlight controller handle
*
*/
typedef void * disp_backlight_h;
/**
* @brief Configuration structure of backlight controller
*
* Must be passed to disp_backlight_new() for correct configuration
*/
typedef struct {
bool pwm_control;
bool output_invert;
int gpio_num; // see gpio_num_t
// Relevant only for PWM controlled backlight
// Ignored for switch (ON/OFF) backlight control
int timer_idx; // ledc_timer_t
int channel_idx; // ledc_channel_t
} disp_backlight_config_t;
/**
* @brief Create new backlight controller
*
* @param[in] config Configuration structure of backlight controller
* @return Display backlight controller handle
*/
disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config);
/**
* @brief Set backlight
*
* Brightness parameter can be 0-100 for PWM controlled backlight.
* GPIO controlled backlight (ON/OFF) is turned off witch value 0 and turned on with any positive value.
*
* @param bckl Backlight controller handle
* @param[in] brightness_percent Brightness in [%]
*/
void disp_backlight_set(disp_backlight_h bckl, int brightness_percent);
void disp_backlight_delete(disp_backlight_h bckl);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View file

@ -160,20 +160,13 @@ static uint8_t displayType = HX8357D;
void hx8357_init(void) void hx8357_init(void)
{ {
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
gpio_pad_select_gpio(HX8357_DC); gpio_pad_select_gpio(HX8357_DC);
gpio_set_direction(HX8357_DC, GPIO_MODE_OUTPUT); gpio_set_direction(HX8357_DC, GPIO_MODE_OUTPUT);
#if HX8357_USE_RST #if HX8357_USE_RST
gpio_pad_select_gpio(HX8357_RST); gpio_pad_select_gpio(HX8357_RST);
gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT); gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT);
#endif
#if HX8357_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(HX8357_BCKL);
gpio_set_direction(HX8357_BCKL, GPIO_MODE_OUTPUT);
#endif
#if HX8357_USE_RST
//Reset the display //Reset the display
gpio_set_level(HX8357_RST, 0); gpio_set_level(HX8357_RST, 0);
vTaskDelay(10 / portTICK_RATE_MS); vTaskDelay(10 / portTICK_RATE_MS);
@ -210,8 +203,6 @@ void hx8357_init(void)
#else #else
hx8357_send_cmd(HX8357_INVOFF); hx8357_send_cmd(HX8357_INVOFF);
#endif #endif
hx8357_enable_backlight(true);
} }
@ -248,23 +239,6 @@ void hx8357_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
hx8357_send_color((void*)color_map, size * 2); hx8357_send_color((void*)color_map, size * 2);
} }
void hx8357_enable_backlight(bool backlight)
{
#if HX8357_ENABLE_BACKLIGHT_CONTROL
ESP_LOGD(TAG, "%s backlight.\n", backlight ? "Enabling" : "Disabling");
uint32_t tmp = 0;
#if (HX8357_BCKL_ACTIVE_LVL==1)
tmp = backlight ? 1 : 0;
#else
tmp = backlight ? 0 : 1;
#endif
gpio_set_level(HX8357_BCKL, tmp);
#endif
}
void hx8357_set_rotation(uint8_t r) void hx8357_set_rotation(uint8_t r)
{ {
r = r & 3; // can't be higher than 3 r = r & 3; // can't be higher than 3

View file

@ -35,19 +35,10 @@ extern "C" {
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#define HX8357_DC CONFIG_LV_DISP_PIN_DC #define HX8357_DC CONFIG_LV_DISP_PIN_DC
#define HX8357_RST CONFIG_LV_DISP_PIN_RST #define HX8357_RST CONFIG_LV_DISP_PIN_RST
#define HX8357_USE_RST CONFIG_LV_DISP_USE_RST #define HX8357_USE_RST CONFIG_LV_DISP_USE_RST
#define HX8357_BCKL CONFIG_LV_DISP_PIN_BCKL #define HX8357_INVERT_COLORS CONFIG_LV_INVERT_COLORS
#define HX8357_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#define HX8357_INVERT_COLORS CONFIG_LV_INVERT_COLORS
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define HX8357_BCKL_ACTIVE_LVL 1
#else
#define HX8357_BCKL_ACTIVE_LVL 0
#endif
/******************* /*******************
@ -136,7 +127,6 @@ extern "C" {
void hx8357_init(void); void hx8357_init(void);
void hx8357_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map); void hx8357_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
void hx8357_enable_backlight(bool backlight);
void hx8357_set_rotation(uint8_t r); void hx8357_set_rotation(uint8_t r);
/********************** /**********************

View file

@ -199,15 +199,13 @@ void il3820_init(void)
gpio_pad_select_gpio(IL3820_DC_PIN); gpio_pad_select_gpio(IL3820_DC_PIN);
gpio_set_direction(IL3820_DC_PIN, GPIO_MODE_OUTPUT); gpio_set_direction(IL3820_DC_PIN, GPIO_MODE_OUTPUT);
#if IL3820_USE_RST
gpio_pad_select_gpio(IL3820_RST_PIN);
gpio_set_direction(IL3820_RST_PIN, GPIO_MODE_OUTPUT);
#endif
gpio_pad_select_gpio(IL3820_BUSY_PIN); gpio_pad_select_gpio(IL3820_BUSY_PIN);
gpio_set_direction(IL3820_BUSY_PIN, GPIO_MODE_INPUT); gpio_set_direction(IL3820_BUSY_PIN, GPIO_MODE_INPUT);
#if IL3820_USE_RST #if IL3820_USE_RST
gpio_pad_select_gpio(IL3820_RST_PIN);
gpio_set_direction(IL3820_RST_PIN, GPIO_MODE_OUTPUT);
/* Harware reset */ /* Harware reset */
gpio_set_level( IL3820_RST_PIN, 0); gpio_set_level( IL3820_RST_PIN, 0);
vTaskDelay(IL3820_RESET_DELAY / portTICK_RATE_MS); vTaskDelay(IL3820_RESET_DELAY / portTICK_RATE_MS);

View file

@ -143,10 +143,6 @@ void ili9163c_init(void)
gpio_pad_select_gpio(ILI9163C_RST); gpio_pad_select_gpio(ILI9163C_RST);
gpio_set_direction(ILI9163C_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9163C_RST, GPIO_MODE_OUTPUT);
#if ILI9163C_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(ILI9163C_BCKL);
gpio_set_direction(ILI9163C_BCKL, GPIO_MODE_OUTPUT);
#endif
//Reset the display //Reset the display
gpio_set_level(ILI9163C_RST, 0); gpio_set_level(ILI9163C_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS); vTaskDelay(100 / portTICK_RATE_MS);
@ -166,8 +162,6 @@ void ili9163c_init(void)
cmd++; cmd++;
} }
ili9163c_enable_backlight(true);
ili9163c_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION); ili9163c_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
} }
@ -199,22 +193,6 @@ void ili9163c_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color
ili9163c_send_color((void *)color_map, size * 2); ili9163c_send_color((void *)color_map, size * 2);
} }
void ili9163c_enable_backlight(bool backlight)
{
#if ILI9163C_ENABLE_BACKLIGHT_CONTROL
ESP_LOGD(TAG, "%s backlight.", backlight ? "Enabling" : "Disabling");
uint32_t tmp = 0;
#if (ILI9163C_BCKL_ACTIVE_LVL == 1)
tmp = backlight ? 1 : 0;
#else
tmp = backlight ? 0 : 1;
#endif
gpio_set_level(ILI9163C_BCKL, tmp);
#endif
}
void ili9163c_sleep_in() void ili9163c_sleep_in()
{ {
uint8_t data[] = {0x08}; uint8_t data[] = {0x08};

View file

@ -26,35 +26,24 @@ extern "C"
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#define ILI9163C_DC CONFIG_LV_DISP_PIN_DC #define ILI9163C_DC CONFIG_LV_DISP_PIN_DC
#define ILI9163C_RST CONFIG_LV_DISP_PIN_RST #define ILI9163C_RST CONFIG_LV_DISP_PIN_RST
#define ILI9163C_BCKL CONFIG_LV_DISP_PIN_BCKL
#define ILI9163C_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define ILI9163C_BCKL_ACTIVE_LVL 1
#else
#define ILI9163C_BCKL_ACTIVE_LVL 0
#endif
#define ILI9163C_INVERT_COLORS CONFIG_LV_INVERT_COLORS #define ILI9163C_INVERT_COLORS CONFIG_LV_INVERT_COLORS
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
**********************/ **********************/
void ili9163c_init(void); void ili9163c_init(void);
void ili9163c_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map); void ili9163c_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map);
void ili9163c_enable_backlight(bool backlight); void ili9163c_sleep_in(void);
void ili9163c_sleep_in(void); void ili9163c_sleep_out(void);
void ili9163c_sleep_out(void);
/********************** /**********************
* MACROS * MACROS
**********************/ **********************/

View file

@ -80,30 +80,14 @@ void ili9341_init(void)
{0, {0}, 0xff}, {0, {0}, 0xff},
}; };
#if ILI9341_BCKL == 15
gpio_config_t io_conf;
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = GPIO_SEL_15;
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
gpio_config(&io_conf);
#endif
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
gpio_pad_select_gpio(ILI9341_DC); gpio_pad_select_gpio(ILI9341_DC);
gpio_set_direction(ILI9341_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9341_DC, GPIO_MODE_OUTPUT);
#if ILI9341_USE_RST #if ILI9341_USE_RST
gpio_pad_select_gpio(ILI9341_RST); gpio_pad_select_gpio(ILI9341_RST);
gpio_set_direction(ILI9341_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9341_RST, GPIO_MODE_OUTPUT);
#endif
#if ILI9341_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(ILI9341_BCKL);
gpio_set_direction(ILI9341_BCKL, GPIO_MODE_OUTPUT);
#endif
#if ILI9341_USE_RST
//Reset the display //Reset the display
gpio_set_level(ILI9341_RST, 0); gpio_set_level(ILI9341_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS); vTaskDelay(100 / portTICK_RATE_MS);
@ -124,9 +108,7 @@ void ili9341_init(void)
cmd++; cmd++;
} }
ili9341_enable_backlight(true); ili9341_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
ili9341_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
#if ILI9341_INVERT_COLORS == 1 #if ILI9341_INVERT_COLORS == 1
ili9341_send_cmd(0x21); ili9341_send_cmd(0x21);
@ -158,29 +140,10 @@ void ili9341_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
/*Memory write*/ /*Memory write*/
ili9341_send_cmd(0x2C); ili9341_send_cmd(0x2C);
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area); uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
ili9341_send_color((void*)color_map, size * 2); ili9341_send_color((void*)color_map, size * 2);
} }
void ili9341_enable_backlight(bool backlight)
{
#if ILI9341_ENABLE_BACKLIGHT_CONTROL
ESP_LOGI(TAG, "%s backlight.", backlight ? "Enabling" : "Disabling");
uint32_t tmp = 0;
#if (ILI9341_BCKL_ACTIVE_LVL==1)
tmp = backlight ? 1 : 0;
#else
tmp = backlight ? 0 : 1;
#endif
gpio_set_level(ILI9341_BCKL, tmp);
#endif
}
void ili9341_sleep_in() void ili9341_sleep_in()
{ {
uint8_t data[] = {0x08}; uint8_t data[] = {0x08};

View file

@ -29,16 +29,6 @@ extern "C" {
#define ILI9341_DC CONFIG_LV_DISP_PIN_DC #define ILI9341_DC CONFIG_LV_DISP_PIN_DC
#define ILI9341_USE_RST CONFIG_LV_DISP_USE_RST #define ILI9341_USE_RST CONFIG_LV_DISP_USE_RST
#define ILI9341_RST CONFIG_LV_DISP_PIN_RST #define ILI9341_RST CONFIG_LV_DISP_PIN_RST
#define ILI9341_BCKL CONFIG_LV_DISP_PIN_BCKL
#define ILI9341_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define ILI9341_BCKL_ACTIVE_LVL 1
#else
#define ILI9341_BCKL_ACTIVE_LVL 0
#endif
#define ILI9341_INVERT_COLORS CONFIG_LV_INVERT_COLORS #define ILI9341_INVERT_COLORS CONFIG_LV_INVERT_COLORS
/********************** /**********************
@ -51,7 +41,6 @@ extern "C" {
void ili9341_init(void); void ili9341_init(void);
void ili9341_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map); void ili9341_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
void ili9341_enable_backlight(bool backlight);
void ili9341_sleep_in(void); void ili9341_sleep_in(void);
void ili9341_sleep_out(void); void ili9341_sleep_out(void);

View file

@ -80,14 +80,7 @@ void ili9481_init(void)
#if ILI9481_USE_RST #if ILI9481_USE_RST
gpio_pad_select_gpio(ILI9481_RST); gpio_pad_select_gpio(ILI9481_RST);
gpio_set_direction(ILI9481_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9481_RST, GPIO_MODE_OUTPUT);
#endif
#if ILI9481_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(ILI9481_BCKL);
gpio_set_direction(ILI9481_BCKL, GPIO_MODE_OUTPUT);
#endif
#if ILI9481_USE_RST
//Reset the display //Reset the display
gpio_set_level(ILI9481_RST, 0); gpio_set_level(ILI9481_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS); vTaskDelay(100 / portTICK_RATE_MS);
@ -112,8 +105,6 @@ void ili9481_init(void)
cmd++; cmd++;
} }
ili9481_enable_backlight(true);
ili9481_set_orientation(ILI9481_DISPLAY_ORIENTATION); ili9481_set_orientation(ILI9481_DISPLAY_ORIENTATION);
} }
@ -173,22 +164,6 @@ void ili9481_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
heap_caps_free(mybuf); heap_caps_free(mybuf);
} }
void ili9481_enable_backlight(bool backlight)
{
#if ILI9481_ENABLE_BACKLIGHT_CONTROL
ESP_LOGI(TAG, "%s backlight.", backlight ? "Enabling" : "Disabling");
uint32_t tmp = 0;
#if (ILI9481_BCKL_ACTIVE_LVL==1)
tmp = backlight ? 1 : 0;
#else
tmp = backlight ? 0 : 1;
#endif
gpio_set_level(ILI9481_BCKL, tmp);
#endif
}
/********************** /**********************
* STATIC FUNCTIONS * STATIC FUNCTIONS
**********************/ **********************/

View file

@ -25,20 +25,12 @@ extern "C" {
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#define ILI9481_DC CONFIG_LV_DISP_PIN_DC #define ILI9481_DC CONFIG_LV_DISP_PIN_DC
#define ILI9481_RST CONFIG_LV_DISP_PIN_RST #define ILI9481_RST CONFIG_LV_DISP_PIN_RST
#define ILI9481_USE_RST CONFIG_LV_DISP_USE_RST #define ILI9481_USE_RST CONFIG_LV_DISP_USE_RST
#define ILI9481_BCKL CONFIG_LV_DISP_PIN_BCKL #define ILI9481_INVERT_COLORS CONFIG_LV_INVERT_COLORS
#define ILI9481_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#define ILI9481_INVERT_COLORS CONFIG_LV_INVERT_COLORS
#define ILI9481_DISPLAY_ORIENTATION CONFIG_LV_DISPLAY_ORIENTATION #define ILI9481_DISPLAY_ORIENTATION CONFIG_LV_DISPLAY_ORIENTATION
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define ILI9481_BCKL_ACTIVE_LVL 1
#else
#define ILI9481_BCKL_ACTIVE_LVL 0
#endif
/******************* /*******************
* ILI9481 REGS * ILI9481 REGS
@ -118,7 +110,6 @@ extern "C" {
void ili9481_init(void); void ili9481_init(void);
void ili9481_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map); void ili9481_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
void ili9481_enable_backlight(bool backlight);
/********************** /**********************
* MACROS * MACROS

View file

@ -65,31 +65,14 @@ void ili9486_init(void)
{0x00, {0}, 0xff}, {0x00, {0}, 0xff},
}; };
#if ILI9486_BCKL == 15
gpio_config_t io_conf;
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = GPIO_SEL_15;
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
gpio_config(&io_conf);
#endif
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
gpio_pad_select_gpio(ILI9486_DC); gpio_pad_select_gpio(ILI9486_DC);
gpio_set_direction(ILI9486_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9486_DC, GPIO_MODE_OUTPUT);
#if ILI9486_USE_RST #if ILI9486_USE_RST
gpio_pad_select_gpio(ILI9486_RST); gpio_pad_select_gpio(ILI9486_RST);
gpio_set_direction(ILI9486_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9486_RST, GPIO_MODE_OUTPUT);
#endif
#if ILI9486_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(ILI9486_BCKL);
gpio_set_direction(ILI9486_BCKL, GPIO_MODE_OUTPUT);
#endif
#if ILI9486_USE_RST
//Reset the display //Reset the display
gpio_set_level(ILI9486_RST, 0); gpio_set_level(ILI9486_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS); vTaskDelay(100 / portTICK_RATE_MS);
@ -110,9 +93,7 @@ void ili9486_init(void)
cmd++; cmd++;
} }
ili9486_enable_backlight(true); ili9486_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
ili9486_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
} }
void ili9486_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map) void ili9486_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
@ -144,22 +125,6 @@ void ili9486_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
ili9486_send_color((void*) color_map, size * 2); ili9486_send_color((void*) color_map, size * 2);
} }
void ili9486_enable_backlight(bool backlight)
{
#if ILI9486_ENABLE_BACKLIGHT_CONTROL
ESP_LOGI(TAG, "%s backlight.", backlight ? "Enabling" : "Disabling");
uint32_t tmp = 0;
#if (ILI9486_BCKL_ACTIVE_LVL==1)
tmp = backlight ? 1 : 0;
#else
tmp = backlight ? 0 : 1;
#endif
gpio_set_level(ILI9486_BCKL, tmp);
#endif
}
/********************** /**********************
* STATIC FUNCTIONS * STATIC FUNCTIONS
**********************/ **********************/

View file

@ -28,15 +28,7 @@ extern "C" {
#define ILI9486_DC CONFIG_LV_DISP_PIN_DC #define ILI9486_DC CONFIG_LV_DISP_PIN_DC
#define ILI9486_RST CONFIG_LV_DISP_PIN_RST #define ILI9486_RST CONFIG_LV_DISP_PIN_RST
#define ILI9486_USE_RST CONFIG_LV_DISP_USE_RST #define ILI9486_USE_RST CONFIG_LV_DISP_USE_RST
#define ILI9486_BCKL CONFIG_LV_DISP_PIN_BCKL
#define ILI9486_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define ILI9486_BCKL_ACTIVE_LVL 1
#else
#define ILI9486_BCKL_ACTIVE_LVL 0
#endif
/********************** /**********************
* TYPEDEFS * TYPEDEFS
@ -48,7 +40,6 @@ extern "C" {
void ili9486_init(void); void ili9486_init(void);
void ili9486_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map); void ili9486_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
void ili9486_enable_backlight(bool backlight);
/********************** /**********************
* MACROS * MACROS

View file

@ -76,20 +76,13 @@ void ili9488_init(void)
}; };
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
gpio_pad_select_gpio(ILI9488_DC); gpio_pad_select_gpio(ILI9488_DC);
gpio_set_direction(ILI9488_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9488_DC, GPIO_MODE_OUTPUT);
#if ILI9488_USE_RST #if ILI9488_USE_RST
gpio_pad_select_gpio(ILI9488_RST); gpio_pad_select_gpio(ILI9488_RST);
gpio_set_direction(ILI9488_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9488_RST, GPIO_MODE_OUTPUT);
#endif
#if ILI9488_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(ILI9488_BCKL);
gpio_set_direction(ILI9488_BCKL, GPIO_MODE_OUTPUT);
#endif
#if ILI9488_USE_RST
//Reset the display //Reset the display
gpio_set_level(ILI9488_RST, 0); gpio_set_level(ILI9488_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS); vTaskDelay(100 / portTICK_RATE_MS);
@ -114,9 +107,7 @@ void ili9488_init(void)
cmd++; cmd++;
} }
ili9488_enable_backlight(true); ili9488_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
ili9488_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
} }
// Flush function based on mvturnho repo // Flush function based on mvturnho repo
@ -175,22 +166,6 @@ void ili9488_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
heap_caps_free(mybuf); heap_caps_free(mybuf);
} }
void ili9488_enable_backlight(bool backlight)
{
#if ILI9488_ENABLE_BACKLIGHT_CONTROL
ESP_LOGI(TAG, "%s backlight.", backlight ? "Enabling" : "Disabling");
uint32_t tmp = 0;
#if (ILI9488_BCKL_ACTIVE_LVL==1)
tmp = backlight ? 1 : 0;
#else
tmp = backlight ? 0 : 1;
#endif
gpio_set_level(ILI9488_BCKL, tmp);
#endif
}
/********************** /**********************
* STATIC FUNCTIONS * STATIC FUNCTIONS
**********************/ **********************/

View file

@ -27,16 +27,7 @@ extern "C" {
*********************/ *********************/
#define ILI9488_DC CONFIG_LV_DISP_PIN_DC #define ILI9488_DC CONFIG_LV_DISP_PIN_DC
#define ILI9488_RST CONFIG_LV_DISP_PIN_RST #define ILI9488_RST CONFIG_LV_DISP_PIN_RST
#define ILI9488_USE_RST CONFIG_LV_DISP_USE_RST #define ILI9488_USE_RST CONFIG_LV_DISP_USE_RSTS
#define ILI9488_BCKL CONFIG_LV_DISP_PIN_BCKL
#define ILI9488_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define ILI9488_BCKL_ACTIVE_LVL 1
#else
#define ILI9488_BCKL_ACTIVE_LVL 0
#endif
/******************* /*******************
* ILI9488 REGS * ILI9488 REGS
@ -155,7 +146,6 @@ typedef struct {
void ili9488_init(void); void ili9488_init(void);
void ili9488_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map); void ili9488_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
void ili9488_enable_backlight(bool backlight);
/********************** /**********************
* MACROS * MACROS

View file

@ -148,29 +148,12 @@ void ra8875_init(void)
ESP_LOGI(TAG, "Initializing RA8875..."); ESP_LOGI(TAG, "Initializing RA8875...");
#if (CONFIG_LV_DISP_PIN_BCKL == 15)
gpio_config_t io_conf;
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = GPIO_SEL_15;
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
gpio_config(&io_conf);
#endif
// Initialize non-SPI GPIOs // Initialize non-SPI GPIOs
#if RA8875_USE_RST #if RA8875_USE_RST
gpio_pad_select_gpio(RA8875_RST); gpio_pad_select_gpio(RA8875_RST);
gpio_set_direction(RA8875_RST, GPIO_MODE_OUTPUT); gpio_set_direction(RA8875_RST, GPIO_MODE_OUTPUT);
#endif
#ifdef CONFIG_LV_DISP_PIN_BCKL
gpio_pad_select_gpio(CONFIG_LV_DISP_PIN_BCKL);
gpio_set_direction(CONFIG_LV_DISP_PIN_BCKL, GPIO_MODE_OUTPUT);
#endif
#if RA8875_USE_RST
// Reset the RA8875 // Reset the RA8875
gpio_set_level(RA8875_RST, 0); gpio_set_level(RA8875_RST, 0);
vTaskDelay(DIV_ROUND_UP(100, portTICK_RATE_MS)); vTaskDelay(DIV_ROUND_UP(100, portTICK_RATE_MS));
@ -200,28 +183,8 @@ void ra8875_init(void)
ESP_LOGW(TAG, "WARNING: Memory clear timed out; RA8875 may be unresponsive."); ESP_LOGW(TAG, "WARNING: Memory clear timed out; RA8875 may be unresponsive.");
} }
// Enable the display and backlight // Enable the display
ra8875_enable_display(true); ra8875_enable_display(true);
ra8875_enable_backlight(true);
}
void ra8875_enable_backlight(bool backlight)
{
#if CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
ESP_LOGI(TAG, "%s backlight.", backlight ? "Enabling" : "Disabling");
uint32_t tmp = 0;
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
tmp = backlight ? 1 : 0;
#else
tmp = backlight ? 0 : 1;
#endif
#ifdef CONFIG_LV_DISP_PIN_BCKL
gpio_set_level(CONFIG_LV_DISP_PIN_BCKL, tmp);
#endif
#endif
} }
void ra8875_enable_display(bool enable) void ra8875_enable_display(bool enable)

View file

@ -97,7 +97,6 @@ extern "C" {
**********************/ **********************/
void ra8875_init(void); void ra8875_init(void);
void ra8875_enable_backlight(bool backlight);
void ra8875_enable_display(bool enable); void ra8875_enable_display(bool enable);
void ra8875_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map); void ra8875_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);

View file

@ -131,7 +131,6 @@ extern "C" {
void st7735s_init(void); void st7735s_init(void);
void st7735s_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map); void st7735s_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
void st7735s_enable_backlight(bool backlight);
void st7735s_sleep_in(void); void st7735s_sleep_in(void);
void st7735s_sleep_out(void); void st7735s_sleep_out(void);

View file

@ -94,11 +94,6 @@ void st7789_init(void)
gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT);
#endif #endif
#if ST7789_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(ST7789_BCKL);
gpio_set_direction(ST7789_BCKL, GPIO_MODE_OUTPUT);
#endif
//Reset the display //Reset the display
#if !defined(ST7789_SOFT_RST) #if !defined(ST7789_SOFT_RST)
gpio_set_level(ST7789_RST, 0); gpio_set_level(ST7789_RST, 0);
@ -122,27 +117,9 @@ void st7789_init(void)
cmd++; cmd++;
} }
st7789_enable_backlight(true);
st7789_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION); st7789_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
} }
void st7789_enable_backlight(bool backlight)
{
#if ST7789_ENABLE_BACKLIGHT_CONTROL
printf("%s backlight.\n", backlight ? "Enabling" : "Disabling");
uint32_t tmp = 0;
#if (ST7789_BCKL_ACTIVE_LVL==1)
tmp = backlight ? 1 : 0;
#else
tmp = backlight ? 0 : 1;
#endif
gpio_set_level(ST7789_BCKL, tmp);
#endif
}
/* The ST7789 display controller can drive 320*240 displays, when using a 240*240 /* The ST7789 display controller can drive 320*240 displays, when using a 240*240
* display there's a gap of 80px, we need to edit the coordinates to take into * display there's a gap of 80px, we need to edit the coordinates to take into
* account that gap, this is not necessary in all orientations. */ * account that gap, this is not necessary in all orientations. */

View file

@ -23,7 +23,6 @@ extern "C"
#define ST7789_DC CONFIG_LV_DISP_PIN_DC #define ST7789_DC CONFIG_LV_DISP_PIN_DC
#define ST7789_RST CONFIG_LV_DISP_PIN_RST #define ST7789_RST CONFIG_LV_DISP_PIN_RST
#define ST7789_BCKL CONFIG_LV_DISP_PIN_BCKL
#if CONFIG_LV_DISP_USE_RST #if CONFIG_LV_DISP_USE_RST
#if CONFIG_LV_DISP_ST7789_SOFT_RESET #if CONFIG_LV_DISP_ST7789_SOFT_RESET
@ -33,16 +32,8 @@ extern "C"
#define ST7789_SOFT_RST #define ST7789_SOFT_RST
#endif #endif
#define ST7789_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#define ST7789_INVERT_COLORS CONFIG_LV_INVERT_COLORS #define ST7789_INVERT_COLORS CONFIG_LV_INVERT_COLORS
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define ST7789_BCKL_ACTIVE_LVL 1
#else
#define ST7789_BCKL_ACTIVE_LVL 0
#endif
/* ST7789 commands */ /* ST7789 commands */
#define ST7789_NOP 0x00 #define ST7789_NOP 0x00
#define ST7789_SWRESET 0x01 #define ST7789_SWRESET 0x01
@ -121,7 +112,6 @@ extern "C"
void st7789_init(void); void st7789_init(void);
void st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map); void st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map);
void st7789_enable_backlight(bool backlight);
void st7789_send_cmd(uint8_t cmd); void st7789_send_cmd(uint8_t cmd);
void st7789_send_data(void *data, uint16_t length); void st7789_send_data(void *data, uint16_t length);

View file

@ -81,16 +81,6 @@ void st7796s_init(void)
{0, {0}, 0xff}, {0, {0}, 0xff},
}; };
#if ST7796S_BCKL == 15
gpio_config_t io_conf;
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = GPIO_SEL_15;
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
gpio_config(&io_conf);
#endif
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
gpio_pad_select_gpio(ST7796S_DC); gpio_pad_select_gpio(ST7796S_DC);
gpio_set_direction(ST7796S_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ST7796S_DC, GPIO_MODE_OUTPUT);
@ -98,14 +88,7 @@ void st7796s_init(void)
#if ST7796S_USE_RST #if ST7796S_USE_RST
gpio_pad_select_gpio(ST7796S_RST); gpio_pad_select_gpio(ST7796S_RST);
gpio_set_direction(ST7796S_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ST7796S_RST, GPIO_MODE_OUTPUT);
#endif
#if ST7796S_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(ST7796S_BCKL);
gpio_set_direction(ST7796S_BCKL, GPIO_MODE_OUTPUT);
#endif
#if ST7796S_USE_RST
//Reset the display //Reset the display
gpio_set_level(ST7796S_RST, 0); gpio_set_level(ST7796S_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS); vTaskDelay(100 / portTICK_RATE_MS);
@ -128,8 +111,6 @@ void st7796s_init(void)
cmd++; cmd++;
} }
st7796s_enable_backlight(true);
st7796s_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION); st7796s_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
#if ST7796S_INVERT_COLORS == 1 #if ST7796S_INVERT_COLORS == 1
@ -167,22 +148,6 @@ void st7796s_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_
st7796s_send_color((void *)color_map, size * 2); st7796s_send_color((void *)color_map, size * 2);
} }
void st7796s_enable_backlight(bool backlight)
{
#if ST7796S_ENABLE_BACKLIGHT_CONTROL
ESP_LOGI(TAG, "%s backlight.", backlight ? "Enabling" : "Disabling");
uint32_t tmp = 0;
#if (ST7796S_BCKL_ACTIVE_LVL == 1)
tmp = backlight ? 1 : 0;
#else
tmp = backlight ? 0 : 1;
#endif
gpio_set_level(ST7796S_BCKL, tmp);
#endif
}
void st7796s_sleep_in() void st7796s_sleep_in()
{ {
uint8_t data[] = {0x08}; uint8_t data[] = {0x08};

View file

@ -26,20 +26,12 @@ extern "C"
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#define ST7796S_DC CONFIG_LV_DISP_PIN_DC #define ST7796S_DC CONFIG_LV_DISP_PIN_DC
#define ST7796S_RST CONFIG_LV_DISP_PIN_RST #define ST7796S_RST CONFIG_LV_DISP_PIN_RST
#define ST7796S_USE_RST CONFIG_LV_DISP_USE_RST #define ST7796S_USE_RST CONFIG_LV_DISP_USE_RST
#define ST7796S_BCKL CONFIG_LV_DISP_PIN_BCKL #define ST7796S_INVERT_COLORS CONFIG_LV_INVERT_COLORS
#define ST7796S_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#define ST7796S_INVERT_COLORS CONFIG_LV_INVERT_COLORS
#define ST7796S_DISPLAY_ORIENTATION CONFIG_LV_DISPLAY_ORIENTATION #define ST7796S_DISPLAY_ORIENTATION CONFIG_LV_DISPLAY_ORIENTATION
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define ST7796S_BCKL_ACTIVE_LVL 1
#else
#define ST7796S_BCKL_ACTIVE_LVL 0
#endif
/******************* /*******************
* ST7796S REGS * ST7796S REGS
@ -119,7 +111,6 @@ extern "C"
void st7796s_init(void); void st7796s_init(void);
void st7796s_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map); void st7796s_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map);
void st7796s_enable_backlight(bool backlight);
/********************** /**********************
* MACROS * MACROS