Merge pull request #14 from lvgl/feature/add_st7796s

Feature/add st7796s
This commit is contained in:
Carlos Diaz 2021-01-15 00:07:39 -06:00 committed by GitHub
commit 1c886d238c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 414 additions and 3 deletions

View file

@ -25,6 +25,8 @@ extern "C" {
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40) #define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40) #define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7796S
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40) #define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SH1107 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SH1107

View file

@ -16,6 +16,8 @@ elseif(CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789)
list(APPEND SOURCES "st7789.c") list(APPEND SOURCES "st7789.c")
elseif(CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S) elseif(CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S)
list(APPEND SOURCES "st7735s.c") list(APPEND SOURCES "st7735s.c")
elseif(CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7796S)
list(APPEND SOURCES "st7796s.c")
elseif(CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357) elseif(CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357)
list(APPEND SOURCES "hx8357.c") list(APPEND SOURCES "hx8357.c")
elseif(CONFIG_LV_TFT_DISPLAY_CONTROLLER_SH1107) elseif(CONFIG_LV_TFT_DISPLAY_CONTROLLER_SH1107)

View file

@ -68,6 +68,10 @@ menu "LVGL TFT Display controller"
bool "TTGO Camera Plus" bool "TTGO Camera Plus"
select LV_TFT_DISPLAY_CONTROLLER_ST7789 select LV_TFT_DISPLAY_CONTROLLER_ST7789
select LV_TFT_DISPLAY_PROTOCOL_SPI select LV_TFT_DISPLAY_PROTOCOL_SPI
config LV_PREDEFINED_DISPLAY_WT32_SC01
bool "Wireless Tag WT32-SC01"
select LV_TFT_DISPLAY_CONTROLLER_ST7796S
select LV_TFT_DISPLAY_PROTOCOL_SPI
endchoice endchoice
# START of helper symbols. # START of helper symbols.
@ -156,6 +160,11 @@ menu "LVGL TFT Display controller"
help help
RA8875 display controller. RA8875 display controller.
config LV_TFT_DISPLAY_CONTROLLER_ST7796S
bool
help
ST7796S display controller.
# Display controller communication protocol # Display controller communication protocol
# #
# This symbols define the communication protocol used by the # This symbols define the communication protocol used by the
@ -185,7 +194,7 @@ menu "LVGL TFT Display controller"
config DISPLAY_ORIENTATION_LANDSCAPE config DISPLAY_ORIENTATION_LANDSCAPE
bool "Landscape" bool "Landscape"
config DISPLAY_ORIENTATION_LANDSCAPE_INVERTED config DISPLAY_ORIENTATION_LANDSCAPE_INVERTED
bool "Landscaoe inverted" bool "Landscape inverted"
endchoice endchoice
config LV_DISPLAY_ORIENTATION config LV_DISPLAY_ORIENTATION
@ -268,6 +277,10 @@ menu "LVGL TFT Display controller"
bool "ST7789" bool "ST7789"
select LV_TFT_DISPLAY_CONTROLLER_ST7789 select LV_TFT_DISPLAY_CONTROLLER_ST7789
select LV_TFT_DISPLAY_PROTOCOL_SPI select LV_TFT_DISPLAY_PROTOCOL_SPI
config LV_TFT_DISPLAY_USER_CONTROLLER_ST7796S
bool "ST7796S"
select LV_TFT_DISPLAY_CONTROLLER_ST7796S
select LV_TFT_DISPLAY_PROTOCOL_SPI
config LV_TFT_DISPLAY_USER_CONTROLLER_GC9A01 config LV_TFT_DISPLAY_USER_CONTROLLER_GC9A01
bool "GC9A01" bool "GC9A01"
select LV_TFT_DISPLAY_CONTROLLER_GC9A01 select LV_TFT_DISPLAY_CONTROLLER_GC9A01
@ -486,6 +499,7 @@ menu "LVGL TFT Display controller"
prompt "Select a custom frequency." prompt "Select a custom frequency."
depends on LV_TFT_USE_CUSTOM_SPI_CLK_DIVIDER depends on LV_TFT_USE_CUSTOM_SPI_CLK_DIVIDER
default LV_TFT_SPI_CLK_DIVIDER_4 if LV_TFT_DISPLAY_CONTROLLER_ST7789 ||LV_TFT_DISPLAY_CONTROLLER_GC9A01 || LV_TFT_DISPLAY_CONTROLLER_ILI9486 default LV_TFT_SPI_CLK_DIVIDER_4 if LV_TFT_DISPLAY_CONTROLLER_ST7789 ||LV_TFT_DISPLAY_CONTROLLER_GC9A01 || LV_TFT_DISPLAY_CONTROLLER_ILI9486
default LV_TFT_SPI_CLK_DIVIDER_2 if LV_TFT_DISPLAY_CONTROLLER_ST7796S
default LV_TFT_SPI_CLK_DIVIDER_5 if LV_TFT_DISPLAY_CONTROLLER_ILI9481 default LV_TFT_SPI_CLK_DIVIDER_5 if LV_TFT_DISPLAY_CONTROLLER_ILI9481
default LV_TFT_SPI_CLK_DIVIDER_3 if LV_TFT_DISPLAY_CONTROLLER_HX8357 default LV_TFT_SPI_CLK_DIVIDER_3 if LV_TFT_DISPLAY_CONTROLLER_HX8357
default LV_TFT_SPI_CLK_DIVIDER_10 if LV_TFT_DISPLAY_CONTROLLER_SH1107 default LV_TFT_SPI_CLK_DIVIDER_10 if LV_TFT_DISPLAY_CONTROLLER_SH1107
@ -723,6 +737,7 @@ menu "LVGL TFT Display controller"
default 23 if LV_PREDEFINED_PINS_TKOALA default 23 if LV_PREDEFINED_PINS_TKOALA
default 19 if LV_PREDEFINED_DISPLAY_TTGO default 19 if LV_PREDEFINED_DISPLAY_TTGO
default 19 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS default 19 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
default 13 if LV_PREDEFINED_DISPLAY_WT32_SC01
default 13 default 13
help help
@ -783,6 +798,7 @@ menu "LVGL TFT Display controller"
default 18 if LV_PREDEFINED_PINS_TKOALA default 18 if LV_PREDEFINED_PINS_TKOALA
default 18 if LV_PREDEFINED_DISPLAY_TTGO default 18 if LV_PREDEFINED_DISPLAY_TTGO
default 21 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS default 21 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
default 14 if LV_PREDEFINED_DISPLAY_WT32_SC01
default 14 default 14
help help
@ -808,6 +824,7 @@ menu "LVGL TFT Display controller"
default 26 if LV_PREDEFINED_DISPLAY_ATAG default 26 if LV_PREDEFINED_DISPLAY_ATAG
default 5 if LV_PREDEFINED_DISPLAY_TTGO default 5 if LV_PREDEFINED_DISPLAY_TTGO
default 12 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS default 12 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
default 15 if LV_PREDEFINED_DISPLAY_WT32_SC01
default 15 default 15
help help
@ -829,6 +846,7 @@ menu "LVGL TFT Display controller"
default 27 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK default 27 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
default 23 if LV_PREDEFINED_DISPLAY_M5STICKC default 23 if LV_PREDEFINED_DISPLAY_M5STICKC
default 21 if LV_PREDEFINED_DISPLAY_WROVER4 default 21 if LV_PREDEFINED_DISPLAY_WROVER4
default 21 if LV_PREDEFINED_DISPLAY_WT32_SC01
default 33 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING default 33 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
default 0 if LV_PREDEFINED_PINS_TKOALA default 0 if LV_PREDEFINED_PINS_TKOALA
default 17 if LV_PREDEFINED_DISPLAY_ATAG default 17 if LV_PREDEFINED_DISPLAY_ATAG
@ -852,6 +870,7 @@ menu "LVGL TFT Display controller"
default 16 if LV_PREDEFINED_DISPLAY_ATAG default 16 if LV_PREDEFINED_DISPLAY_ATAG
default 23 if LV_PREDEFINED_DISPLAY_TTGO default 23 if LV_PREDEFINED_DISPLAY_TTGO
default 33 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS default 33 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
default 22 if LV_PREDEFINED_DISPLAY_WT32_SC01
default 4 default 4
help help
@ -875,6 +894,7 @@ menu "LVGL TFT Display controller"
default y if LV_PREDEFINED_DISPLAY_ERTFT0356 default y if LV_PREDEFINED_DISPLAY_ERTFT0356
default y if LV_PREDEFINED_DISPLAY_TTGO default y if LV_PREDEFINED_DISPLAY_TTGO
default y if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS default y if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
default y if LV_PREDEFINED_DISPLAY_WT32_SC01
help help
Enable controlling the display backlight using an GPIO Enable controlling the display backlight using an GPIO
@ -885,6 +905,7 @@ menu "LVGL TFT Display controller"
default y if LV_PREDEFINED_DISPLAY_ERTFT0356 default y if LV_PREDEFINED_DISPLAY_ERTFT0356
default y if LV_PREDEFINED_DISPLAY_TTGO default y if LV_PREDEFINED_DISPLAY_TTGO
default y if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS default y if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
default y if LV_PREDEFINED_DISPLAY_WT32_SC01
help help
Some backlights are turned on with a high signal, others held low. 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, If enabled, a value of 1 will be sent to the display to enable the backlight,
@ -903,6 +924,7 @@ menu "LVGL TFT Display controller"
default 0 if LV_PREDEFINED_PINS_TKOALA default 0 if LV_PREDEFINED_PINS_TKOALA
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 27 default 27
help help

View file

@ -15,6 +15,8 @@ void disp_driver_init(void)
ili9488_init(); ili9488_init();
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789
st7789_init(); st7789_init();
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7796S
st7796s_init();
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S
st7735s_init(); st7735s_init();
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357
@ -50,6 +52,8 @@ void disp_driver_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t *
ili9488_flush(drv, area, color_map); ili9488_flush(drv, area, color_map);
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789
st7789_flush(drv, area, color_map); st7789_flush(drv, area, color_map);
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7796S
st7796s_flush(drv, area, color_map);
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S
st7735s_flush(drv, area, color_map); st7735s_flush(drv, area, color_map);
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357

View file

@ -26,6 +26,8 @@ extern "C" {
#include "ili9488.h" #include "ili9488.h"
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789
#include "st7789.h" #include "st7789.h"
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7796S
#include "st7796s.h"
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S
#include "st7735s.h" #include "st7735s.h"
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357

242
lvgl_tft/st7796s.c Normal file
View file

@ -0,0 +1,242 @@
/**
* @file st7796s.c
*
*/
/*********************
* INCLUDES
*********************/
#include "st7796s.h"
#include "disp_spi.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
/*********************
* DEFINES
*********************/
#define TAG "ST7796S"
/**********************
* TYPEDEFS
**********************/
/*The LCD needs a bunch of command/argument values to be initialized. They are stored in this struct. */
typedef struct
{
uint8_t cmd;
uint8_t data[16];
uint8_t databytes; //No of data in data; bit 7 = delay after set; 0xFF = end of cmds.
} lcd_init_cmd_t;
/**********************
* STATIC PROTOTYPES
**********************/
static void st7796s_set_orientation(uint8_t orientation);
static void st7796s_send_cmd(uint8_t cmd);
static void st7796s_send_data(void *data, uint16_t length);
static void st7796s_send_color(void *data, uint16_t length);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void st7796s_init(void)
{
lcd_init_cmd_t init_cmds[] = {
{0xCF, {0x00, 0x83, 0X30}, 3},
{0xED, {0x64, 0x03, 0X12, 0X81}, 4},
{0xE8, {0x85, 0x01, 0x79}, 3},
{0xCB, {0x39, 0x2C, 0x00, 0x34, 0x02}, 5},
{0xF7, {0x20}, 1},
{0xEA, {0x00, 0x00}, 2},
{0xC0, {0x26}, 1}, /*Power control*/
{0xC1, {0x11}, 1}, /*Power control */
{0xC5, {0x35, 0x3E}, 2}, /*VCOM control*/
{0xC7, {0xBE}, 1}, /*VCOM control*/
{0x36, {0x28}, 1}, /*Memory Access Control*/
{0x3A, {0x55}, 1}, /*Pixel Format Set*/
{0xB1, {0x00, 0x1B}, 2},
{0xF2, {0x08}, 1},
{0x26, {0x01}, 1},
{0xE0, {0x1F, 0x1A, 0x18, 0x0A, 0x0F, 0x06, 0x45, 0X87, 0x32, 0x0A, 0x07, 0x02, 0x07, 0x05, 0x00}, 15},
{0XE1, {0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3A, 0x78, 0x4D, 0x05, 0x18, 0x0D, 0x38, 0x3A, 0x1F}, 15},
{0x2A, {0x00, 0x00, 0x00, 0xEF}, 4},
{0x2B, {0x00, 0x00, 0x01, 0x3f}, 4},
{0x2C, {0}, 0},
{0xB7, {0x07}, 1},
{0xB6, {0x0A, 0x82, 0x27, 0x00}, 4},
{0x11, {0}, 0x80},
{0x29, {0}, 0x80},
{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
gpio_pad_select_gpio(ST7796S_DC);
gpio_set_direction(ST7796S_DC, GPIO_MODE_OUTPUT);
gpio_pad_select_gpio(ST7796S_RST);
gpio_set_direction(ST7796S_RST, GPIO_MODE_OUTPUT);
#if ST7796S_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(ST7796S_BCKL);
gpio_set_direction(ST7796S_BCKL, GPIO_MODE_OUTPUT);
#endif
//Reset the display
gpio_set_level(ST7796S_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS);
gpio_set_level(ST7796S_RST, 1);
vTaskDelay(100 / portTICK_RATE_MS);
ESP_LOGI(TAG, "Initialization.");
//Send all the commands
uint16_t cmd = 0;
while (init_cmds[cmd].databytes != 0xff)
{
st7796s_send_cmd(init_cmds[cmd].cmd);
st7796s_send_data(init_cmds[cmd].data, init_cmds[cmd].databytes & 0x1F);
if (init_cmds[cmd].databytes & 0x80)
{
vTaskDelay(100 / portTICK_RATE_MS);
}
cmd++;
}
st7796s_enable_backlight(true);
st7796s_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
#if ST7796S_INVERT_COLORS == 1
st7796s_send_cmd(0x21);
#else
st7796s_send_cmd(0x20);
#endif
}
void st7796s_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
{
uint8_t data[4];
/*Column addresses*/
st7796s_send_cmd(0x2A);
data[0] = (area->x1 >> 8) & 0xFF;
data[1] = area->x1 & 0xFF;
data[2] = (area->x2 >> 8) & 0xFF;
data[3] = area->x2 & 0xFF;
st7796s_send_data(data, 4);
/*Page addresses*/
st7796s_send_cmd(0x2B);
data[0] = (area->y1 >> 8) & 0xFF;
data[1] = area->y1 & 0xFF;
data[2] = (area->y2 >> 8) & 0xFF;
data[3] = area->y2 & 0xFF;
st7796s_send_data(data, 4);
/*Memory write*/
st7796s_send_cmd(0x2C);
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
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()
{
uint8_t data[] = {0x08};
st7796s_send_cmd(0x10);
st7796s_send_data(&data, 1);
}
void st7796s_sleep_out()
{
uint8_t data[] = {0x08};
st7796s_send_cmd(0x11);
st7796s_send_data(&data, 1);
}
/**********************
* STATIC FUNCTIONS
**********************/
static void st7796s_send_cmd(uint8_t cmd)
{
disp_wait_for_pending_transactions();
gpio_set_level(ST7796S_DC, 0); /*Command mode*/
disp_spi_send_data(&cmd, 1);
}
static void st7796s_send_data(void *data, uint16_t length)
{
disp_wait_for_pending_transactions();
gpio_set_level(ST7796S_DC, 1); /*Data mode*/
disp_spi_send_data(data, length);
}
static void st7796s_send_color(void *data, uint16_t length)
{
disp_wait_for_pending_transactions();
gpio_set_level(ST7796S_DC, 1); /*Data mode*/
disp_spi_send_colors(data, length);
}
static void st7796s_set_orientation(uint8_t orientation)
{
// ESP_ASSERT(orientation < 4);
const char *orientation_str[] = {
"PORTRAIT", "PORTRAIT_INVERTED", "LANDSCAPE", "LANDSCAPE_INVERTED"};
ESP_LOGI(TAG, "Display orientation: %s", orientation_str[orientation]);
#if defined CONFIG_LV_PREDEFINED_DISPLAY_M5STACK
uint8_t data[] = {0x68, 0x68, 0x08, 0x08};
#elif defined(CONFIG_LV_PREDEFINED_DISPLAY_WROVER4)
uint8_t data[] = {0x4C, 0x88, 0x28, 0xE8};
#elif defined(CONFIG_LV_PREDEFINED_DISPLAY_WT32_SC01)
uint8_t data[] = {0x48, 0x88, 0x28, 0xE8};
#elif defined(CONFIG_LV_PREDEFINED_DISPLAY_NONE)
uint8_t data[] = {0x48, 0x88, 0x28, 0xE8};
#endif
ESP_LOGI(TAG, "0x36 command value: 0x%02X", data[orientation]);
st7796s_send_cmd(0x36);
st7796s_send_data((void *)&data[orientation], 1);
}

131
lvgl_tft/st7796s.h Normal file
View file

@ -0,0 +1,131 @@
/**
* @file st7796s.h
*/
#ifndef ST7796S_H
#define ST7796S_H
#ifdef __cplusplus
extern "C"
{
#endif
/*********************
* INCLUDES
*********************/
#include <stdbool.h>
#include <stdint.h>
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
#include "../lvgl_helpers.h"
/*********************
* DEFINES
*********************/
#define ST7796S_DC CONFIG_LV_DISP_PIN_DC
#define ST7796S_RST CONFIG_LV_DISP_PIN_RST
#define ST7796S_BCKL CONFIG_LV_DISP_PIN_BCKL
#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
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define ST7796S_BCKL_ACTIVE_LVL 1
#else
#define ST7796S_BCKL_ACTIVE_LVL 0
#endif
/*******************
* ST7796S REGS
*********************/
/* MIPI DCS Type1 */
#define ST7796S_CMD_NOP 0x00
#define ST7796S_CMD_SOFTWARE_RESET 0x01
#define ST7796S_CMD_READ_DISP_POWER_MODE 0x0A
#define ST7796S_CMD_READ_DISP_MADCTRL 0x0B // bits 7:3 only
#define ST7796S_CMD_READ_DISP_PIXEL_FORMAT 0x0C
#define ST7796S_CMD_READ_DISP_IMAGE_MODE 0x0D
#define ST7796S_CMD_READ_DISP_SIGNAL_MODE 0x0E
#define ST7796S_CMD_READ_DISP_SELF_DIAGNOSTIC 0x0F // bits 7:6 only
#define ST7796S_CMD_ENTER_SLEEP_MODE 0x10
#define ST7796S_CMD_SLEEP_OUT 0x11
#define ST7796S_CMD_PARTIAL_MODE_ON 0x12
#define ST7796S_CMD_NORMAL_DISP_MODE_ON 0x13
#define ST7796S_CMD_DISP_INVERSION_OFF 0x20
#define ST7796S_CMD_DISP_INVERSION_ON 0x21
#define ST7796S_CMD_DISPLAY_OFF 0x28
#define ST7796S_CMD_DISPLAY_ON 0x29
#define ST7796S_CMD_COLUMN_ADDRESS_SET 0x2A
#define ST7796S_CMD_PAGE_ADDRESS_SET 0x2B
#define ST7796S_CMD_MEMORY_WRITE 0x2C
#define ST7796S_CMD_MEMORY_READ 0x2E
#define ST7796S_CMD_PARTIAL_AREA 0x30
#define ST7796S_CMD_VERT_SCROLL_DEFINITION 0x33
#define ST7796S_CMD_TEARING_EFFECT_LINE_OFF 0x34
#define ST7796S_CMD_TEARING_EFFECT_LINE_ON 0x35
#define ST7796S_CMD_MEMORY_ACCESS_CONTROL 0x36 // bits 7:3,1:0 only
#define ST7796S_CMD_VERT_SCROLL_START_ADDRESS 0x37
#define ST7796S_CMD_IDLE_MODE_OFF 0x38
#define ST7796S_CMD_IDLE_MODE_ON 0x39
#define ST7796S_CMD_COLMOD_PIXEL_FORMAT_SET 0x3A
#define ST7796S_CMD_WRITE_MEMORY_CONTINUE 0x3C
#define ST7796S_CMD_READ_MEMORY_CONTINUE 0x3E
#define ST7796S_CMD_SET_TEAR_SCANLINE 0x44
#define ST7796S_CMD_GET_SCANLINE 0x45
#define ST7796S_DDB_START 0xA1
#define ST7796S_DDB_CONTINUE 0xA8
/* other */
#define ST7796S_CMD_ACCESS_PROTECT 0xB0
#define ST7796S_CMD_LOW_POWER_CONTROL 0xB1
#define ST7796S_CMD_FRAME_MEMORY_ACCESS 0xB3
#define ST7796S_CMD_DISPLAY_MODE 0xB4
#define ST7796S_CMD_DEVICE_CODE 0xBF
#define ST7796S_CMD_PANEL_DRIVE 0xC0
#define ST7796S_CMD_DISP_TIMING_NORMAL 0xC1
#define ST7796S_CMD_DISP_TIMING_PARTIAL 0xC2
#define ST7796S_CMD_DISP_TIMING_IDLE 0xC3
#define ST7796S_CMD_FRAME_RATE 0xC5
#define ST7796S_CMD_INTERFACE_CONTROL 0xC6
#define ST7796S_CMD_GAMMA_SETTING 0xC8
#define ST7796S_CMD_POWER_SETTING 0xD0
#define ST7796S_CMD_VCOM_CONTROL 0xD1
#define ST7796S_CMD_POWER_CONTROL_NORMAL 0xD2
#define ST7796S_CMD_POWER_CONTROL_IDEL 0xD3
#define ST7796S_CMD_POWER_CONTROL_PARTIAL 0xD4
#define ST7796S_CMD_NVMEM_WRITE 0xE0
#define ST7796S_CMD_NVMEM_PROTECTION_KEY 0xE1
#define ST7796S_CMD_NVMEM_STATUS_READ 0xE2
#define ST7796S_CMD_NVMEM_PROTECTION 0xE3
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void st7796s_init(void);
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
**********************/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*ST7796S_H*/

View file

@ -21,7 +21,13 @@
#define __FT6X06_H #define __FT6X06_H
#include <lvgl/src/lv_hal/lv_hal.h> #include <stdint.h>
#include <stdbool.h>
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {