Marge branch 'master' into lvgl_7.11.0_idf_5.0
This commit is contained in:
commit
a73c429954
62 changed files with 2427 additions and 1270 deletions
|
@ -144,7 +144,7 @@ void DELAY_MS(uint16_t ms)
|
|||
vTaskDelay(ms / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
|
||||
#if EVE_USE_PDN
|
||||
void EVE_pdn_set(void)
|
||||
{
|
||||
gpio_set_level(EVE_PDN, 0); /* Power-Down low */
|
||||
|
@ -155,7 +155,7 @@ void EVE_pdn_clear(void)
|
|||
{
|
||||
gpio_set_level(EVE_PDN, 1); /* Power-Down high */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void spi_acquire()
|
||||
{
|
||||
|
@ -841,11 +841,13 @@ uint8_t EVE_init(void)
|
|||
uint8_t chipid = 0;
|
||||
uint16_t timeout = 0;
|
||||
|
||||
#if EVE_USE_PDN
|
||||
EVE_pdn_set();
|
||||
DELAY_MS(6); /* minimum time for power-down is 5ms */
|
||||
|
||||
EVE_pdn_clear();
|
||||
DELAY_MS(21); /* minimum time to allow from rising PD_N to first access is 20ms */
|
||||
#endif
|
||||
|
||||
/* EVE_cmdWrite(EVE_CORERST,0); */ /* reset, only required for warm-start if PowerDown line is not used */
|
||||
|
||||
|
|
|
@ -39,8 +39,12 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
|
|||
#define BLOCK_TRANSFER_SIZE 3840 // block transfer size when write data to CMD buffer
|
||||
|
||||
void DELAY_MS(uint16_t ms);
|
||||
|
||||
#if EVE_USE_PDN
|
||||
void EVE_pdn_set(void);
|
||||
void EVE_pdn_clear(void);
|
||||
#endif
|
||||
|
||||
void spi_acquire();
|
||||
void spi_release();
|
||||
|
||||
|
@ -64,7 +68,7 @@ void EVE_get_cmdoffset(void);
|
|||
/* commands to operate on memory: */
|
||||
void EVE_cmd_memzero(uint32_t ptr, uint32_t num);
|
||||
void EVE_cmd_memset(uint32_t ptr, uint8_t value, uint32_t num);
|
||||
void EVE_cmd_memwrite(uint32_t dest, uint32_t num, const uint8_t *data);
|
||||
void EVE_cmd_memwrite(uint32_t dest, uint32_t num, const uint8_t *data);
|
||||
void EVE_cmd_memcpy(uint32_t dest, uint32_t src, uint32_t num);
|
||||
|
||||
#if FT81X_FULL
|
||||
|
|
|
@ -44,11 +44,12 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
|
|||
|
||||
#include "FT81x.h"
|
||||
|
||||
#define EVE_CLK DISP_SPI_CLK // orange
|
||||
#define EVE_MISO DISP_SPI_MISO // yellow
|
||||
#define EVE_MOSI DISP_SPI_MOSI // green
|
||||
#define EVE_CS DISP_SPI_CS // blue
|
||||
#define EVE_PDN CONFIG_LV_DISP_PIN_RST // grey
|
||||
#define EVE_CLK DISP_SPI_CLK // orange
|
||||
#define EVE_MISO DISP_SPI_MISO // yellow
|
||||
#define EVE_MOSI DISP_SPI_MOSI // green
|
||||
#define EVE_CS DISP_SPI_CS // blue
|
||||
#define EVE_PDN CONFIG_LV_DISP_PIN_RST // grey
|
||||
#define EVE_USE_PDN CONFIG_LV_DISP_USE_RST
|
||||
|
||||
#define SPI_TRANSER_SIZE (DISP_BUF_SIZE * (LV_COLOR_DEPTH / 8))
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ void TFT_bitmap_display(void)
|
|||
EVE_cmd_dl(TAG(0));
|
||||
|
||||
EVE_cmd_dl(DL_DISPLAY); /* instruct the graphics processor to show the list */
|
||||
|
||||
|
||||
EVE_cmd_dl(CMD_SWAP); /* make this list active */
|
||||
|
||||
EVE_end_cmd_burst(); /* stop writing to the cmd-fifo */
|
||||
|
@ -262,12 +262,18 @@ void TFT_bitmap_display(void)
|
|||
|
||||
void FT81x_init(void)
|
||||
{
|
||||
#if EVE_USE_PDN
|
||||
gpio_reset_pin(EVE_PDN);
|
||||
#endif
|
||||
|
||||
gpio_set_level(EVE_CS, 1);
|
||||
|
||||
#if EVE_USE_PDN
|
||||
gpio_set_direction(EVE_PDN, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
|
||||
spi_acquire();
|
||||
|
||||
|
||||
if(EVE_init())
|
||||
{
|
||||
tft_active = 1;
|
||||
|
@ -278,7 +284,7 @@ void FT81x_init(void)
|
|||
|
||||
EVE_cmd_memset(SCREEN_BITMAP_ADDR, BLACK, SCREEN_BUFFER_SIZE); // clear screen buffer
|
||||
EVE_cmd_execute();
|
||||
|
||||
|
||||
TFT_bitmap_display(); // set DL for fullscreen bitmap display
|
||||
}
|
||||
|
||||
|
@ -320,4 +326,4 @@ void TFT_WriteBitmap(uint8_t* Bitmap, uint16_t X, uint16_t Y, uint16_t Width, ui
|
|||
void FT81x_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
|
||||
{
|
||||
TFT_WriteBitmap((uint8_t*)color_map, area->x1, area->y1, lv_area_get_width(area), lv_area_get_height(area));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,31 +111,25 @@ 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
|
||||
gpio_reset_pin(GC9A01_DC);
|
||||
gpio_reset_pin(GC9A01_DC);
|
||||
gpio_set_direction(GC9A01_DC, GPIO_MODE_OUTPUT);
|
||||
gpio_reset_pin(GC9A01_RST);
|
||||
|
||||
#if GC9A01_USE_RST
|
||||
gpio_reset_pin(GC9A01_RST);
|
||||
gpio_set_direction(GC9A01_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if GC9A01_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(GC9A01_BCKL);
|
||||
gpio_set_direction(GC9A01_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
//Reset the display
|
||||
gpio_set_level(GC9A01_RST, 0);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(GC9A01_RST, 1);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
#endif
|
||||
|
||||
#if GC9A01_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(GC9A01_BCKL);
|
||||
gpio_set_direction(GC9A01_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "Initialization.");
|
||||
|
||||
|
@ -150,8 +144,6 @@ void GC9A01_init(void)
|
|||
cmd++;
|
||||
}
|
||||
|
||||
GC9A01_enable_backlight(true);
|
||||
|
||||
GC9A01_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
|
||||
|
||||
#if GC9A01_INVERT_COLORS == 1
|
||||
|
@ -167,7 +159,7 @@ void GC9A01_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
|
|||
uint8_t data[4];
|
||||
|
||||
/*Column addresses*/
|
||||
GC9A01_send_cmd(0x2A); //0x2A
|
||||
GC9A01_send_cmd(0x2A); //0x2A
|
||||
data[0] = (area->x1 >> 8) & 0xFF;
|
||||
data[1] = area->x1 & 0xFF;
|
||||
data[2] = (area->x2 >> 8) & 0xFF;
|
||||
|
@ -175,7 +167,7 @@ void GC9A01_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
|
|||
GC9A01_send_data(data, 4);
|
||||
|
||||
/*Page addresses*/
|
||||
GC9A01_send_cmd(0x2B); //0x2B
|
||||
GC9A01_send_cmd(0x2B); //0x2B
|
||||
data[0] = (area->y1 >> 8) & 0xFF;
|
||||
data[1] = area->y1 & 0xFF;
|
||||
data[2] = (area->y2 >> 8) & 0xFF;
|
||||
|
@ -183,7 +175,7 @@ void GC9A01_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
|
|||
GC9A01_send_data(data, 4);
|
||||
|
||||
/*Memory write*/
|
||||
GC9A01_send_cmd(0x2C); //0x2C
|
||||
GC9A01_send_cmd(0x2C); //0x2C
|
||||
|
||||
|
||||
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
|
||||
|
@ -191,27 +183,11 @@ 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);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
uint8_t data[] = {0x08};
|
||||
GC9A01_send_cmd(0x10); //0x10 Enter Sleep Mode
|
||||
GC9A01_send_data(&data, 1);
|
||||
GC9A01_send_data(&data, 1);
|
||||
}
|
||||
|
||||
void GC9A01_sleep_out()
|
||||
|
|
|
@ -25,18 +25,9 @@ extern "C" {
|
|||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define GC9A01_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define GC9A01_RST CONFIG_LV_DISP_PIN_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_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define GC9A01_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define GC9A01_USE_RST CONFIG_LV_DISP_USE_RST
|
||||
#define GC9A01_INVERT_COLORS CONFIG_LV_INVERT_COLORS
|
||||
|
||||
/**********************
|
||||
|
@ -49,7 +40,6 @@ extern "C" {
|
|||
|
||||
void GC9A01_init(void);
|
||||
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_out(void);
|
||||
|
||||
|
|
332
lvgl_tft/Kconfig
332
lvgl_tft/Kconfig
|
@ -21,6 +21,10 @@ menu "LVGL TFT Display controller"
|
|||
bool "M5Stack"
|
||||
select LV_TFT_DISPLAY_CONTROLLER_ILI9341
|
||||
select LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
config LV_PREDEFINED_DISPLAY_M5CORE2
|
||||
bool "M5Core2"
|
||||
select LV_TFT_DISPLAY_CONTROLLER_ILI9341
|
||||
select LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
config LV_PREDEFINED_DISPLAY_M5STICK
|
||||
bool "M5Stick"
|
||||
select LV_TFT_DISPLAY_CONTROLLER_SH1107
|
||||
|
@ -46,7 +50,7 @@ menu "LVGL TFT Display controller"
|
|||
config LV_PREDEFINED_DISPLAY_WEMOS_LOLIN
|
||||
bool "Wemos Lolin OLED"
|
||||
select LV_TFT_DISPLAY_CONTROLLER_SSD1306
|
||||
select LV_TFT_DISPLAY_PROTOCOL_I2C
|
||||
select LV_I2C_DISPLAY
|
||||
select LV_TFT_DISPLAY_MONOCHROME
|
||||
select LV_THEME_MONO
|
||||
config LV_PREDEFINED_DISPLAY_ATAG
|
||||
|
@ -165,6 +169,15 @@ menu "LVGL TFT Display controller"
|
|||
help
|
||||
ST7796S display controller.
|
||||
|
||||
config LV_TFT_DISPLAY_CONTROLLER_ILI9163C
|
||||
bool
|
||||
help
|
||||
ILI9163C display controller.
|
||||
|
||||
config LV_TFT_DISPLAY_CONTROLLER_PCD8544
|
||||
bool
|
||||
help
|
||||
PCD8544 display controller (Nokia 3110/5110)
|
||||
# Display controller communication protocol
|
||||
#
|
||||
# This symbols define the communication protocol used by the
|
||||
|
@ -178,7 +191,7 @@ menu "LVGL TFT Display controller"
|
|||
help
|
||||
Display controller protocol SPI
|
||||
|
||||
config LV_TFT_DISPLAY_PROTOCOL_I2C
|
||||
config LV_I2C_DISPLAY
|
||||
bool
|
||||
help
|
||||
Display controller protocol I2C
|
||||
|
@ -186,24 +199,24 @@ menu "LVGL TFT Display controller"
|
|||
# Used in display init function to send display orientation commands
|
||||
choice DISPLAY_ORIENTATION
|
||||
prompt "Display orientation"
|
||||
default DISPLAY_ORIENTATION_PORTRAIT if !LV_TFT_DISPLAY_CONTROLLER_SSD1306
|
||||
default DISPLAY_ORIENTATION_LANDSCAPE if LV_TFT_DISPLAY_CONTROLLER_SSD1306
|
||||
config DISPLAY_ORIENTATION_PORTRAIT
|
||||
default LV_DISPLAY_ORIENTATION_PORTRAIT if !LV_TFT_DISPLAY_CONTROLLER_SSD1306
|
||||
default LV_DISPLAY_ORIENTATION_LANDSCAPE if LV_TFT_DISPLAY_CONTROLLER_SSD1306
|
||||
config LV_DISPLAY_ORIENTATION_PORTRAIT
|
||||
bool "Portrait" if !LV_TFT_DISPLAY_CONTROLLER_SSD1306
|
||||
config DISPLAY_ORIENTATION_PORTRAIT_INVERTED
|
||||
config LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED
|
||||
bool "Portrait inverted" if !LV_TFT_DISPLAY_CONTROLLER_SSD1306
|
||||
config DISPLAY_ORIENTATION_LANDSCAPE
|
||||
config LV_DISPLAY_ORIENTATION_LANDSCAPE
|
||||
bool "Landscape"
|
||||
config DISPLAY_ORIENTATION_LANDSCAPE_INVERTED
|
||||
config LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED
|
||||
bool "Landscape inverted"
|
||||
endchoice
|
||||
|
||||
config LV_DISPLAY_ORIENTATION
|
||||
int
|
||||
default 0 if DISPLAY_ORIENTATION_PORTRAIT
|
||||
default 1 if DISPLAY_ORIENTATION_PORTRAIT_INVERTED
|
||||
default 2 if DISPLAY_ORIENTATION_LANDSCAPE
|
||||
default 3 if DISPLAY_ORIENTATION_LANDSCAPE_INVERTED
|
||||
default 0 if LV_DISPLAY_ORIENTATION_PORTRAIT
|
||||
default 1 if LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED
|
||||
default 2 if LV_DISPLAY_ORIENTATION_LANDSCAPE
|
||||
default 3 if LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED
|
||||
|
||||
config LV_TFT_DISPLAY_OFFSETS
|
||||
bool
|
||||
|
@ -212,14 +225,14 @@ menu "LVGL TFT Display controller"
|
|||
|
||||
config LV_TFT_DISPLAY_X_OFFSET
|
||||
depends on LV_TFT_DISPLAY_OFFSETS
|
||||
int
|
||||
int "X offset"
|
||||
default 40 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_LANDSCAPE || LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
|
||||
default 53 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_PORTRAIT || LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
|
||||
default 0
|
||||
|
||||
config LV_TFT_DISPLAY_Y_OFFSET
|
||||
depends on LV_TFT_DISPLAY_OFFSETS
|
||||
int
|
||||
int "Y offset"
|
||||
default 53 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_LANDSCAPE || LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
|
||||
default 40 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_PORTRAIT || LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
|
||||
default 0
|
||||
|
@ -302,7 +315,7 @@ menu "LVGL TFT Display controller"
|
|||
config LV_TFT_DISPLAY_USER_CONTROLLER_SSD1306
|
||||
bool "SSD1306"
|
||||
select LV_TFT_DISPLAY_CONTROLLER_SSD1306
|
||||
select LV_TFT_DISPLAY_PROTOCOL_I2C
|
||||
select LV_I2C_DISPLAY
|
||||
select LV_TFT_DISPLAY_MONOCHROME
|
||||
config LV_TFT_DISPLAY_USER_CONTROLLER_FT81X
|
||||
bool "FT81X"
|
||||
|
@ -327,6 +340,15 @@ menu "LVGL TFT Display controller"
|
|||
bool "RA8875"
|
||||
select LV_TFT_DISPLAY_CONTROLLER_RA8875
|
||||
select LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
config LV_TFT_DISPLAY_USER_CONTROLLER_ILI9163C
|
||||
bool "ILI9163C"
|
||||
select LV_TFT_DISPLAY_CONTROLLER_ILI9163C
|
||||
select LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
config LV_TFT_DISPLAY_USER_CONTROLLER_PCD8544
|
||||
bool "PCD8544"
|
||||
select LV_TFT_DISPLAY_CONTROLLER_PCD8544
|
||||
select LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
select LV_TFT_DISPLAY_MONOCHROME
|
||||
endchoice
|
||||
|
||||
config CUSTOM_DISPLAY_BUFFER_SIZE
|
||||
|
@ -446,20 +468,15 @@ menu "LVGL TFT Display controller"
|
|||
endchoice
|
||||
|
||||
choice
|
||||
prompt "TFT SPI Bus." if LV_TFT_DISPLAY_PROTOCOL_SPI && \
|
||||
!LV_PREDEFINED_DISPLAY_TTGO
|
||||
default LV_TFT_DISPLAY_SPI_VSPI if LV_PREDEFINED_DISPLAY_TTGO && \
|
||||
!IDF_TARGET_ESP32S2
|
||||
default LV_TFT_DISPLAY_SPI_FSPI if IDF_TARGET_ESP32S2
|
||||
prompt "TFT SPI Bus." if LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
default LV_TFT_DISPLAY_SPI2_HOST
|
||||
help
|
||||
Select the SPI Bus the TFT Display is attached to.
|
||||
|
||||
config LV_TFT_DISPLAY_SPI_HSPI
|
||||
bool "HSPI"
|
||||
config LV_TFT_DISPLAY_SPI_VSPI
|
||||
bool "VSPI" if !IDF_TARGET_ESP32S2
|
||||
config LV_TFT_DISPLAY_SPI_FSPI
|
||||
bool "FSPI" if IDF_TARGET_ESP32S2
|
||||
config LV_TFT_DISPLAY_SPI2_HOST
|
||||
bool "SPI2_HOST"
|
||||
config LV_TFT_DISPLAY_SPI3_HOST
|
||||
bool "SPI3_HOST"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
|
@ -490,18 +507,6 @@ menu "LVGL TFT Display controller"
|
|||
depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_SIO
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Display I2C port" if LV_TFT_DISPLAY_PROTOCOL_I2C
|
||||
default LV_DISPLAY_I2C_PORT_0
|
||||
help
|
||||
Select the I2C port used by the display controller.
|
||||
|
||||
config LV_DISPLAY_I2C_PORT_0
|
||||
bool "I2C PORT 0"
|
||||
config LV_DISPLAY_I2C_PORT_1
|
||||
bool "I2C PORT 1"
|
||||
endchoice
|
||||
|
||||
config LV_TFT_USE_CUSTOM_SPI_CLK_DIVIDER
|
||||
bool "Use custom SPI clock frequency." if LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
default n
|
||||
|
@ -579,6 +584,16 @@ menu "LVGL TFT Display controller"
|
|||
default 80 if LV_TFT_SPI_CLK_DIVIDER_80
|
||||
default 2
|
||||
|
||||
config LV_M5STICKC_HANDLE_AXP192
|
||||
bool "Handle Backlight and TFT power for M5StickC using AXP192." if LV_PREDEFINED_DISPLAY_M5STICKC || LV_TFT_DISPLAY_CONTROLLER_ST7735S
|
||||
default y if LV_PREDEFINED_DISPLAY_M5STICKC
|
||||
select LV_I2C_DISPLAY
|
||||
help
|
||||
Display and TFT power supply on M5StickC is controlled using an
|
||||
AXP192 Power Mangerment IC. Select yes if you want to enable TFT IC
|
||||
(LDO3) and backlight power using AXP192 by LVGL, or select no if you
|
||||
want to take care of power management in your own code.
|
||||
|
||||
config LV_INVERT_DISPLAY
|
||||
bool "IN DEPRECATION - Invert display." if LV_TFT_DISPLAY_CONTROLLER_RA8875
|
||||
default n
|
||||
|
@ -586,37 +601,12 @@ menu "LVGL TFT Display controller"
|
|||
If text is backwards on your display, try enabling this.
|
||||
|
||||
config LV_INVERT_COLORS
|
||||
bool "Invert colors in display" if LV_TFT_DISPLAY_CONTROLLER_ILI9341 || LV_TFT_DISPLAY_CONTROLLER_ST7735S || LV_TFT_DISPLAY_CONTROLLER_ILI9481 || LV_TFT_DISPLAY_CONTROLLER_ST7789 || LV_TFT_DISPLAY_CONTROLLER_SSD1306 || LV_TFT_DISPLAY_CONTROLLER_SH1107 || LV_TFT_DISPLAY_CONTROLLER_HX8357
|
||||
bool "Invert colors in display" if LV_TFT_DISPLAY_CONTROLLER_ILI9341 || LV_TFT_DISPLAY_CONTROLLER_ST7735S || LV_TFT_DISPLAY_CONTROLLER_ILI9481 || LV_TFT_DISPLAY_CONTROLLER_ST7789 || LV_TFT_DISPLAY_CONTROLLER_SSD1306 || LV_TFT_DISPLAY_CONTROLLER_SH1107 || LV_TFT_DISPLAY_CONTROLLER_HX8357 || LV_TFT_DISPLAY_CONTROLLER_GC9A01 || LV_TFT_DISPLAY_CONTROLLER_ILI9163C
|
||||
default y if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICKC
|
||||
help
|
||||
If the colors look inverted on your display, try enabling this.
|
||||
If it didn't help try LVGL configuration -> Swap the 2 bytes of RGB565 color.
|
||||
|
||||
config LV_M5STICKC_HANDLE_AXP192
|
||||
bool "Handle Backlight and TFT power for M5StickC using AXP192." if LV_PREDEFINED_DISPLAY_M5STICKC || LV_TFT_DISPLAY_CONTROLLER_ST7735S
|
||||
default y if LV_PREDEFINED_DISPLAY_M5STICKC
|
||||
help
|
||||
Display and TFT power supply on M5StickC is controlled using an AXP192 Power Mangerment IC.
|
||||
Select yes if you want to enable TFT IC (LDO3) and backlight power using AXP192 by LVGL, or select no if you want to take care of
|
||||
power management in your own code.
|
||||
|
||||
config LV_AXP192_PIN_SDA
|
||||
int "GPIO for AXP192 I2C SDA"
|
||||
depends on LV_M5STICKC_HANDLE_AXP192
|
||||
range 0 39
|
||||
default 21 if LV_PREDEFINED_DISPLAY_M5STICKC
|
||||
default 21
|
||||
help
|
||||
Configure the AXP192 I2C SDA pin here.
|
||||
|
||||
config LV_AXP192_PIN_SCL
|
||||
int "GPIO for AXP192 I2C SCL"
|
||||
depends on LV_M5STICKC_HANDLE_AXP192
|
||||
range 0 39
|
||||
default 22 if LV_PREDEFINED_DISPLAY_M5STICKC
|
||||
default 22
|
||||
help
|
||||
Configure the AXP192 I2C SDA pin here.
|
||||
|
||||
# menu will be visible only when LV_PREDEFINED_DISPLAY_NONE is y
|
||||
menu "Display RA8875 Configuration"
|
||||
|
@ -744,11 +734,11 @@ menu "LVGL TFT Display controller"
|
|||
|
||||
config LV_DISP_ST7789_SOFT_RESET
|
||||
bool "Soft reset - use software reset instead of reset pin"
|
||||
depends on LV_TFT_DISPLAY_CONTROLLER_ST7789
|
||||
depends on LV_TFT_DISPLAY_CONTROLLER_ST7789
|
||||
default n
|
||||
help
|
||||
Use software reset and ignores configured reset pin (some hardware does not use a reset pin).
|
||||
|
||||
|
||||
endmenu
|
||||
|
||||
# menu will be visible only when LV_PREDEFINED_DISPLAY_NONE is y
|
||||
|
@ -757,12 +747,10 @@ menu "LVGL TFT Display controller"
|
|||
|
||||
config LV_DISP_SPI_MOSI
|
||||
int "GPIO for MOSI (Master Out Slave In)" if LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 23 if LV_PREDEFINED_DISPLAY_WROVER4
|
||||
default 23 if LV_PREDEFINED_DISPLAY_ATAG
|
||||
default 23 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
|
||||
default 23 if LV_PREDEFINED_DISPLAY_M5CORE2
|
||||
default 15 if LV_PREDEFINED_DISPLAY_M5STICKC
|
||||
default 18 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
|
||||
default 23 if LV_PREDEFINED_PINS_TKOALA
|
||||
|
@ -770,13 +758,13 @@ menu "LVGL TFT Display controller"
|
|||
default 19 if LV_PREDEFINED_DISPLAY_TTGO_CAMERA_PLUS
|
||||
default 13 if LV_PREDEFINED_DISPLAY_WT32_SC01
|
||||
default 13
|
||||
|
||||
help
|
||||
Configure the display MOSI pin here.
|
||||
|
||||
config LV_DISPLAY_USE_SPI_MISO
|
||||
bool "GPIO for MISO (Master In Slave Out)" if LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
default y if LV_PREDEFINED_PINS_TKOALA
|
||||
default y if LV_PREDEFINED_DISPLAY_M5CORE2
|
||||
help
|
||||
Enable the MISO signal to control the display. You can disable
|
||||
it when the display does not need MISO signal to be controlled.
|
||||
|
@ -784,10 +772,8 @@ menu "LVGL TFT Display controller"
|
|||
config LV_DISP_SPI_MISO
|
||||
int "GPIO for MISO (Master In Slave Out)" if LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
depends on LV_DISPLAY_USE_SPI_MISO
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 19 if LV_PREDEFINED_PINS_TKOALA
|
||||
default 38 if LV_PREDEFINED_DISPLAY_M5CORE2
|
||||
default 0
|
||||
|
||||
help
|
||||
|
@ -805,9 +791,6 @@ menu "LVGL TFT Display controller"
|
|||
config LV_DISP_SPI_IO2
|
||||
int "GPIO for Quad SPI IO2/WP" if LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
|
||||
range -1 39 if IDF_TARGET_ESP32
|
||||
range -1 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 22 if LV_PREDEFINED_PINS_TKOALA && LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
|
||||
default -1
|
||||
help
|
||||
|
@ -816,9 +799,6 @@ menu "LVGL TFT Display controller"
|
|||
config LV_DISP_SPI_IO3
|
||||
int "GPIO for Quad SPI IO3/HD" if LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
|
||||
range -1 39 if IDF_TARGET_ESP32
|
||||
range -1 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 21 if LV_PREDEFINED_PINS_TKOALA && LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
|
||||
default -1
|
||||
help
|
||||
|
@ -826,10 +806,8 @@ menu "LVGL TFT Display controller"
|
|||
|
||||
config LV_DISP_SPI_CLK
|
||||
int "GPIO for CLK (SCK / Serial Clock)" if LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 18 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
|
||||
default 18 if LV_PREDEFINED_DISPLAY_M5CORE2
|
||||
default 13 if LV_PREDEFINED_DISPLAY_M5STICKC
|
||||
default 18 if LV_PREDEFINED_DISPLAY_ATAG
|
||||
default 19 if LV_PREDEFINED_DISPLAY_WROVER4
|
||||
|
@ -853,11 +831,9 @@ menu "LVGL TFT Display controller"
|
|||
config LV_DISP_SPI_CS
|
||||
int "GPIO for CS (Slave Select)" if LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
depends on LV_DISPLAY_USE_SPI_CS
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 5 if LV_PREDEFINED_PINS_38V1
|
||||
default 14 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
|
||||
default 5 if LV_PREDEFINED_DISPLAY_M5CORE2
|
||||
default 5 if LV_PREDEFINED_DISPLAY_M5STICKC
|
||||
default 22 if LV_PREDEFINED_DISPLAY_WROVER4
|
||||
default 15 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
|
||||
|
@ -880,13 +856,11 @@ menu "LVGL TFT Display controller"
|
|||
|
||||
config LV_DISP_PIN_DC
|
||||
int "GPIO for DC (Data / Command)" if LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
depends on LV_DISPLAY_USE_DC
|
||||
default 19 if LV_PREDEFINED_PINS_38V1
|
||||
default 17 if LV_PREDEFINED_PINS_38V4
|
||||
default 27 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
|
||||
default 15 if LV_PREDEFINED_DISPLAY_M5CORE2
|
||||
default 23 if LV_PREDEFINED_DISPLAY_M5STICKC
|
||||
default 21 if LV_PREDEFINED_DISPLAY_WROVER4
|
||||
default 21 if LV_PREDEFINED_DISPLAY_WT32_SC01
|
||||
|
@ -900,11 +874,22 @@ menu "LVGL TFT Display controller"
|
|||
help
|
||||
Configure the display DC pin here.
|
||||
|
||||
config LV_DISP_USE_RST
|
||||
bool "Use a GPIO for resetting the display" if LV_TFT_DISPLAY_PROTOCOL_SPI
|
||||
default n if LV_PREDEFINED_DISPLAY_M5CORE2
|
||||
default y
|
||||
help
|
||||
Enable display reset control. Set this if the reset pin of the
|
||||
display is connected to the host. If this is not set, then it is
|
||||
the user's responsibility to ensure that the display is reset
|
||||
before initialisation.
|
||||
You may want to disable this option because the reset pin is not
|
||||
connected, or is connected to an external component such as the
|
||||
power management IC.
|
||||
|
||||
config LV_DISP_PIN_RST
|
||||
int "GPIO for Reset" if LV_TFT_DISPLAY_PROTOCOL_SPI && !LV_DISP_ST7789_SOFT_RESET
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
depends on LV_DISP_USE_RST
|
||||
default 18 if LV_PREDEFINED_PINS_38V1
|
||||
default 25 if LV_PREDEFINED_PINS_38V4
|
||||
default 33 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
|
||||
|
@ -923,84 +908,103 @@ menu "LVGL TFT Display controller"
|
|||
|
||||
config LV_DISP_PIN_BUSY
|
||||
int "GPIO for Busy" if LV_TFT_DISPLAY_CONTROLLER_IL3820 || LV_TFT_DISPLAY_CONTROLLER_JD79653A || LV_TFT_DISPLAY_CONTROLLER_UC8151D
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 35 if LV_TFT_DISPLAY_CONTROLLER_IL3820 || LV_TFT_DISPLAY_CONTROLLER_JD79653A || LV_TFT_DISPLAY_CONTROLLER_UC8151D
|
||||
default 35
|
||||
default 35 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2
|
||||
default 21 if IDF_TARGET_ESP32C3
|
||||
|
||||
help
|
||||
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 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
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
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_DISP_PIN_SDA
|
||||
int "GPIO for I2C SDA" if LV_TFT_DISPLAY_PROTOCOL_I2C
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 5 if LV_PREDEFINED_DISPLAY_WEMOS_LOLIN
|
||||
default 5
|
||||
|
||||
help
|
||||
Configure the I2C SDA pin here.
|
||||
|
||||
config LV_DISP_PIN_SCL
|
||||
int "GPIO for I2C SCL" if LV_TFT_DISPLAY_PROTOCOL_I2C
|
||||
range 0 39 if IDF_TARGET_ESP32
|
||||
range 0 43 if IDF_TARGET_ESP32S2
|
||||
|
||||
default 4 if LV_PREDEFINED_DISPLAY_WEMOS_LOLIN
|
||||
default 4
|
||||
|
||||
help
|
||||
Configure the I2C SCL pin here.
|
||||
|
||||
endmenu
|
||||
|
||||
choice
|
||||
prompt "Select an I2C port for the display"
|
||||
default LV_I2C_DISPLAY_PORT_0
|
||||
depends on LV_I2C_DISPLAY
|
||||
|
||||
config LV_I2C_DISPLAY_PORT_0
|
||||
bool
|
||||
prompt "I2C port 0"
|
||||
help
|
||||
I2C is shared peripheral managed by I2C Manager. In order to configure I2C Manager (pinout, etc.) see menu
|
||||
Component config->I2C Port Settings.
|
||||
|
||||
config LV_I2C_DISPLAY_PORT_1
|
||||
bool
|
||||
prompt "I2C port 1"
|
||||
help
|
||||
I2C is shared peripheral managed by I2C Manager. In order to configure I2C Manager (pinout, etc.) see menu
|
||||
Component config->I2C Port Settings.
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
default LV_DISP_BACKLIGHT_SWITCH
|
||||
prompt "Backlight Control" if \
|
||||
(! ( LV_TFT_DISPLAY_CONTROLLER_SH1107 || LV_TFT_DISPLAY_CONTROLLER_SSD1306 ) )
|
||||
|
||||
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 -1
|
||||
|
||||
help
|
||||
Configure the display BCLK (LED) pin here.
|
||||
|
||||
config LV_I2C
|
||||
bool
|
||||
default y if LV_I2C_DISPLAY
|
||||
|
||||
config LV_I2C_DISPLAY_PORT
|
||||
int
|
||||
default 1 if LV_I2C_DISPLAY_PORT_1
|
||||
default 0
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
|
||||
#include "disp_driver.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
|
||||
ili9341_init();
|
||||
|
@ -21,7 +23,7 @@ void disp_driver_init(void)
|
|||
st7735s_init();
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357
|
||||
hx8357_init();
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9486
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9486
|
||||
ili9486_init();
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SH1107
|
||||
sh1107_init();
|
||||
|
@ -34,11 +36,40 @@ void disp_driver_init(void)
|
|||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_RA8875
|
||||
ra8875_init();
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_GC9A01
|
||||
GC9A01_init();
|
||||
GC9A01_init();
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_JD79653A
|
||||
jd79653a_init();
|
||||
jd79653a_init();
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_UC8151D
|
||||
uc8151d_init();
|
||||
uc8151d_init();
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9163C
|
||||
ili9163c_init();
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_PCD8544
|
||||
pcd8544_init();
|
||||
#endif
|
||||
|
||||
// We still use menuconfig for these settings
|
||||
// It will be set up during runtime in the future
|
||||
#if (defined(CONFIG_LV_DISP_BACKLIGHT_SWITCH) || defined(CONFIG_LV_DISP_BACKLIGHT_PWM))
|
||||
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
|
||||
};
|
||||
disp_backlight_h bckl_handle = disp_backlight_new(&bckl_config);
|
||||
disp_backlight_set(bckl_handle, 100);
|
||||
return bckl_handle;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -76,6 +107,10 @@ void disp_driver_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t *
|
|||
jd79653a_lv_fb_flush(drv, area, color_map);
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_UC8151D
|
||||
uc8151d_lv_fb_flush(drv, area, color_map);
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9163C
|
||||
ili9163c_flush(drv, area, color_map);
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_PCD8544
|
||||
pcd8544_flush(drv, area, color_map);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -91,11 +126,13 @@ void disp_driver_rounder(lv_disp_drv_t * disp_drv, lv_area_t * area)
|
|||
jd79653a_lv_rounder_cb(disp_drv, area);
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_UC8151D
|
||||
uc8151d_lv_rounder_cb(disp_drv, area);
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_PCD8544
|
||||
pcd8544_rounder(disp_drv, area);
|
||||
#endif
|
||||
}
|
||||
|
||||
void disp_driver_set_px(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
#if defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SSD1306
|
||||
ssd1306_set_px_cb(disp_drv, buf, buf_w, x, y, color, opa);
|
||||
|
@ -107,5 +144,7 @@ void disp_driver_set_px(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_
|
|||
jd79653a_lv_set_fb_cb(disp_drv, buf, buf_w, x, y, color, opa);
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_UC8151D
|
||||
uc8151d_lv_set_fb_cb(disp_drv, buf, buf_w, x, y, color, opa);
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_PCD8544
|
||||
pcd8544_set_px_cb(disp_drv, buf, buf_w, x, y, color, opa);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -50,6 +50,10 @@ extern "C" {
|
|||
#include "jd79653a.h"
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_UC8151D
|
||||
#include "uc8151d.h"
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9163C
|
||||
#include "ili9163c.h"
|
||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_PCD8544
|
||||
#include "pcd8544.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
|
@ -65,7 +69,7 @@ extern "C" {
|
|||
**********************/
|
||||
|
||||
/* Initialize display */
|
||||
void disp_driver_init(void);
|
||||
void *disp_driver_init(void);
|
||||
|
||||
/* Display flush callback */
|
||||
void disp_driver_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
|
||||
|
|
|
@ -310,7 +310,12 @@ static void IRAM_ATTR spi_ready(spi_transaction_t *trans)
|
|||
disp = lv_refr_get_disp_refreshing();
|
||||
#endif
|
||||
|
||||
#if LVGL_VERSION_MAJOR < 8
|
||||
lv_disp_flush_ready(&disp->driver);
|
||||
#else
|
||||
lv_disp_flush_ready(disp->driver);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if (chained_post_cb) {
|
||||
|
|
107
lvgl_tft/esp_lcd_backlight.c
Normal file
107
lvgl_tft/esp_lcd_backlight.c
Normal file
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* @file esp_lcd_backlight.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "esp_lcd_backlight.h"
|
||||
#include "driver/ledc.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_log.h"
|
||||
#include "soc/ledc_periph.h" // to invert LEDC output on IDF version < v4.3
|
||||
|
||||
typedef struct {
|
||||
bool pwm_control; // true: LEDC is used, false: GPIO is used
|
||||
int index; // Either GPIO or LEDC channel
|
||||
} disp_backlight_t;
|
||||
|
||||
static const char *TAG = "disp_backlight";
|
||||
|
||||
disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config)
|
||||
{
|
||||
// Check input parameters
|
||||
if (config == 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));
|
||||
if (bckl_dev == NULL){
|
||||
ESP_LOGW(TAG, "Not enough memory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (config->pwm_control){
|
||||
// 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));
|
||||
gpio_matrix_out(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));
|
||||
gpio_matrix_out(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert, false);
|
||||
}
|
||||
|
||||
return (disp_backlight_h)bckl_dev;
|
||||
}
|
||||
|
||||
void disp_backlight_set(disp_backlight_h bckl, int brightness_percent)
|
||||
{
|
||||
// Check input paramters
|
||||
if (bckl == NULL)
|
||||
return;
|
||||
if (brightness_percent > 100)
|
||||
brightness_percent = 100;
|
||||
if (brightness_percent < 0)
|
||||
brightness_percent = 0;
|
||||
|
||||
disp_backlight_t *bckl_dev = (disp_backlight_t *) bckl;
|
||||
ESP_LOGI(TAG, "Setting LCD backlight: %d%%", brightness_percent);
|
||||
|
||||
if (bckl_dev->pwm_control) {
|
||||
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);
|
||||
}
|
67
lvgl_tft/esp_lcd_backlight.h
Normal file
67
lvgl_tft/esp_lcd_backlight.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* @file esp_lcd_backlight.h
|
||||
*/
|
||||
|
||||
#ifndef ESP_LCD_BACKLIGHT_H
|
||||
#define ESP_LCD_BACKLIGHT_H
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* extern "C" */
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* @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
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*ESP_LCD_BACKLIGHT_H*/
|
|
@ -160,21 +160,24 @@ static uint8_t displayType = HX8357D;
|
|||
void hx8357_init(void)
|
||||
{
|
||||
//Initialize non-SPI GPIOs
|
||||
gpio_reset_pin(HX8357_DC);
|
||||
gpio_reset_pin(HX8357_DC);
|
||||
gpio_set_direction(HX8357_DC, GPIO_MODE_OUTPUT);
|
||||
gpio_reset_pin(HX8357_RST);
|
||||
gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if HX8357_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(HX8357_BCKL);
|
||||
gpio_set_direction(HX8357_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
#if HX8357_USE_RST
|
||||
gpio_reset_pin(HX8357_RST);
|
||||
gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
//Reset the display
|
||||
gpio_set_level(HX8357_RST, 0);
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(HX8357_RST, 1);
|
||||
vTaskDelay(120 / portTICK_PERIOD_MS);
|
||||
#endif
|
||||
|
||||
#if HX8357_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(HX8357_BCKL);
|
||||
gpio_set_direction(HX8357_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "Initialization.");
|
||||
|
||||
|
@ -205,8 +208,6 @@ void hx8357_init(void)
|
|||
#else
|
||||
hx8357_send_cmd(HX8357_INVOFF);
|
||||
#endif
|
||||
|
||||
hx8357_enable_backlight(true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -243,23 +244,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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
r = r & 3; // can't be higher than 3
|
||||
|
|
|
@ -35,18 +35,10 @@ extern "C" {
|
|||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define HX8357_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define HX8357_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define HX8357_BCKL CONFIG_LV_DISP_PIN_BCKL
|
||||
|
||||
#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
|
||||
#define HX8357_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define HX8357_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define HX8357_USE_RST CONFIG_LV_DISP_USE_RST
|
||||
#define HX8357_INVERT_COLORS CONFIG_LV_INVERT_COLORS
|
||||
|
||||
|
||||
/*******************
|
||||
|
@ -135,7 +127,6 @@ extern "C" {
|
|||
|
||||
void hx8357_init(void);
|
||||
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);
|
||||
|
||||
/**********************
|
||||
|
|
|
@ -73,9 +73,9 @@ static uint8_t il3820_lut_initial[] = {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
static uint8_t il3820_lut_default[] = {
|
||||
0x10, 0x18, 0x18, 0x08, 0x18, 0x18,
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x10, 0x18, 0x18, 0x08, 0x18, 0x18,
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x13, 0x14, 0x44, 0x12,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
@ -113,7 +113,7 @@ void il3820_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_m
|
|||
uint8_t *buffer = (uint8_t*) color_map;
|
||||
uint16_t x_addr_counter = 0;
|
||||
uint16_t y_addr_counter = 0;
|
||||
|
||||
|
||||
/* Configure entry mode */
|
||||
il3820_write_cmd(IL3820_CMD_ENTRY_MODE, &il3820_scan_mode, 1);
|
||||
|
||||
|
@ -131,7 +131,7 @@ void il3820_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_m
|
|||
il3820_set_cursor(x_addr_counter, y_addr_counter);
|
||||
|
||||
il3820_send_cmd(IL3820_CMD_WRITE_RAM);
|
||||
|
||||
|
||||
/* Write the pixel data to graphic RAM, linelen bytes at the time. */
|
||||
for(size_t row = 0; row <= (EPD_PANEL_HEIGHT - 1); row++){
|
||||
il3820_send_data(buffer, linelen);
|
||||
|
@ -139,7 +139,7 @@ void il3820_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_m
|
|||
}
|
||||
|
||||
il3820_set_window(0, EPD_PANEL_WIDTH - 1, 0, EPD_PANEL_HEIGHT - 1);
|
||||
|
||||
|
||||
il3820_update_display();
|
||||
|
||||
/* IMPORTANT!!!
|
||||
|
@ -152,7 +152,7 @@ void il3820_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_m
|
|||
* BIT_SET(byte_index, bit_index) clears the bit_index pixel at byte_index of
|
||||
* the display buffer.
|
||||
* BIT_CLEAR(byte_index, bit_index) sets the bit_index pixel at the byte_index
|
||||
* of the display buffer. */
|
||||
* of the display buffer. */
|
||||
void il3820_set_px_cb(lv_disp_drv_t * disp_drv, uint8_t* buf,
|
||||
lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
|
@ -198,20 +198,24 @@ void il3820_init(void)
|
|||
/* Initialize non-SPI GPIOs */
|
||||
gpio_reset_pin(IL3820_DC_PIN);
|
||||
gpio_set_direction(IL3820_DC_PIN, GPIO_MODE_OUTPUT);
|
||||
gpio_reset_pin(IL3820_RST_PIN);
|
||||
gpio_set_direction(IL3820_RST_PIN, GPIO_MODE_OUTPUT);
|
||||
|
||||
gpio_reset_pin(IL3820_BUSY_PIN);
|
||||
gpio_set_direction(IL3820_BUSY_PIN, GPIO_MODE_INPUT);
|
||||
|
||||
#if IL3820_USE_RST
|
||||
gpio_reset_pin(IL3820_RST_PIN);
|
||||
gpio_set_direction(IL3820_RST_PIN, GPIO_MODE_OUTPUT);
|
||||
|
||||
/* Harware reset */
|
||||
gpio_set_level( IL3820_RST_PIN, 0);
|
||||
vTaskDelay(IL3820_RESET_DELAY / portTICK_PERIOD_MS);
|
||||
gpio_set_level( IL3820_RST_PIN, 1);
|
||||
vTaskDelay(IL3820_RESET_DELAY / portTICK_PERIOD_MS);
|
||||
#endif
|
||||
|
||||
/* Software reset */
|
||||
il3820_write_cmd(IL3820_CMD_SW_RESET, NULL, 0);
|
||||
|
||||
|
||||
/* Busy wait for the BUSY signal to go low */
|
||||
il3820_waitbusy(IL3820_WAIT);
|
||||
|
||||
|
@ -239,10 +243,10 @@ void il3820_init(void)
|
|||
|
||||
// allow partial updates now
|
||||
il3820_partial = true;
|
||||
|
||||
|
||||
/* Update LUT */
|
||||
il3820_write_cmd(IL3820_CMD_UPDATE_LUT, il3820_lut_default, sizeof(il3820_lut_default));
|
||||
|
||||
|
||||
/* Clear control memory and update */
|
||||
il3820_clear_cntlr_mem(IL3820_CMD_WRITE_RAM, true);
|
||||
}
|
||||
|
@ -251,10 +255,10 @@ void il3820_init(void)
|
|||
void il3820_sleep_in(void)
|
||||
{
|
||||
uint8_t data[] = {0x01};
|
||||
|
||||
|
||||
/* Wait for the BUSY signal to go low */
|
||||
il3820_waitbusy(IL3820_WAIT);
|
||||
|
||||
|
||||
il3820_write_cmd(IL3820_CMD_SLEEP_MODE, data, 1);
|
||||
}
|
||||
|
||||
|
@ -264,15 +268,15 @@ static void il3820_waitbusy(int wait_ms)
|
|||
int i = 0;
|
||||
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS); // 10ms delay
|
||||
|
||||
|
||||
for(i = 0; i < (wait_ms * 10); i++) {
|
||||
if(gpio_get_level(IL3820_BUSY_PIN) != IL3820_BUSY_LEVEL) {
|
||||
if(gpio_get_level(IL3820_BUSY_PIN) != IL3820_BUSY_LEVEL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
|
||||
ESP_LOGE( TAG, "busy exceeded %dms", i*10 );
|
||||
}
|
||||
|
||||
|
@ -288,10 +292,10 @@ static inline void il3820_data_mode(void)
|
|||
gpio_set_level(IL3820_DC_PIN, 1);
|
||||
}
|
||||
|
||||
static inline void il3820_write_cmd(uint8_t cmd, uint8_t *data, size_t len)
|
||||
static inline void il3820_write_cmd(uint8_t cmd, uint8_t *data, size_t len)
|
||||
{
|
||||
disp_wait_for_pending_transactions();
|
||||
|
||||
|
||||
il3820_command_mode();
|
||||
disp_spi_send_data(&cmd, 1);
|
||||
|
||||
|
@ -302,10 +306,10 @@ static inline void il3820_write_cmd(uint8_t cmd, uint8_t *data, size_t len)
|
|||
}
|
||||
|
||||
/* Send cmd to the display */
|
||||
static inline void il3820_send_cmd(uint8_t cmd)
|
||||
static inline void il3820_send_cmd(uint8_t cmd)
|
||||
{
|
||||
disp_wait_for_pending_transactions();
|
||||
|
||||
|
||||
il3820_command_mode();
|
||||
disp_spi_send_data(&cmd, 1);
|
||||
}
|
||||
|
@ -314,14 +318,14 @@ static inline void il3820_send_cmd(uint8_t cmd)
|
|||
static void il3820_send_data(uint8_t *data, uint16_t length)
|
||||
{
|
||||
disp_wait_for_pending_transactions();
|
||||
|
||||
|
||||
il3820_data_mode();
|
||||
disp_spi_send_colors(data, length);
|
||||
}
|
||||
|
||||
/* Specify the start/end positions of the window address in the X and Y
|
||||
* directions by an address unit.
|
||||
*
|
||||
*
|
||||
* @param sx: X Start position.
|
||||
* @param ex: X End position.
|
||||
* @param ys: Y Start position.
|
||||
|
@ -330,7 +334,7 @@ static void il3820_send_data(uint8_t *data, uint16_t length)
|
|||
static inline void il3820_set_window( uint16_t sx, uint16_t ex, uint16_t ys, uint16_t ye)
|
||||
{
|
||||
uint8_t tmp[4] = {0};
|
||||
|
||||
|
||||
tmp[0] = sx / 8;
|
||||
tmp[1] = ex / 8;
|
||||
|
||||
|
@ -378,7 +382,7 @@ static void il3820_update_display(void)
|
|||
} else {
|
||||
tmp = (IL3820_CTRL2_ENABLE_CLK | IL3820_CTRL2_ENABLE_ANALOG | IL3820_CTRL2_TO_PATTERN);
|
||||
}
|
||||
|
||||
|
||||
il3820_write_cmd(IL3820_CMD_UPDATE_CTRL2, &tmp, 1);
|
||||
|
||||
il3820_write_cmd(IL3820_CMD_MASTER_ACTIVATION, NULL, 0);
|
||||
|
@ -394,10 +398,10 @@ static void il3820_clear_cntlr_mem(uint8_t ram_cmd, bool update)
|
|||
/* Arrays used by SPI must be word alligned */
|
||||
WORD_ALIGNED_ATTR uint8_t clear_page[IL3820_COLUMNS];
|
||||
memset(clear_page, 0xff, sizeof clear_page);
|
||||
|
||||
|
||||
/* Configure entry mode */
|
||||
il3820_write_cmd(IL3820_CMD_ENTRY_MODE, &il3820_scan_mode, 1);
|
||||
|
||||
|
||||
/* Configure the window */
|
||||
il3820_set_window(0, EPD_PANEL_WIDTH - 1, 0, EPD_PANEL_HEIGHT - 1);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ extern "C"
|
|||
|
||||
#define IL3820_DC_PIN CONFIG_LV_DISP_PIN_DC
|
||||
#define IL3820_RST_PIN CONFIG_LV_DISP_PIN_RST
|
||||
#define IL3820_USE_RST CONFIG_LV_DISP_USE_RST
|
||||
#define IL3820_BUSY_PIN CONFIG_LV_DISP_PIN_BUSY
|
||||
#define IL3820_BUSY_LEVEL 1
|
||||
|
||||
|
|
248
lvgl_tft/ili9163c.c
Normal file
248
lvgl_tft/ili9163c.c
Normal file
|
@ -0,0 +1,248 @@
|
|||
/**
|
||||
* @file ILI9163C.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "ili9163c.h"
|
||||
#include "disp_spi.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define TAG "ILI9163C"
|
||||
|
||||
// ILI9163C specific commands used in init
|
||||
#define ILI9163C_NOP 0x00
|
||||
#define ILI9163C_SWRESET 0x01
|
||||
#define ILI9163C_RDDID 0x04
|
||||
#define ILI9163C_RDDST 0x09
|
||||
|
||||
#define ILI9163C_SLPIN 0x10
|
||||
#define ILI9163C_SLPOUT 0x11
|
||||
#define ILI9163C_PTLON 0x12
|
||||
#define ILI9163C_NORON 0x13
|
||||
|
||||
#define ILI9163C_INVOFF 0x20
|
||||
#define ILI9163C_INVON 0x21
|
||||
#define ILI9163C_CMD_GAMST 0x26
|
||||
#define ILI9163C_DISPOFF 0x28
|
||||
#define ILI9163C_DISPON 0x29
|
||||
#define ILI9163C_CASET 0x2A
|
||||
#define ILI9163C_RASET 0x2B
|
||||
#define ILI9163C_RAMWR 0x2C
|
||||
#define ILI9163C_COLORSET 0x2D
|
||||
#define ILI9163C_RAMRD 0x2E
|
||||
|
||||
#define ILI9163C_PTLAR 0x30
|
||||
#define ILI9163C_VSCRDEF 0x33
|
||||
#define ILI9163C_COLMOD 0x3A
|
||||
#define ILI9163C_MADCTL 0x36
|
||||
#define ILI9163C_VSCRSADD 0x37
|
||||
|
||||
#define ILI9163C_FRMCTR1 0xB1
|
||||
#define ILI9163C_FRMCTR2 0xB2
|
||||
#define ILI9163C_FRMCTR3 0xB3
|
||||
#define ILI9163C_INVCTR 0xB4
|
||||
#define ILI9163C_DISSET5 0xB6
|
||||
#define ILI9163C_SDDC 0xB7
|
||||
|
||||
#define ILI9163C_PWCTR1 0xC0
|
||||
#define ILI9163C_PWCTR2 0xC1
|
||||
#define ILI9163C_PWCTR3 0xC2
|
||||
#define ILI9163C_PWCTR4 0xC3
|
||||
#define ILI9163C_PWCTR5 0xC4
|
||||
#define ILI9163C_VMCTR1 0xC5
|
||||
#define ILI9163C_VMCOFFS 0xC7
|
||||
|
||||
#define ILI9163C_GAMCTL 0xF2
|
||||
|
||||
#define ILI9163C_GMCTRP1 0xE0
|
||||
#define ILI9163C_GMCTRN1 0xE1
|
||||
|
||||
#define ST77XX_MADCTL_MY 0x80
|
||||
#define ST77XX_MADCTL_MX 0x40
|
||||
#define ST77XX_MADCTL_MV 0x20 #define
|
||||
#define ST77XX_MADCTL_ML 0x10
|
||||
#define ST77XX_MADCTL_RGB 0x00
|
||||
#define ST77XX_MADCTL_BGR 0x08
|
||||
|
||||
/**********************
|
||||
* 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 ili9163c_set_orientation(uint8_t orientation);
|
||||
|
||||
static void ili9163c_send_cmd(uint8_t cmd);
|
||||
static void ili9163c_send_data(void *data, uint16_t length);
|
||||
static void ili9163c_send_color(void *data, uint16_t length);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void ili9163c_init(void)
|
||||
{
|
||||
ESP_LOGD(TAG, "Init");
|
||||
|
||||
lcd_init_cmd_t ili_init_cmds[] = {
|
||||
{ILI9163C_SWRESET, {0}, 0x80}, // Software reset, 0 args, w/delay 120ms
|
||||
{ILI9163C_SLPOUT, {0}, 0x80}, // Out of sleep mode, 0 args, w/delay 5ms
|
||||
{ILI9163C_CMD_GAMST, {0x04}, 1}, // Gamma Curve
|
||||
{ILI9163C_FRMCTR1, {0x0C, 0x14}, 2}, // Frame rate ctrl - normal mode
|
||||
{ILI9163C_INVCTR, {0x07}, 1}, // Display inversion ctrl, 1 arg, no delay:No inversion
|
||||
{ILI9163C_PWCTR1, {0x0C, 0x05}, 2}, // Power control, 2 args, no delay
|
||||
{ILI9163C_PWCTR2, {0x02}, 1}, // Power control, 1 arg
|
||||
{ILI9163C_PWCTR3, {0x02}, 1}, // Power control, 1 arg
|
||||
{ILI9163C_VMCTR1, {0x20, 0x55}, 2}, // Power control, 1 arg, no delay:
|
||||
{ILI9163C_VMCOFFS, {0x40}, 1}, // VCOM Offset
|
||||
#if ILI9163C_INVERT_COLORS == 1
|
||||
{ILI9163C_INVON, {0}, 0}, // set inverted mode
|
||||
#else
|
||||
{ILI9163C_INVOFF, {0}, 0}, // set non-inverted mode
|
||||
#endif
|
||||
{ILI9163C_COLMOD, {0x5}, 1}, // set color mode, 1 arg, no delay: 16-bit color
|
||||
{ILI9163C_SDDC, {0}, 1}, // set source driver direction control
|
||||
{ILI9163C_GAMCTL, {0x01}, 1}, // set source driver direction control
|
||||
{ILI9163C_GMCTRP1, {0x36, 0x29, 0x12, 0x22, 0x1C, 0x15, 0x42, 0xB7, 0x2F, 0x13, 0x12, 0x0A, 0x11, 0x0B, 0x06}, 16}, // 16 args, no delay:
|
||||
{ILI9163C_GMCTRN1, {0x09, 0x16, 0x2D, 0x0D, 0x13, 0x15, 0x40, 0x48, 0x53, 0x0C, 0x1D, 0x25, 0x2E, 0x34, 0x39}, 16}, // 16 args, no delay:
|
||||
{ILI9163C_NORON, {0}, 0x80}, // Normal display on, no args, w/delay 10 ms delay
|
||||
{ILI9163C_DISPON, {0}, 0x80}, // Main screen turn on, no args w/delay 100 ms delay
|
||||
{0, {0}, 0xff}
|
||||
};
|
||||
|
||||
//Initialize non-SPI GPIOs
|
||||
gpio_reset_pin(ILI9163C_DC);
|
||||
gpio_set_direction(ILI9163C_DC, GPIO_MODE_OUTPUT);
|
||||
gpio_reset_pin(ILI9163C_RST);
|
||||
gpio_set_direction(ILI9163C_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
//Reset the display
|
||||
gpio_set_level(ILI9163C_RST, 0);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
gpio_set_level(ILI9163C_RST, 1);
|
||||
vTaskDelay(150 / portTICK_RATE_MS);
|
||||
|
||||
//Send all the commands
|
||||
uint16_t cmd = 0;
|
||||
while (ili_init_cmds[cmd].databytes != 0xff)
|
||||
{
|
||||
ili9163c_send_cmd(ili_init_cmds[cmd].cmd);
|
||||
ili9163c_send_data(ili_init_cmds[cmd].data, ili_init_cmds[cmd].databytes & 0x1F);
|
||||
if (ili_init_cmds[cmd].databytes & 0x80)
|
||||
{
|
||||
vTaskDelay(150 / portTICK_RATE_MS);
|
||||
}
|
||||
cmd++;
|
||||
}
|
||||
|
||||
ili9163c_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
|
||||
}
|
||||
|
||||
void ili9163c_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
|
||||
{
|
||||
uint8_t data[4];
|
||||
|
||||
/*Column addresses*/
|
||||
ili9163c_send_cmd(ILI9163C_CASET);
|
||||
data[0] = (area->x1 >> 8) & 0xFF;
|
||||
data[1] = area->x1 & 0xFF;
|
||||
data[2] = (area->x2 >> 8) & 0xFF;
|
||||
data[3] = area->x2 & 0xFF;
|
||||
ili9163c_send_data(data, 4);
|
||||
|
||||
/*Page addresses*/
|
||||
ili9163c_send_cmd(ILI9163C_RASET);
|
||||
data[0] = (area->y1 >> 8) & 0xFF;
|
||||
data[1] = area->y1 & 0xFF;
|
||||
data[2] = (area->y2 >> 8) & 0xFF;
|
||||
data[3] = area->y2 & 0xFF;
|
||||
ili9163c_send_data(data, 4);
|
||||
|
||||
/*Memory write*/
|
||||
ili9163c_send_cmd(ILI9163C_RAMWR);
|
||||
|
||||
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
|
||||
|
||||
ili9163c_send_color((void *)color_map, size * 2);
|
||||
}
|
||||
|
||||
void ili9163c_sleep_in()
|
||||
{
|
||||
uint8_t data[] = {0x08};
|
||||
ili9163c_send_cmd(ILI9163C_SLPIN);
|
||||
ili9163c_send_data(&data, 1);
|
||||
}
|
||||
|
||||
void ili9163c_sleep_out()
|
||||
{
|
||||
uint8_t data[] = {0x08};
|
||||
ili9163c_send_cmd(ILI9163C_SLPOUT);
|
||||
ili9163c_send_data(&data, 1);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void ili9163c_send_cmd(uint8_t cmd)
|
||||
{
|
||||
disp_wait_for_pending_transactions();
|
||||
gpio_set_level(ILI9163C_DC, 0); /*Command mode*/
|
||||
disp_spi_send_data(&cmd, 1);
|
||||
}
|
||||
|
||||
static void ili9163c_send_data(void *data, uint16_t length)
|
||||
{
|
||||
disp_wait_for_pending_transactions();
|
||||
gpio_set_level(ILI9163C_DC, 1); /*Data mode*/
|
||||
disp_spi_send_data(data, length);
|
||||
}
|
||||
|
||||
static void ili9163c_send_color(void *data, uint16_t length)
|
||||
{
|
||||
disp_wait_for_pending_transactions();
|
||||
gpio_set_level(ILI9163C_DC, 1); /*Data mode*/
|
||||
disp_spi_send_colors(data, length);
|
||||
}
|
||||
|
||||
static void ili9163c_set_orientation(uint8_t orientation)
|
||||
{
|
||||
assert(orientation < 4);
|
||||
|
||||
const char *orientation_str[] = {
|
||||
"PORTRAIT", "PORTRAIT_INVERTED", "LANDSCAPE", "LANDSCAPE_INVERTED"};
|
||||
|
||||
ESP_LOGD(TAG, "Display orientation: %s", orientation_str[orientation]);
|
||||
|
||||
uint8_t data[] = {0x48, 0x88, 0xA8, 0x68};
|
||||
|
||||
ili9163c_send_cmd(ILI9163C_MADCTL);
|
||||
ili9163c_send_data((void *)&data[orientation], 1);
|
||||
}
|
54
lvgl_tft/ili9163c.h
Normal file
54
lvgl_tft/ili9163c.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* @file lv_templ.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ILI9163C_H
|
||||
#define ILI9163C_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
|
||||
#include "lvgl.h"
|
||||
#else
|
||||
#include "lvgl/lvgl.h"
|
||||
#endif
|
||||
#include "../lvgl_helpers.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define ILI9163C_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define ILI9163C_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define ILI9163C_INVERT_COLORS CONFIG_LV_INVERT_COLORS
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
void ili9163c_init(void);
|
||||
void ili9163c_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map);
|
||||
void ili9163c_sleep_in(void);
|
||||
void ili9163c_sleep_out(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*ILI9163C_H*/
|
|
@ -80,31 +80,25 @@ void ili9341_init(void)
|
|||
{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
|
||||
gpio_reset_pin(ILI9341_DC);
|
||||
gpio_reset_pin(ILI9341_DC);
|
||||
gpio_set_direction(ILI9341_DC, GPIO_MODE_OUTPUT);
|
||||
gpio_reset_pin(ILI9341_RST);
|
||||
|
||||
#if ILI9341_USE_RST
|
||||
gpio_reset_pin(ILI9341_RST);
|
||||
gpio_set_direction(ILI9341_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if ILI9341_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(ILI9341_BCKL);
|
||||
gpio_set_direction(ILI9341_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
//Reset the display
|
||||
gpio_set_level(ILI9341_RST, 0);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(ILI9341_RST, 1);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
#endif
|
||||
|
||||
#if ILI9341_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(ILI9341_BCKL);
|
||||
gpio_set_direction(ILI9341_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "Initialization.");
|
||||
|
||||
|
@ -119,9 +113,7 @@ void ili9341_init(void)
|
|||
cmd++;
|
||||
}
|
||||
|
||||
ili9341_enable_backlight(true);
|
||||
|
||||
ili9341_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
|
||||
ili9341_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
|
||||
|
||||
#if ILI9341_INVERT_COLORS == 1
|
||||
ili9341_send_cmd(0x21);
|
||||
|
@ -153,29 +145,10 @@ void ili9341_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
|
|||
|
||||
/*Memory write*/
|
||||
ili9341_send_cmd(0x2C);
|
||||
|
||||
|
||||
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
|
||||
|
||||
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()
|
||||
{
|
||||
uint8_t data[] = {0x08};
|
||||
|
@ -228,8 +201,10 @@ static void ili9341_set_orientation(uint8_t orientation)
|
|||
|
||||
#if defined CONFIG_LV_PREDEFINED_DISPLAY_M5STACK
|
||||
uint8_t data[] = {0x68, 0x68, 0x08, 0x08};
|
||||
#elif defined (CONFIG_LV_PREDEFINED_DISPLAY_M5CORE2)
|
||||
uint8_t data[] = {0x08, 0x88, 0x28, 0xE8};
|
||||
#elif defined (CONFIG_LV_PREDEFINED_DISPLAY_WROVER4)
|
||||
uint8_t data[] = {0x4C, 0x88, 0x28, 0xE8};
|
||||
uint8_t data[] = {0x6C, 0xEC, 0xCC, 0x4C};
|
||||
#elif defined (CONFIG_LV_PREDEFINED_DISPLAY_NONE)
|
||||
uint8_t data[] = {0x48, 0x88, 0x28, 0xE8};
|
||||
#endif
|
||||
|
|
|
@ -20,23 +20,15 @@ extern "C" {
|
|||
#else
|
||||
#include "lvgl/lvgl.h"
|
||||
#endif
|
||||
#include "../lvgl_helpers.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define ILI9341_DC CONFIG_LV_DISP_PIN_DC
|
||||
#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_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define ILI9341_USE_RST CONFIG_LV_DISP_USE_RST
|
||||
#define ILI9341_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define ILI9341_INVERT_COLORS CONFIG_LV_INVERT_COLORS
|
||||
|
||||
/**********************
|
||||
|
@ -49,7 +41,6 @@ extern "C" {
|
|||
|
||||
void ili9341_init(void);
|
||||
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_out(void);
|
||||
|
||||
|
|
|
@ -76,19 +76,22 @@ void ili9481_init(void)
|
|||
//Initialize non-SPI GPIOs
|
||||
gpio_reset_pin(ILI9481_DC);
|
||||
gpio_set_direction(ILI9481_DC, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if ILI9481_USE_RST
|
||||
gpio_reset_pin(ILI9481_RST);
|
||||
gpio_set_direction(ILI9481_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if ILI9481_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(ILI9481_BCKL);
|
||||
gpio_set_direction(ILI9481_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
|
||||
//Reset the display
|
||||
gpio_set_level(ILI9481_RST, 0);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(ILI9481_RST, 1);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
#endif
|
||||
|
||||
#if ILI9481_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(ILI9481_BCKL);
|
||||
gpio_set_direction(ILI9481_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "ILI9481 initialization.");
|
||||
|
||||
|
@ -107,8 +110,6 @@ void ili9481_init(void)
|
|||
cmd++;
|
||||
}
|
||||
|
||||
ili9481_enable_backlight(true);
|
||||
|
||||
ili9481_set_orientation(ILI9481_DISPLAY_ORIENTATION);
|
||||
}
|
||||
|
||||
|
@ -168,22 +169,6 @@ void ili9481_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
|
|||
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
|
||||
**********************/
|
||||
|
|
|
@ -25,19 +25,12 @@ extern "C" {
|
|||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define ILI9481_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define ILI9481_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define ILI9481_BCKL CONFIG_LV_DISP_PIN_BCKL
|
||||
|
||||
#define ILI9481_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
|
||||
#define ILI9481_INVERT_COLORS CONFIG_LV_INVERT_COLORS
|
||||
#define ILI9481_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define ILI9481_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define ILI9481_USE_RST CONFIG_LV_DISP_USE_RST
|
||||
#define ILI9481_INVERT_COLORS CONFIG_LV_INVERT_COLORS
|
||||
#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
|
||||
|
@ -117,7 +110,6 @@ extern "C" {
|
|||
|
||||
void ili9481_init(void);
|
||||
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
|
||||
|
|
|
@ -60,37 +60,30 @@ void ili9486_init(void)
|
|||
{0xE0, {0x0F, 0x1F, 0x1C, 0x0C, 0x0F, 0x08, 0x48, 0x98, 0x37, 0x0A, 0x13, 0x04, 0x11, 0x0D, 0x00}, 15},
|
||||
{0XE1, {0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75, 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00}, 15},
|
||||
{0x20, {0}, 0}, /* display inversion OFF */
|
||||
{0x36, {0x48}, 1},
|
||||
{0x29, {0}, 0x80}, /* display on */
|
||||
{0x36, {0x48}, 1},
|
||||
{0x29, {0}, 0x80}, /* display on */
|
||||
{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
|
||||
gpio_reset_pin(ILI9486_DC);
|
||||
gpio_reset_pin(ILI9486_DC);
|
||||
gpio_set_direction(ILI9486_DC, GPIO_MODE_OUTPUT);
|
||||
gpio_reset_pin(ILI9486_RST);
|
||||
gpio_set_direction(ILI9486_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if ILI9486_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(ILI9486_BCKL);
|
||||
gpio_set_direction(ILI9486_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
#if ILI9486_USE_RST
|
||||
gpio_reset_pin(ILI9486_RST);
|
||||
gpio_set_direction(ILI9486_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
//Reset the display
|
||||
gpio_set_level(ILI9486_RST, 0);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(ILI9486_RST, 1);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
#endif
|
||||
|
||||
#if ILI9486_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(ILI9486_BCKL);
|
||||
gpio_set_direction(ILI9486_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "ILI9486 Initialization.");
|
||||
|
||||
|
@ -105,9 +98,7 @@ void ili9486_init(void)
|
|||
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)
|
||||
|
@ -135,26 +126,10 @@ void ili9486_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
|
|||
ili9486_send_cmd(0x2C);
|
||||
|
||||
size = lv_area_get_width(area) * lv_area_get_height(area);
|
||||
|
||||
|
||||
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
|
||||
**********************/
|
||||
|
|
|
@ -25,17 +25,10 @@ extern "C" {
|
|||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define ILI9486_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define ILI9486_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define ILI9486_BCKL CONFIG_LV_DISP_PIN_BCKL
|
||||
#define ILI9486_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define ILI9486_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define ILI9486_USE_RST CONFIG_LV_DISP_USE_RST
|
||||
|
||||
#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
|
||||
|
@ -47,7 +40,6 @@ extern "C" {
|
|||
|
||||
void ili9486_init(void);
|
||||
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
|
||||
|
|
|
@ -50,7 +50,7 @@ static void ili9488_send_color(void * data, uint16_t length);
|
|||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
// From github.com/jeremyjh/ESP32_TFT_library
|
||||
// From github.com/jeremyjh/ESP32_TFT_library
|
||||
// From github.com/mvturnho/ILI9488-lvgl-ESP32-WROVER-B
|
||||
void ili9488_init(void)
|
||||
{
|
||||
|
@ -76,28 +76,31 @@ void ili9488_init(void)
|
|||
};
|
||||
|
||||
//Initialize non-SPI GPIOs
|
||||
gpio_reset_pin(ILI9488_DC);
|
||||
gpio_reset_pin(ILI9488_DC);
|
||||
gpio_set_direction(ILI9488_DC, GPIO_MODE_OUTPUT);
|
||||
gpio_reset_pin(ILI9488_RST);
|
||||
gpio_set_direction(ILI9488_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if ILI9488_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(ILI9488_BCKL);
|
||||
gpio_set_direction(ILI9488_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
#if ILI9488_USE_RST
|
||||
gpio_reset_pin(ILI9488_RST);
|
||||
gpio_set_direction(ILI9488_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
//Reset the display
|
||||
gpio_set_level(ILI9488_RST, 0);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(ILI9488_RST, 1);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
#endif
|
||||
|
||||
#if ILI9488_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(ILI9488_BCKL);
|
||||
gpio_set_direction(ILI9488_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "ILI9488 initialization.");
|
||||
|
||||
// Exit sleep
|
||||
ili9488_send_cmd(0x01); /* Software reset */
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
|
||||
|
||||
//Send all the commands
|
||||
uint16_t cmd = 0;
|
||||
while (ili_init_cmds[cmd].databytes!=0xff) {
|
||||
|
@ -109,9 +112,7 @@ void ili9488_init(void)
|
|||
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
|
||||
|
@ -146,7 +147,7 @@ void ili9488_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
|
|||
(uint8_t) (area->x2 >> 8) & 0xFF,
|
||||
(uint8_t) (area->x2) & 0xFF,
|
||||
};
|
||||
|
||||
|
||||
/* Page addresses */
|
||||
uint8_t yb[] = {
|
||||
(uint8_t) (area->y1 >> 8) & 0xFF,
|
||||
|
@ -170,22 +171,6 @@ void ili9488_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
|
|||
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
|
||||
**********************/
|
||||
|
|
|
@ -25,17 +25,9 @@ extern "C" {
|
|||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define ILI9488_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define ILI9488_RST CONFIG_LV_DISP_PIN_RST
|
||||
#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
|
||||
#define ILI9488_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define ILI9488_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define ILI9488_USE_RST CONFIG_LV_DISP_USE_RSTS
|
||||
|
||||
/*******************
|
||||
* ILI9488 REGS
|
||||
|
@ -154,7 +146,6 @@ typedef struct {
|
|||
|
||||
void ili9488_init(void);
|
||||
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
|
||||
|
|
148
lvgl_tft/pcd8544.c
Normal file
148
lvgl_tft/pcd8544.c
Normal file
|
@ -0,0 +1,148 @@
|
|||
/**
|
||||
* @file pcd8544.c
|
||||
*
|
||||
* Roughly based on:
|
||||
* https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library
|
||||
* https://github.com/olikraus/u8g2
|
||||
*/
|
||||
|
||||
#include "disp_spi.h"
|
||||
#include "driver/gpio.h"
|
||||
|
||||
#include <esp_log.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "pcd8544.h"
|
||||
|
||||
#define TAG "lv_pcd8544"
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#define BIT_SET(a,b) ((a) |= (1U<<(b)))
|
||||
#define BIT_CLEAR(a,b) ((a) &= ~(1U<<(b)))
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void pcd8544_send_cmd(uint8_t cmd)
|
||||
{
|
||||
disp_wait_for_pending_transactions();
|
||||
gpio_set_level(PCD8544_DC, 0); /*Command mode*/
|
||||
disp_spi_send_data(&cmd, 1);
|
||||
}
|
||||
|
||||
static void pcd8544_send_data(void * data, uint16_t length)
|
||||
{
|
||||
disp_wait_for_pending_transactions();
|
||||
gpio_set_level(PCD8544_DC, 1); /*Data mode*/
|
||||
disp_spi_send_data(data, length);
|
||||
}
|
||||
|
||||
static void pcd8544_send_colors(void * data, uint16_t length)
|
||||
{
|
||||
gpio_set_level(PCD8544_DC, 1); /*Data mode*/
|
||||
disp_spi_send_colors(data, length);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void pcd8544_init(void){
|
||||
|
||||
// TODO: orientation
|
||||
|
||||
// Initialize non-SPI GPIOs
|
||||
gpio_reset_pin(PCD8544_DC);
|
||||
gpio_set_direction(PCD8544_DC, GPIO_MODE_OUTPUT);
|
||||
gpio_reset_pin(PCD8544_RST);
|
||||
gpio_set_direction(PCD8544_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
// Reset the display
|
||||
gpio_set_level(PCD8544_RST, 0);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
gpio_set_level(PCD8544_RST, 1);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
|
||||
pcd8544_send_cmd(0x21); /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
|
||||
pcd8544_send_cmd(0x06); /* temp. control: b10 = 2 */
|
||||
pcd8544_send_cmd(0x13); /* bias system 1:48 */
|
||||
pcd8544_send_cmd(0xc0); /* medium Vop = Contrast 0x40 = 64 */
|
||||
|
||||
pcd8544_send_cmd(0x20); /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=0) */
|
||||
pcd8544_send_cmd(0x0c); /* display mode normal */
|
||||
}
|
||||
|
||||
void pcd8544_set_contrast (uint8_t contrast){
|
||||
if (contrast > 0x7f){
|
||||
contrast = 0x7f;
|
||||
}
|
||||
pcd8544_send_cmd(0x21); /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
|
||||
pcd8544_send_cmd(0x80 | contrast); /* medium Vop = Contrast */
|
||||
}
|
||||
|
||||
void pcd8544_rounder(lv_disp_drv_t * disp_drv, lv_area_t *area){
|
||||
uint8_t hor_max = disp_drv->hor_res;
|
||||
uint8_t ver_max = disp_drv->ver_res;
|
||||
|
||||
area->x1 = 0;
|
||||
area->y1 = 0;
|
||||
area->x2 = hor_max - 1;
|
||||
area->y2 = ver_max - 1;
|
||||
}
|
||||
|
||||
void pcd8544_set_px_cb(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa){
|
||||
|
||||
uint8_t set = (color.full == 0) && (LV_OPA_TRANSP != opa);
|
||||
|
||||
uint16_t byte_index = x + (( y>>3 ) * buf_w);
|
||||
uint8_t bit_index = y & 0x7;
|
||||
|
||||
if (set) {
|
||||
BIT_SET(buf[byte_index], bit_index);
|
||||
} else {
|
||||
BIT_CLEAR(buf[byte_index], bit_index);
|
||||
}
|
||||
}
|
||||
|
||||
void pcd8544_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_map){
|
||||
|
||||
pcd8544_send_cmd(0x20); /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=0) */
|
||||
|
||||
uint8_t * buf = (uint8_t *) color_map;
|
||||
|
||||
// Check if the whole frame buffer can be sent in a single SPI transaction
|
||||
|
||||
if ((area->x1 == 0) && (area->y1 == 0) && (area->x2 == (disp_drv->hor_res - 1)) && (area->y2 == (disp_drv->ver_res - 1))){
|
||||
|
||||
// send complete frame buffer at once.
|
||||
// NOTE: disp_spi_send_colors triggers lv_disp_flush_ready
|
||||
|
||||
pcd8544_send_cmd(0x40); /* set Y address */
|
||||
pcd8544_send_cmd(0x80); /* set X address */
|
||||
pcd8544_send_colors(buf, disp_drv->hor_res * disp_drv->ver_res / 8);
|
||||
|
||||
} else {
|
||||
|
||||
// send horizontal tiles
|
||||
|
||||
uint16_t bank_start = area->y1 / 8;
|
||||
uint16_t bank_end = area->y2 / 8;
|
||||
|
||||
uint16_t bank;
|
||||
uint16_t cols_to_update = area->x2 - area->x1 + 1;
|
||||
for (bank = bank_start ; bank <= bank_end ; bank++ ){
|
||||
pcd8544_send_cmd(0x40 | bank ); /* set Y address */
|
||||
pcd8544_send_cmd(0x80 | area->x1 ); /* set X address */
|
||||
uint16_t offset = bank * disp_drv->hor_res + area->x1;
|
||||
pcd8544_send_data(&buf[offset], cols_to_update);
|
||||
}
|
||||
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
}
|
57
lvgl_tft/pcd8544.h
Normal file
57
lvgl_tft/pcd8544.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
|
||||
/**
|
||||
* @file pcd8544.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PCD8544_H
|
||||
#define PCD8544_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
|
||||
#include "lvgl.h"
|
||||
#else
|
||||
#include "lvgl/lvgl.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define PCD8544_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define PCD8544_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define PCD8544_BCKL CONFIG_LV_DISP_PIN_BCKL
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
void pcd8544_init(void);
|
||||
void pcd8544_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
|
||||
void pcd8544_rounder(lv_disp_drv_t * disp_drv, lv_area_t *area);
|
||||
void pcd8544_set_px_cb(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
void pcd8544_set_contrast(uint8_t contrast);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*PCD8544_H*/
|
|
@ -148,29 +148,23 @@ void ra8875_init(void)
|
|||
|
||||
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
|
||||
|
||||
#if RA8875_USE_RST
|
||||
gpio_reset_pin(RA8875_RST);
|
||||
gpio_set_direction(RA8875_RST, GPIO_MODE_OUTPUT);
|
||||
#ifdef CONFIG_LV_DISP_PIN_BCKL
|
||||
gpio_reset_pin(CONFIG_LV_DISP_PIN_BCKL);
|
||||
gpio_set_direction(CONFIG_LV_DISP_PIN_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
|
||||
// Reset the RA8875
|
||||
gpio_set_level(RA8875_RST, 0);
|
||||
vTaskDelay(DIV_ROUND_UP(100, portTICK_PERIOD_MS));
|
||||
gpio_set_level(RA8875_RST, 1);
|
||||
vTaskDelay(DIV_ROUND_UP(100, portTICK_PERIOD_MS));
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LV_DISP_PIN_BCKL
|
||||
gpio_reset_pin(CONFIG_LV_DISP_PIN_BCKL);
|
||||
gpio_set_direction(CONFIG_LV_DISP_PIN_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
|
||||
// Initalize RA8875 clocks (SPI must be decelerated before initializing clocks)
|
||||
disp_spi_change_device_speed(SPI_CLOCK_SPEED_SLOW_HZ);
|
||||
|
@ -194,28 +188,8 @@ void ra8875_init(void)
|
|||
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_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)
|
||||
|
|
|
@ -24,7 +24,8 @@ extern "C" {
|
|||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define RA8875_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define RA8875_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define RA8875_USE_RST CONFIG_LV_DISP_USE_RST
|
||||
|
||||
// System & Configuration Registers
|
||||
#define RA8875_REG_PWRR (0x01) // Power and Display Control Register (PWRR)
|
||||
|
@ -96,7 +97,6 @@ extern "C" {
|
|||
**********************/
|
||||
|
||||
void ra8875_init(void);
|
||||
void ra8875_enable_backlight(bool backlight);
|
||||
void ra8875_enable_display(bool enable);
|
||||
void ra8875_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
|
||||
|
||||
|
|
|
@ -94,7 +94,9 @@ void sh1107_init(void)
|
|||
//Initialize non-SPI GPIOs
|
||||
gpio_reset_pin(SH1107_DC);
|
||||
gpio_set_direction(SH1107_DC, GPIO_MODE_OUTPUT);
|
||||
gpio_reset_pin(SH1107_RST);
|
||||
|
||||
#if SH1107_USE_RST
|
||||
gpio_reset_pin(SH1107_RST);
|
||||
gpio_set_direction(SH1107_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
//Reset the display
|
||||
|
@ -102,6 +104,7 @@ void sh1107_init(void)
|
|||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(SH1107_RST, 1);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
#endif
|
||||
|
||||
//Send all the commands
|
||||
uint16_t cmd = 0;
|
||||
|
|
|
@ -25,8 +25,9 @@ extern "C" {
|
|||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define SH1107_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define SH1107_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define SH1107_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define SH1107_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define SH1107_USE_RST CONFIG_LV_DISP_USE_RST
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
|
|
|
@ -13,10 +13,9 @@
|
|||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "driver/i2c.h"
|
||||
#include "assert.h"
|
||||
|
||||
#include "lvgl_i2c_conf.h"
|
||||
#include "lvgl_i2c/i2c_manager.h"
|
||||
|
||||
#include "ssd1306.h"
|
||||
|
||||
|
@ -25,6 +24,7 @@
|
|||
*********************/
|
||||
#define TAG "SSD1306"
|
||||
|
||||
#define OLED_I2C_PORT (CONFIG_LV_I2C_DISPLAY_PORT)
|
||||
// SLA (0x3C) + WRITE_MODE (0x00) = 0x78 (0b01111000)
|
||||
#define OLED_I2C_ADDRESS 0x3C
|
||||
#define OLED_WIDTH 128
|
||||
|
@ -70,8 +70,6 @@
|
|||
// Charge Pump (pg.62)
|
||||
#define OLED_CMD_SET_CHARGE_PUMP 0x8D // follow with 0x14
|
||||
|
||||
#define OLED_IIC_FREQ_HZ 400000 // I2C colock frequency
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
@ -126,8 +124,8 @@ void ssd1306_init(void)
|
|||
orientation_1,
|
||||
orientation_2,
|
||||
OLED_CMD_SET_CONTRAST,
|
||||
display_mode,
|
||||
0xFF,
|
||||
display_mode,
|
||||
OLED_CMD_DISPLAY_ON
|
||||
};
|
||||
|
||||
|
@ -213,44 +211,15 @@ void ssd1306_sleep_out(void)
|
|||
static uint8_t send_data(lv_disp_drv_t *disp_drv, void *bytes, size_t bytes_len)
|
||||
{
|
||||
(void) disp_drv;
|
||||
esp_err_t err;
|
||||
|
||||
uint8_t *data = (uint8_t *) bytes;
|
||||
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (OLED_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true);
|
||||
|
||||
for (size_t idx = 0; idx < bytes_len; idx++) {
|
||||
i2c_master_write_byte(cmd, data[idx], true);
|
||||
}
|
||||
|
||||
i2c_master_stop(cmd);
|
||||
|
||||
/* Send queued commands */
|
||||
err = i2c_master_cmd_begin(DISP_I2C_PORT, cmd, 10 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
|
||||
return ESP_OK == err ? 0 : 1;
|
||||
return lvgl_i2c_write(OLED_I2C_PORT, OLED_I2C_ADDRESS, data[0], data + 1, bytes_len - 1 );
|
||||
}
|
||||
|
||||
static uint8_t send_pixels(lv_disp_drv_t *disp_drv, void *color_buffer, size_t buffer_len)
|
||||
{
|
||||
(void) disp_drv;
|
||||
esp_err_t err;
|
||||
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (OLED_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true);
|
||||
|
||||
i2c_master_write_byte(cmd, OLED_CONTROL_BYTE_DATA_STREAM, true);
|
||||
i2c_master_write(cmd, (uint8_t *) color_buffer, buffer_len, true);
|
||||
i2c_master_stop(cmd);
|
||||
|
||||
/* Send queued commands */
|
||||
err = i2c_master_cmd_begin(DISP_I2C_PORT, cmd, 10 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
|
||||
return ESP_OK == err ? 0 : 1;
|
||||
return lvgl_i2c_write(OLED_I2C_PORT, OLED_I2C_ADDRESS, OLED_CONTROL_BYTE_DATA_STREAM, color_buffer, buffer_len);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,6 @@ extern "C" {
|
|||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define SSD1306_SDA CONFIG_LV_DISP_PIN_SDA
|
||||
#define SSD1306_SCL CONFIG_LV_DISP_PIN_SCL
|
||||
#define SSD1306_DISPLAY_ORIENTATION TFT_ORIENTATION_LANDSCAPE
|
||||
|
||||
/**********************
|
||||
|
|
|
@ -8,12 +8,15 @@
|
|||
*********************/
|
||||
#include "st7735s.h"
|
||||
#include "disp_spi.h"
|
||||
#include "driver/i2c.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192
|
||||
#include "lvgl_i2c/i2c_manager.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
@ -38,7 +41,6 @@ static void st7735s_send_cmd(uint8_t cmd);
|
|||
static void st7735s_send_data(void * data, uint16_t length);
|
||||
static void st7735s_send_color(void * data, uint16_t length);
|
||||
static void st7735s_set_orientation(uint8_t orientation);
|
||||
static void i2c_master_init();
|
||||
static void axp192_write_byte(uint8_t addr, uint8_t data);
|
||||
static void axp192_init();
|
||||
static void axp192_sleep_in();
|
||||
|
@ -60,7 +62,6 @@ uint8_t st7735s_portrait_mode = 0;
|
|||
void st7735s_init(void)
|
||||
{
|
||||
#ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192
|
||||
i2c_master_init();
|
||||
axp192_init();
|
||||
#endif
|
||||
|
||||
|
@ -99,7 +100,9 @@ void st7735s_init(void)
|
|||
//Initialize non-SPI GPIOs
|
||||
gpio_reset_pin(ST7735S_DC);
|
||||
gpio_set_direction(ST7735S_DC, GPIO_MODE_OUTPUT);
|
||||
gpio_reset_pin(ST7735S_RST);
|
||||
|
||||
#if ST7735S_USE_RST
|
||||
gpio_reset_pin(ST7735S_RST);
|
||||
gpio_set_direction(ST7735S_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
//Reset the display
|
||||
|
@ -107,6 +110,7 @@ void st7735s_init(void)
|
|||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(ST7735S_RST, 1);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "ST7735S initialization.");
|
||||
|
||||
|
@ -160,12 +164,16 @@ void st7735s_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
|
|||
void st7735s_sleep_in()
|
||||
{
|
||||
st7735s_send_cmd(0x10);
|
||||
axp192_sleep_in();
|
||||
#ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192
|
||||
axp192_sleep_in();
|
||||
#endif
|
||||
}
|
||||
|
||||
void st7735s_sleep_out()
|
||||
{
|
||||
axp192_sleep_out();
|
||||
#ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192
|
||||
axp192_sleep_out();
|
||||
#endif
|
||||
st7735s_send_cmd(0x11);
|
||||
}
|
||||
|
||||
|
@ -215,55 +223,35 @@ static void st7735s_set_orientation(uint8_t orientation)
|
|||
st7735s_send_data((void *) &data[orientation], 1);
|
||||
}
|
||||
|
||||
static void i2c_master_init()
|
||||
{
|
||||
i2c_config_t i2c_config = {
|
||||
.mode = I2C_MODE_MASTER,
|
||||
.sda_io_num = AXP192_SDA,
|
||||
.scl_io_num = AXP192_SCL,
|
||||
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
.scl_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
.master.clk_speed = 400000
|
||||
};
|
||||
i2c_param_config(I2C_NUM_0, &i2c_config);
|
||||
i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0);
|
||||
}
|
||||
#ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192
|
||||
|
||||
static void axp192_write_byte(uint8_t addr, uint8_t data)
|
||||
{
|
||||
esp_err_t ret;
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
static void axp192_write_byte(uint8_t addr, uint8_t data)
|
||||
{
|
||||
err = lvgl_i2c_write(CONFIG_LV_I2C_DISPLAY_PORT, AXP192_I2C_ADDRESS, addr, &data, 1);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "AXP192 send failed. code: 0x%.2X", ret);
|
||||
}
|
||||
}
|
||||
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (AXP192_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true);
|
||||
i2c_master_write_byte(cmd, addr, true);
|
||||
i2c_master_write_byte(cmd, data, true);
|
||||
i2c_master_stop(cmd);
|
||||
static void axp192_init()
|
||||
{
|
||||
// information on how to init and use AXP192 ifor M5StickC taken from
|
||||
// https://forum.m5stack.com/topic/1025/m5stickc-turn-off-screen-completely
|
||||
|
||||
ret = i2c_master_cmd_begin(I2C_NUM_0, cmd, 10/portTICK_PERIOD_MS);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "AXP192 send failed. code: 0x%.2X", ret);
|
||||
}
|
||||
i2c_cmd_link_delete(cmd);
|
||||
}
|
||||
axp192_write_byte(0x10, 0xFF); // OLED_VPP Enable
|
||||
axp192_write_byte(0x28, 0xCC); // Enable LDO2&LDO3, LED&TFT 3.0V
|
||||
axp192_sleep_out();
|
||||
ESP_LOGI(TAG, "AXP192 initialized, power enabled for LDO2 and LDO3");
|
||||
}
|
||||
|
||||
static void axp192_init()
|
||||
{
|
||||
// information on how to init and use AXP192 ifor M5StickC taken from
|
||||
// https://forum.m5stack.com/topic/1025/m5stickc-turn-off-screen-completely
|
||||
static void axp192_sleep_in()
|
||||
{
|
||||
axp192_write_byte(0x12, 0x4b);
|
||||
}
|
||||
|
||||
axp192_write_byte(0x10, 0xFF); // OLED_VPP Enable
|
||||
axp192_write_byte(0x28, 0xCC); // Enable LDO2&LDO3, LED&TFT 3.0V
|
||||
axp192_sleep_out();
|
||||
ESP_LOGI(TAG, "AXP192 initialized, power enabled for LDO2 and LDO3");
|
||||
}
|
||||
static void axp192_sleep_out()
|
||||
{
|
||||
axp192_write_byte(0x12, 0x4d);
|
||||
}
|
||||
|
||||
static void axp192_sleep_in()
|
||||
{
|
||||
axp192_write_byte(0x12, 0x4b);
|
||||
}
|
||||
|
||||
static void axp192_sleep_out()
|
||||
{
|
||||
axp192_write_byte(0x12, 0x4d);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -25,11 +25,9 @@ extern "C" {
|
|||
*********************/
|
||||
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
|
||||
|
||||
#define ST7735S_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define ST7735S_RST CONFIG_LV_DISP_PIN_RST
|
||||
|
||||
#define AXP192_SDA CONFIG_LV_AXP192_PIN_SDA
|
||||
#define AXP192_SCL CONFIG_LV_AXP192_PIN_SCL
|
||||
#define ST7735S_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define ST7735S_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define ST7735S_USE_RST CONFIG_LV_DISP_USE_RST
|
||||
|
||||
#define ST7735S_INVERT_COLORS CONFIG_LV_INVERT_COLORS
|
||||
|
||||
|
@ -133,7 +131,6 @@ extern "C" {
|
|||
|
||||
void st7735s_init(void);
|
||||
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_out(void);
|
||||
|
||||
|
|
|
@ -35,9 +35,7 @@ typedef struct {
|
|||
**********************/
|
||||
static void st7789_set_orientation(uint8_t orientation);
|
||||
|
||||
static void st7789_send_cmd(uint8_t cmd);
|
||||
static void st7789_send_data(void *data, uint16_t length);
|
||||
static void st7789_send_color(void *data, uint16_t length);
|
||||
static void st7789_send_color(void *data, size_t length);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
|
@ -91,7 +89,7 @@ void st7789_init(void)
|
|||
gpio_reset_pin(ST7789_DC);
|
||||
gpio_set_direction(ST7789_DC, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if !defined(CONFIG_LV_DISP_ST7789_SOFT_RESET)
|
||||
#if !defined(ST7789_SOFT_RST)
|
||||
gpio_reset_pin(ST7789_RST);
|
||||
gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
|
@ -102,7 +100,7 @@ void st7789_init(void)
|
|||
#endif
|
||||
|
||||
//Reset the display
|
||||
#if !defined(CONFIG_LV_DISP_ST7789_SOFT_RESET)
|
||||
#if !defined(ST7789_SOFT_RST)
|
||||
gpio_set_level(ST7789_RST, 0);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(ST7789_RST, 1);
|
||||
|
@ -124,30 +122,12 @@ void st7789_init(void)
|
|||
cmd++;
|
||||
}
|
||||
|
||||
st7789_enable_backlight(true);
|
||||
|
||||
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
|
||||
* 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. */
|
||||
/* The ST7789 display controller can drive up to 320*240 displays, when using a 240*240 or 240*135
|
||||
* displays there's a gap of 80px or 40/52/53px respectively. 52px or 53x offset depends on display orientation.
|
||||
* We need to edit the coordinates to take into account those gaps, this is not necessary in all orientations. */
|
||||
void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
|
||||
{
|
||||
uint8_t data[4] = {0};
|
||||
|
@ -164,13 +144,29 @@ void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
|
|||
offsety2 += CONFIG_LV_TFT_DISPLAY_Y_OFFSET;
|
||||
|
||||
#elif (LV_HOR_RES_MAX == 240) && (LV_VER_RES_MAX == 240)
|
||||
#if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT)
|
||||
offsetx1 += 80;
|
||||
offsetx2 += 80;
|
||||
#elif (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
|
||||
offsety1 += 80;
|
||||
offsety2 += 80;
|
||||
#endif
|
||||
#if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT)
|
||||
offsetx1 += 80;
|
||||
offsetx2 += 80;
|
||||
#elif (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
|
||||
offsety1 += 80;
|
||||
offsety2 += 80;
|
||||
#endif
|
||||
#elif (LV_HOR_RES_MAX == 240) && (LV_VER_RES_MAX == 135)
|
||||
#if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT) || \
|
||||
(CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
|
||||
offsetx1 += 40;
|
||||
offsetx2 += 40;
|
||||
offsety1 += 53;
|
||||
offsety2 += 53;
|
||||
#endif
|
||||
#elif (LV_HOR_RES_MAX == 135) && (LV_VER_RES_MAX == 240)
|
||||
#if (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE) || \
|
||||
(CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
|
||||
offsetx1 += 52;
|
||||
offsetx2 += 52;
|
||||
offsety1 += 40;
|
||||
offsety2 += 40;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*Column addresses*/
|
||||
|
@ -192,7 +188,7 @@ void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
|
|||
/*Memory write*/
|
||||
st7789_send_cmd(ST7789_RAMWR);
|
||||
|
||||
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
|
||||
size_t size = (size_t)lv_area_get_width(area) * (size_t)lv_area_get_height(area);
|
||||
|
||||
st7789_send_color((void*)color_map, size * 2);
|
||||
|
||||
|
@ -201,21 +197,21 @@ void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
|
|||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
static void st7789_send_cmd(uint8_t cmd)
|
||||
void st7789_send_cmd(uint8_t cmd)
|
||||
{
|
||||
disp_wait_for_pending_transactions();
|
||||
gpio_set_level(ST7789_DC, 0);
|
||||
disp_spi_send_data(&cmd, 1);
|
||||
}
|
||||
|
||||
static void st7789_send_data(void * data, uint16_t length)
|
||||
void st7789_send_data(void * data, uint16_t length)
|
||||
{
|
||||
disp_wait_for_pending_transactions();
|
||||
gpio_set_level(ST7789_DC, 1);
|
||||
disp_spi_send_data(data, length);
|
||||
}
|
||||
|
||||
static void st7789_send_color(void * data, uint16_t length)
|
||||
static void st7789_send_color(void * data, size_t length)
|
||||
{
|
||||
disp_wait_for_pending_transactions();
|
||||
gpio_set_level(ST7789_DC, 1);
|
||||
|
|
|
@ -23,17 +23,17 @@ extern "C"
|
|||
|
||||
#define ST7789_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define ST7789_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define ST7789_BCKL CONFIG_LV_DISP_PIN_BCKL
|
||||
|
||||
#define ST7789_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
|
||||
#define ST7789_INVERT_COLORS CONFIG_LV_INVERT_COLORS
|
||||
|
||||
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
|
||||
#define ST7789_BCKL_ACTIVE_LVL 1
|
||||
#if CONFIG_LV_DISP_USE_RST
|
||||
#if CONFIG_LV_DISP_ST7789_SOFT_RESET
|
||||
#define ST7789_SOFT_RST
|
||||
#endif
|
||||
#else
|
||||
#define ST7789_BCKL_ACTIVE_LVL 0
|
||||
#define ST7789_SOFT_RST
|
||||
#endif
|
||||
|
||||
#define ST7789_INVERT_COLORS CONFIG_LV_INVERT_COLORS
|
||||
|
||||
/* ST7789 commands */
|
||||
#define ST7789_NOP 0x00
|
||||
#define ST7789_SWRESET 0x01
|
||||
|
@ -112,7 +112,9 @@ extern "C"
|
|||
|
||||
void st7789_init(void);
|
||||
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_data(void *data, uint16_t length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
@ -81,31 +81,25 @@ void st7796s_init(void)
|
|||
{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_reset_pin(ST7796S_DC);
|
||||
gpio_set_direction(ST7796S_DC, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if ST7796S_USE_RST
|
||||
gpio_reset_pin(ST7796S_RST);
|
||||
gpio_set_direction(ST7796S_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if ST7796S_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(ST7796S_BCKL);
|
||||
gpio_set_direction(ST7796S_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
//Reset the display
|
||||
gpio_set_level(ST7796S_RST, 0);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(ST7796S_RST, 1);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
#endif
|
||||
|
||||
#if ST7796S_ENABLE_BACKLIGHT_CONTROL
|
||||
gpio_reset_pin(ST7796S_BCKL);
|
||||
gpio_set_direction(ST7796S_BCKL, GPIO_MODE_OUTPUT);
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "Initialization.");
|
||||
|
||||
|
@ -122,8 +116,6 @@ void st7796s_init(void)
|
|||
cmd++;
|
||||
}
|
||||
|
||||
st7796s_enable_backlight(true);
|
||||
|
||||
st7796s_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
|
||||
|
||||
#if ST7796S_INVERT_COLORS == 1
|
||||
|
@ -161,22 +153,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);
|
||||
}
|
||||
|
||||
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};
|
||||
|
|
|
@ -26,19 +26,12 @@ extern "C"
|
|||
/*********************
|
||||
* 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_DC CONFIG_LV_DISP_PIN_DC
|
||||
#define ST7796S_RST CONFIG_LV_DISP_PIN_RST
|
||||
#define ST7796S_USE_RST CONFIG_LV_DISP_USE_RST
|
||||
#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
|
||||
|
@ -118,7 +111,6 @@ extern "C"
|
|||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue