Skip to content

Commit 5424362

Browse files
authored
Merge pull request #58 from ropg/master
GPIO display reset optional / Added M5Core2 / White space fixes
2 parents db51c38 + f4be773 commit 5424362

31 files changed

+199
-77
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,9 @@ modules.order
5050
Module.symvers
5151
Mkfile.old
5252
dkms.conf
53+
54+
# MacOS
55+
.DS_Store
56+
57+
# ESP-IDF build dir
58+
build

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ and sets the gpio numbers for the interface.
5151
|---------------------------|-----------------------|-----------|-----------|-----------|
5252
| ESP Wrover Kit v4.1 | ILI9341 | SPI | 240 | 320 |
5353
| M5Stack | ILI9341 | SPI | 240 | 320 |
54+
| M5Core2 | ILI9341 | SPI | 240 | 320 |
5455
| M5Stick | SH1107 | SPI | - | - |
5556
| M5StickC | ST7735S | SPI | 80 | 160 |
5657
| Adafruit 3.5 Featherwing | HX8357 | SPI | 480 | 320 |

lvgl_tft/EVE_commands.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void DELAY_MS(uint16_t ms)
144144
vTaskDelay(ms / portTICK_PERIOD_MS);
145145
}
146146

147-
147+
#if EVE_USE_PDN
148148
void EVE_pdn_set(void)
149149
{
150150
gpio_set_level(EVE_PDN, 0); /* Power-Down low */
@@ -155,7 +155,7 @@ void EVE_pdn_clear(void)
155155
{
156156
gpio_set_level(EVE_PDN, 1); /* Power-Down high */
157157
}
158-
158+
#endif
159159

160160
void spi_acquire()
161161
{
@@ -841,11 +841,13 @@ uint8_t EVE_init(void)
841841
uint8_t chipid = 0;
842842
uint16_t timeout = 0;
843843

844+
#if EVE_USE_PDN
844845
EVE_pdn_set();
845846
DELAY_MS(6); /* minimum time for power-down is 5ms */
846847

847848
EVE_pdn_clear();
848849
DELAY_MS(21); /* minimum time to allow from rising PD_N to first access is 20ms */
850+
#endif
849851

850852
/* EVE_cmdWrite(EVE_CORERST,0); */ /* reset, only required for warm-start if PowerDown line is not used */
851853

lvgl_tft/EVE_commands.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
3939
#define BLOCK_TRANSFER_SIZE 3840 // block transfer size when write data to CMD buffer
4040

4141
void DELAY_MS(uint16_t ms);
42+
43+
#if EVE_USE_PDN
4244
void EVE_pdn_set(void);
4345
void EVE_pdn_clear(void);
46+
#endif
47+
4448
void spi_acquire();
4549
void spi_release();
4650

@@ -64,7 +68,7 @@ void EVE_get_cmdoffset(void);
6468
/* commands to operate on memory: */
6569
void EVE_cmd_memzero(uint32_t ptr, uint32_t num);
6670
void EVE_cmd_memset(uint32_t ptr, uint8_t value, uint32_t num);
67-
void EVE_cmd_memwrite(uint32_t dest, uint32_t num, const uint8_t *data);
71+
void EVE_cmd_memwrite(uint32_t dest, uint32_t num, const uint8_t *data);
6872
void EVE_cmd_memcpy(uint32_t dest, uint32_t src, uint32_t num);
6973

7074
#if FT81X_FULL

lvgl_tft/EVE_config.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
4444

4545
#include "FT81x.h"
4646

47-
#define EVE_CLK DISP_SPI_CLK // orange
48-
#define EVE_MISO DISP_SPI_MISO // yellow
49-
#define EVE_MOSI DISP_SPI_MOSI // green
50-
#define EVE_CS DISP_SPI_CS // blue
51-
#define EVE_PDN CONFIG_LV_DISP_PIN_RST // grey
47+
#define EVE_CLK DISP_SPI_CLK // orange
48+
#define EVE_MISO DISP_SPI_MISO // yellow
49+
#define EVE_MOSI DISP_SPI_MOSI // green
50+
#define EVE_CS DISP_SPI_CS // blue
51+
#define EVE_PDN CONFIG_LV_DISP_PIN_RST // grey
52+
#define EVE_USE_PDN CONFIG_LV_DISP_USE_RST
5253

5354
#define SPI_TRANSER_SIZE (DISP_BUF_SIZE * (LV_COLOR_DEPTH / 8))
5455

lvgl_tft/FT81x.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void TFT_bitmap_display(void)
250250
EVE_cmd_dl(TAG(0));
251251

252252
EVE_cmd_dl(DL_DISPLAY); /* instruct the graphics processor to show the list */
253-
253+
254254
EVE_cmd_dl(CMD_SWAP); /* make this list active */
255255

256256
EVE_end_cmd_burst(); /* stop writing to the cmd-fifo */
@@ -262,12 +262,18 @@ void TFT_bitmap_display(void)
262262

263263
void FT81x_init(void)
264264
{
265+
#if EVE_USE_PDN
265266
gpio_pad_select_gpio(EVE_PDN);
267+
#endif
268+
266269
gpio_set_level(EVE_CS, 1);
270+
271+
#if EVE_USE_PDN
267272
gpio_set_direction(EVE_PDN, GPIO_MODE_OUTPUT);
273+
#endif
268274

269275
spi_acquire();
270-
276+
271277
if(EVE_init())
272278
{
273279
tft_active = 1;
@@ -278,7 +284,7 @@ void FT81x_init(void)
278284

279285
EVE_cmd_memset(SCREEN_BITMAP_ADDR, BLACK, SCREEN_BUFFER_SIZE); // clear screen buffer
280286
EVE_cmd_execute();
281-
287+
282288
TFT_bitmap_display(); // set DL for fullscreen bitmap display
283289
}
284290

@@ -320,4 +326,4 @@ void TFT_WriteBitmap(uint8_t* Bitmap, uint16_t X, uint16_t Y, uint16_t Width, ui
320326
void FT81x_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
321327
{
322328
TFT_WriteBitmap((uint8_t*)color_map, area->x1, area->y1, lv_area_get_width(area), lv_area_get_height(area));
323-
}
329+
}

lvgl_tft/GC9A01.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,24 @@ void GC9A01_init(void)
124124
//Initialize non-SPI GPIOs
125125
gpio_pad_select_gpio(GC9A01_DC);
126126
gpio_set_direction(GC9A01_DC, GPIO_MODE_OUTPUT);
127+
128+
#if GC9A01_USE_RST
127129
gpio_pad_select_gpio(GC9A01_RST);
128130
gpio_set_direction(GC9A01_RST, GPIO_MODE_OUTPUT);
131+
#endif
129132

130133
#if GC9A01_ENABLE_BACKLIGHT_CONTROL
131134
gpio_pad_select_gpio(GC9A01_BCKL);
132135
gpio_set_direction(GC9A01_BCKL, GPIO_MODE_OUTPUT);
133136
#endif
137+
138+
#if GC9A01_USE_RST
134139
//Reset the display
135140
gpio_set_level(GC9A01_RST, 0);
136141
vTaskDelay(100 / portTICK_RATE_MS);
137142
gpio_set_level(GC9A01_RST, 1);
138143
vTaskDelay(100 / portTICK_RATE_MS);
144+
#endif
139145

140146
ESP_LOGI(TAG, "Initialization.");
141147

@@ -167,23 +173,23 @@ void GC9A01_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
167173
uint8_t data[4];
168174

169175
/*Column addresses*/
170-
GC9A01_send_cmd(0x2A); //0x2A
176+
GC9A01_send_cmd(0x2A); //0x2A
171177
data[0] = (area->x1 >> 8) & 0xFF;
172178
data[1] = area->x1 & 0xFF;
173179
data[2] = (area->x2 >> 8) & 0xFF;
174180
data[3] = area->x2 & 0xFF;
175181
GC9A01_send_data(data, 4);
176182

177183
/*Page addresses*/
178-
GC9A01_send_cmd(0x2B); //0x2B
184+
GC9A01_send_cmd(0x2B); //0x2B
179185
data[0] = (area->y1 >> 8) & 0xFF;
180186
data[1] = area->y1 & 0xFF;
181187
data[2] = (area->y2 >> 8) & 0xFF;
182188
data[3] = area->y2 & 0xFF;
183189
GC9A01_send_data(data, 4);
184190

185191
/*Memory write*/
186-
GC9A01_send_cmd(0x2C); //0x2C
192+
GC9A01_send_cmd(0x2C); //0x2C
187193

188194

189195
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
@@ -211,7 +217,7 @@ void GC9A01_sleep_in()
211217
{
212218
uint8_t data[] = {0x08};
213219
GC9A01_send_cmd(0x10); //0x10 Enter Sleep Mode
214-
GC9A01_send_data(&data, 1);
220+
GC9A01_send_data(&data, 1);
215221
}
216222

217223
void GC9A01_sleep_out()

lvgl_tft/GC9A01.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ extern "C" {
2525
/*********************
2626
* DEFINES
2727
*********************/
28-
#define GC9A01_DC CONFIG_LV_DISP_PIN_DC
29-
#define GC9A01_RST CONFIG_LV_DISP_PIN_RST
30-
#define GC9A01_BCKL CONFIG_LV_DISP_PIN_BCKL
28+
#define GC9A01_DC CONFIG_LV_DISP_PIN_DC
29+
#define GC9A01_RST CONFIG_LV_DISP_PIN_RST
30+
#define GC9A01_USE_RST CONFIG_LV_DISP_USE_RST
31+
#define GC9A01_BCKL CONFIG_LV_DISP_PIN_BCKL
3132

3233
#define GC9A01_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
3334

lvgl_tft/Kconfig

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ menu "LVGL TFT Display controller"
2121
bool "M5Stack"
2222
select LV_TFT_DISPLAY_CONTROLLER_ILI9341
2323
select LV_TFT_DISPLAY_PROTOCOL_SPI
24+
config LV_PREDEFINED_DISPLAY_M5CORE2
25+
bool "M5Core2"
26+
select LV_TFT_DISPLAY_CONTROLLER_ILI9341
27+
select LV_TFT_DISPLAY_PROTOCOL_SPI
2428
config LV_PREDEFINED_DISPLAY_M5STICK
2529
bool "M5Stick"
2630
select LV_TFT_DISPLAY_CONTROLLER_SH1107
@@ -744,11 +748,11 @@ menu "LVGL TFT Display controller"
744748

745749
config LV_DISP_ST7789_SOFT_RESET
746750
bool "Soft reset - use software reset instead of reset pin"
747-
depends on LV_TFT_DISPLAY_CONTROLLER_ST7789
751+
depends on LV_TFT_DISPLAY_CONTROLLER_ST7789
748752
default n
749753
help
750754
Use software reset and ignores configured reset pin (some hardware does not use a reset pin).
751-
755+
752756
endmenu
753757

754758
# menu will be visible only when LV_PREDEFINED_DISPLAY_NONE is y
@@ -763,6 +767,7 @@ menu "LVGL TFT Display controller"
763767
default 23 if LV_PREDEFINED_DISPLAY_WROVER4
764768
default 23 if LV_PREDEFINED_DISPLAY_ATAG
765769
default 23 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
770+
default 23 if LV_PREDEFINED_DISPLAY_M5CORE2
766771
default 15 if LV_PREDEFINED_DISPLAY_M5STICKC
767772
default 18 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
768773
default 23 if LV_PREDEFINED_PINS_TKOALA
@@ -777,6 +782,7 @@ menu "LVGL TFT Display controller"
777782
config LV_DISPLAY_USE_SPI_MISO
778783
bool "GPIO for MISO (Master In Slave Out)" if LV_TFT_DISPLAY_PROTOCOL_SPI
779784
default y if LV_PREDEFINED_PINS_TKOALA
785+
default y if LV_PREDEFINED_DISPLAY_M5CORE2
780786
help
781787
Enable the MISO signal to control the display. You can disable
782788
it when the display does not need MISO signal to be controlled.
@@ -788,6 +794,7 @@ menu "LVGL TFT Display controller"
788794
range 0 43 if IDF_TARGET_ESP32S2
789795

790796
default 19 if LV_PREDEFINED_PINS_TKOALA
797+
default 38 if LV_PREDEFINED_DISPLAY_M5CORE2
791798
default 0
792799

793800
help
@@ -830,6 +837,7 @@ menu "LVGL TFT Display controller"
830837
range 0 43 if IDF_TARGET_ESP32S2
831838

832839
default 18 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
840+
default 18 if LV_PREDEFINED_DISPLAY_M5CORE2
833841
default 13 if LV_PREDEFINED_DISPLAY_M5STICKC
834842
default 18 if LV_PREDEFINED_DISPLAY_ATAG
835843
default 19 if LV_PREDEFINED_DISPLAY_WROVER4
@@ -858,6 +866,7 @@ menu "LVGL TFT Display controller"
858866

859867
default 5 if LV_PREDEFINED_PINS_38V1
860868
default 14 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
869+
default 5 if LV_PREDEFINED_DISPLAY_M5CORE2
861870
default 5 if LV_PREDEFINED_DISPLAY_M5STICKC
862871
default 22 if LV_PREDEFINED_DISPLAY_WROVER4
863872
default 15 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
@@ -887,6 +896,7 @@ menu "LVGL TFT Display controller"
887896
default 19 if LV_PREDEFINED_PINS_38V1
888897
default 17 if LV_PREDEFINED_PINS_38V4
889898
default 27 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
899+
default 15 if LV_PREDEFINED_DISPLAY_M5CORE2
890900
default 23 if LV_PREDEFINED_DISPLAY_M5STICKC
891901
default 21 if LV_PREDEFINED_DISPLAY_WROVER4
892902
default 21 if LV_PREDEFINED_DISPLAY_WT32_SC01
@@ -900,8 +910,22 @@ menu "LVGL TFT Display controller"
900910
help
901911
Configure the display DC pin here.
902912

913+
config LV_DISP_USE_RST
914+
bool "Use a GPIO for resetting the display" if LV_TFT_DISPLAY_PROTOCOL_SPI
915+
default n if LV_PREDEFINED_DISPLAY_M5CORE2
916+
default y
917+
help
918+
Enable display reset control. Set this if the reset pin of the
919+
display is connected to the host. If this is not set, then it is
920+
the user's responsibility to ensure that the display is reset
921+
before initialisation.
922+
You may want to disable this option because the reset pin is not
923+
connected, or is connected to an external component such as the
924+
power management IC.
925+
903926
config LV_DISP_PIN_RST
904927
int "GPIO for Reset" if LV_TFT_DISPLAY_PROTOCOL_SPI && !LV_DISP_ST7789_SOFT_RESET
928+
depends on LV_DISP_USE_RST
905929
range 0 39 if IDF_TARGET_ESP32
906930
range 0 43 if IDF_TARGET_ESP32S2
907931

@@ -937,6 +961,7 @@ menu "LVGL TFT Display controller"
937961
( LV_PREDEFINED_DISPLAY_NONE && ! ( LV_TFT_DISPLAY_CONTROLLER_SH1107 || LV_TFT_DISPLAY_CONTROLLER_SSD1306 ) ) \
938962
|| LV_PREDEFINED_DISPLAY_RPI_MPI3501
939963
default y if LV_PREDEFINED_DISPLAY_M5STACK
964+
default n if LV_PREDEFINED_DISPLAY_M5CORE2
940965
default y if LV_PREDEFINED_DISPLAY_WROVER4
941966
default y if LV_PREDEFINED_DISPLAY_ERTFT0356
942967
default y if LV_PREDEFINED_DISPLAY_TTGO

lvgl_tft/hx8357.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,24 @@ void hx8357_init(void)
162162
//Initialize non-SPI GPIOs
163163
gpio_pad_select_gpio(HX8357_DC);
164164
gpio_set_direction(HX8357_DC, GPIO_MODE_OUTPUT);
165+
166+
#if HX8357_USE_RST
165167
gpio_pad_select_gpio(HX8357_RST);
166168
gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT);
169+
#endif
167170

168171
#if HX8357_ENABLE_BACKLIGHT_CONTROL
169172
gpio_pad_select_gpio(HX8357_BCKL);
170173
gpio_set_direction(HX8357_BCKL, GPIO_MODE_OUTPUT);
171174
#endif
172175

176+
#if HX8357_USE_RST
173177
//Reset the display
174178
gpio_set_level(HX8357_RST, 0);
175179
vTaskDelay(10 / portTICK_RATE_MS);
176180
gpio_set_level(HX8357_RST, 1);
177181
vTaskDelay(120 / portTICK_RATE_MS);
182+
#endif
178183

179184
ESP_LOGI(TAG, "Initialization.");
180185

0 commit comments

Comments
 (0)