Skip to content

GPIO display reset optional / Added M5Core2 / White space fixes #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

# MacOS
.DS_Store

# ESP-IDF build dir
build
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ and sets the gpio numbers for the interface.
|---------------------------|-----------------------|-----------|-----------|-----------|
| ESP Wrover Kit v4.1 | ILI9341 | SPI | 240 | 320 |
| M5Stack | ILI9341 | SPI | 240 | 320 |
| M5Core2 | ILI9341 | SPI | 240 | 320 |
| M5Stick | SH1107 | SPI | - | - |
| M5StickC | ST7735S | SPI | 80 | 160 |
| Adafruit 3.5 Featherwing | HX8357 | SPI | 480 | 320 |
Expand Down
6 changes: 4 additions & 2 deletions lvgl_tft/EVE_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -155,7 +155,7 @@ void EVE_pdn_clear(void)
{
gpio_set_level(EVE_PDN, 1); /* Power-Down high */
}

#endif

void spi_acquire()
{
Expand Down Expand Up @@ -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 */

Expand Down
6 changes: 5 additions & 1 deletion lvgl_tft/EVE_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions lvgl_tft/EVE_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
14 changes: 10 additions & 4 deletions lvgl_tft/FT81x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -262,12 +262,18 @@ void TFT_bitmap_display(void)

void FT81x_init(void)
{
#if EVE_USE_PDN
gpio_pad_select_gpio(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;
Expand All @@ -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
}

Expand Down Expand Up @@ -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));
}
}
14 changes: 10 additions & 4 deletions lvgl_tft/GC9A01.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,24 @@ void GC9A01_init(void)
//Initialize non-SPI GPIOs
gpio_pad_select_gpio(GC9A01_DC);
gpio_set_direction(GC9A01_DC, GPIO_MODE_OUTPUT);

#if GC9A01_USE_RST
gpio_pad_select_gpio(GC9A01_RST);
gpio_set_direction(GC9A01_RST, GPIO_MODE_OUTPUT);
#endif

#if GC9A01_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(GC9A01_BCKL);
gpio_set_direction(GC9A01_BCKL, GPIO_MODE_OUTPUT);
#endif

#if GC9A01_USE_RST
//Reset the display
gpio_set_level(GC9A01_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS);
gpio_set_level(GC9A01_RST, 1);
vTaskDelay(100 / portTICK_RATE_MS);
#endif

ESP_LOGI(TAG, "Initialization.");

Expand Down Expand Up @@ -167,23 +173,23 @@ 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;
data[3] = area->x2 & 0xFF;
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;
data[3] = area->y2 & 0xFF;
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);
Expand Down Expand Up @@ -211,7 +217,7 @@ 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()
Expand Down
7 changes: 4 additions & 3 deletions lvgl_tft/GC9A01.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ 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_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_BCKL CONFIG_LV_DISP_PIN_BCKL

#define GC9A01_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL

Expand Down
29 changes: 27 additions & 2 deletions lvgl_tft/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -744,11 +748,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
Expand All @@ -763,6 +767,7 @@ menu "LVGL TFT Display controller"
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
Expand All @@ -777,6 +782,7 @@ menu "LVGL TFT Display controller"
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.
Expand All @@ -788,6 +794,7 @@ menu "LVGL TFT Display controller"
range 0 43 if IDF_TARGET_ESP32S2

default 19 if LV_PREDEFINED_PINS_TKOALA
default 38 if LV_PREDEFINED_DISPLAY_M5CORE2
default 0

help
Expand Down Expand Up @@ -830,6 +837,7 @@ menu "LVGL TFT Display controller"
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
Expand Down Expand Up @@ -858,6 +866,7 @@ menu "LVGL TFT Display controller"

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
Expand Down Expand Up @@ -887,6 +896,7 @@ menu "LVGL TFT Display controller"
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
Expand All @@ -900,8 +910,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
depends on LV_DISP_USE_RST
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2

Expand Down Expand Up @@ -937,6 +961,7 @@ menu "LVGL TFT Display controller"
( LV_PREDEFINED_DISPLAY_NONE && ! ( LV_TFT_DISPLAY_CONTROLLER_SH1107 || LV_TFT_DISPLAY_CONTROLLER_SSD1306 ) ) \
|| LV_PREDEFINED_DISPLAY_RPI_MPI3501
default y if LV_PREDEFINED_DISPLAY_M5STACK
default n if LV_PREDEFINED_DISPLAY_M5CORE2
default y if LV_PREDEFINED_DISPLAY_WROVER4
default y if LV_PREDEFINED_DISPLAY_ERTFT0356
default y if LV_PREDEFINED_DISPLAY_TTGO
Expand Down
5 changes: 5 additions & 0 deletions lvgl_tft/hx8357.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,24 @@ void hx8357_init(void)
//Initialize non-SPI GPIOs
gpio_pad_select_gpio(HX8357_DC);
gpio_set_direction(HX8357_DC, GPIO_MODE_OUTPUT);

#if HX8357_USE_RST
gpio_pad_select_gpio(HX8357_RST);
gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT);
#endif

#if HX8357_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(HX8357_BCKL);
gpio_set_direction(HX8357_BCKL, GPIO_MODE_OUTPUT);
#endif

#if HX8357_USE_RST
//Reset the display
gpio_set_level(HX8357_RST, 0);
vTaskDelay(10 / portTICK_RATE_MS);
gpio_set_level(HX8357_RST, 1);
vTaskDelay(120 / portTICK_RATE_MS);
#endif

ESP_LOGI(TAG, "Initialization.");

Expand Down
7 changes: 4 additions & 3 deletions lvgl_tft/hx8357.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +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_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_BCKL CONFIG_LV_DISP_PIN_BCKL

#define HX8357_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#define HX8357_INVERT_COLORS CONFIG_LV_INVERT_COLORS
Expand Down
Loading