Skip to content

Commit

Permalink
Add support for M5Stack(Custom ILI9341) (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1abin authored and loboris committed Jan 28, 2018
1 parent 46dad5a commit aa21772
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
15 changes: 15 additions & 0 deletions components/tft/tftspi.c
Expand Up @@ -815,6 +815,21 @@ void _tft_setRotation(uint8_t rot) {
madctl = (MADCTL_MX | MADCTL_MV | TFT_RGB_BGR);
break;
}
#elif TFT_INVERT_ROTATION2
switch (rotation) {
case PORTRAIT:
madctl = (MADCTL_MX | MADCTL_MV | TFT_RGB_BGR);
break;
case LANDSCAPE:
madctl = (TFT_RGB_BGR);
break;
case PORTRAIT_FLIP:
madctl = (MADCTL_MY | MADCTL_MV | TFT_RGB_BGR);
break;
case LANDSCAPE_FLIP:
madctl = (MADCTL_MY | MADCTL_MX | TFT_RGB_BGR);
break;
}
#else
switch (rotation) {
case PORTRAIT:
Expand Down
32 changes: 31 additions & 1 deletion components/tft/tftspi.h
Expand Up @@ -94,6 +94,36 @@
#define PIN_BCKL_OFF 1 // GPIO value for backlight OFF
// ---------------------------------------------------------

#elif CONFIG_EXAMPLE_DISPLAY_TYPE == 3

// ** Set the correct configuration for M5Stack TFT
// ---------------------------------------------------------
#define DEFAULT_DISP_TYPE DISP_TYPE_ILI9341
#define DEFAULT_TFT_DISPLAY_WIDTH 320
#define DEFAULT_TFT_DISPLAY_HEIGHT 240
#define DISP_COLOR_BITS_24 0x66
#define DEFAULT_GAMMA_CURVE 0
#define DEFAULT_SPI_CLOCK 26000000
#define TFT_INVERT_ROTATION 0
#define TFT_INVERT_ROTATION1 0
#define TFT_INVERT_ROTATION2 1 // Adapte M5Stack TFT
#define TFT_RGB_BGR 0x08

#define USE_TOUCH TOUCH_TYPE_NONE

#define PIN_NUM_MISO 19 // SPI MISO
#define PIN_NUM_MOSI 23 // SPI MOSI
#define PIN_NUM_CLK 18 // SPI CLOCK pin
#define PIN_NUM_CS 14 // Display CS pin
#define PIN_NUM_DC 27 // Display command/data pin
#define PIN_NUM_TCS 0 // Touch screen CS pin (NOT used if USE_TOUCH=0)

#define PIN_NUM_RST 33 // GPIO used for RESET control (#16)
#define PIN_NUM_BCKL 32 // GPIO used for backlight control
#define PIN_BCKL_ON 1 // GPIO value for backlight ON
#define PIN_BCKL_OFF 0 // GPIO value for backlight OFF
// ---------------------------------------------------------

#else

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

// ===============================================================================

#endif
#endif
3 changes: 3 additions & 0 deletions main/Kconfig.projbuild
Expand Up @@ -29,6 +29,7 @@ config EXAMPLE_DISPLAY_TYPE
default 0 if EXAMPLE_DISPLAY_TYPE0
default 1 if EXAMPLE_DISPLAY_TYPE1
default 2 if EXAMPLE_DISPLAY_TYPE2
default 3 if EXAMPLE_DISPLAY_TYPE3

choice
prompt "Select predefined display configuration"
Expand All @@ -42,6 +43,8 @@ config EXAMPLE_DISPLAY_TYPE
bool "ESP-WROVER-KIT Display"
config EXAMPLE_DISPLAY_TYPE2
bool "Adafruit TFT Feather display"
config EXAMPLE_DISPLAY_TYPE3
bool "M5Stack TFT display"
endchoice

config EXAMPLE_USE_WIFI
Expand Down

0 comments on commit aa21772

Please sign in to comment.