Skip to content

Commit aa21772

Browse files
0x1abinloboris
authored andcommitted
Add support for M5Stack(Custom ILI9341) (#26)
1 parent 46dad5a commit aa21772

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

components/tft/tftspi.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,21 @@ void _tft_setRotation(uint8_t rot) {
815815
madctl = (MADCTL_MX | MADCTL_MV | TFT_RGB_BGR);
816816
break;
817817
}
818+
#elif TFT_INVERT_ROTATION2
819+
switch (rotation) {
820+
case PORTRAIT:
821+
madctl = (MADCTL_MX | MADCTL_MV | TFT_RGB_BGR);
822+
break;
823+
case LANDSCAPE:
824+
madctl = (TFT_RGB_BGR);
825+
break;
826+
case PORTRAIT_FLIP:
827+
madctl = (MADCTL_MY | MADCTL_MV | TFT_RGB_BGR);
828+
break;
829+
case LANDSCAPE_FLIP:
830+
madctl = (MADCTL_MY | MADCTL_MX | TFT_RGB_BGR);
831+
break;
832+
}
818833
#else
819834
switch (rotation) {
820835
case PORTRAIT:

components/tft/tftspi.h

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,36 @@
9494
#define PIN_BCKL_OFF 1 // GPIO value for backlight OFF
9595
// ---------------------------------------------------------
9696

97+
#elif CONFIG_EXAMPLE_DISPLAY_TYPE == 3
98+
99+
// ** Set the correct configuration for M5Stack TFT
100+
// ---------------------------------------------------------
101+
#define DEFAULT_DISP_TYPE DISP_TYPE_ILI9341
102+
#define DEFAULT_TFT_DISPLAY_WIDTH 320
103+
#define DEFAULT_TFT_DISPLAY_HEIGHT 240
104+
#define DISP_COLOR_BITS_24 0x66
105+
#define DEFAULT_GAMMA_CURVE 0
106+
#define DEFAULT_SPI_CLOCK 26000000
107+
#define TFT_INVERT_ROTATION 0
108+
#define TFT_INVERT_ROTATION1 0
109+
#define TFT_INVERT_ROTATION2 1 // Adapte M5Stack TFT
110+
#define TFT_RGB_BGR 0x08
111+
112+
#define USE_TOUCH TOUCH_TYPE_NONE
113+
114+
#define PIN_NUM_MISO 19 // SPI MISO
115+
#define PIN_NUM_MOSI 23 // SPI MOSI
116+
#define PIN_NUM_CLK 18 // SPI CLOCK pin
117+
#define PIN_NUM_CS 14 // Display CS pin
118+
#define PIN_NUM_DC 27 // Display command/data pin
119+
#define PIN_NUM_TCS 0 // Touch screen CS pin (NOT used if USE_TOUCH=0)
120+
121+
#define PIN_NUM_RST 33 // GPIO used for RESET control (#16)
122+
#define PIN_NUM_BCKL 32 // GPIO used for backlight control
123+
#define PIN_BCKL_ON 1 // GPIO value for backlight ON
124+
#define PIN_BCKL_OFF 0 // GPIO value for backlight OFF
125+
// ---------------------------------------------------------
126+
97127
#else
98128

99129
// Configuration for other boards, set the correct values for the display used
@@ -644,4 +674,4 @@ uint32_t stmpe610_getID();
644674

645675
// ===============================================================================
646676

647-
#endif
677+
#endif

main/Kconfig.projbuild

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ config EXAMPLE_DISPLAY_TYPE
2929
default 0 if EXAMPLE_DISPLAY_TYPE0
3030
default 1 if EXAMPLE_DISPLAY_TYPE1
3131
default 2 if EXAMPLE_DISPLAY_TYPE2
32+
default 3 if EXAMPLE_DISPLAY_TYPE3
3233

3334
choice
3435
prompt "Select predefined display configuration"
@@ -42,6 +43,8 @@ config EXAMPLE_DISPLAY_TYPE
4243
bool "ESP-WROVER-KIT Display"
4344
config EXAMPLE_DISPLAY_TYPE2
4445
bool "Adafruit TFT Feather display"
46+
config EXAMPLE_DISPLAY_TYPE3
47+
bool "M5Stack TFT display"
4548
endchoice
4649

4750
config EXAMPLE_USE_WIFI

0 commit comments

Comments
 (0)