diff --git a/TFT_Drivers/ILI9341_Init.h b/TFT_Drivers/ILI9341_Init.h index c867e4e..124c849 100644 --- a/TFT_Drivers/ILI9341_Init.h +++ b/TFT_Drivers/ILI9341_Init.h @@ -55,7 +55,11 @@ writedata(0x86); //-- writecommand(ILI9341_MADCTL); // Memory Access Control - writedata(0x48); +#ifdef M5STACK + writedata(0xA8); // Rotation 0 (portrait mode) +#else + writedata(0x48); // Rotation 0 (portrait mode) +#endif writecommand(ILI9341_PIXFMT); writedata(0x55); @@ -116,4 +120,11 @@ spi_begin(); writecommand(ILI9341_DISPON); //Display on + +#ifdef M5STACK + // Turn on the back-light LED + digitalWrite(TFT_BL, HIGH); + pinMode(TFT_BL, OUTPUT); +#endif + } \ No newline at end of file diff --git a/TFT_Drivers/ILI9341_Rotation.h b/TFT_Drivers/ILI9341_Rotation.h index 0af4fa7..6ad18e0 100644 --- a/TFT_Drivers/ILI9341_Rotation.h +++ b/TFT_Drivers/ILI9341_Rotation.h @@ -6,43 +6,75 @@ writecommand(TFT_MADCTL); switch (rotation) { case 0: +#ifdef M5STACK + writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); +#else writedata(TFT_MAD_MX | TFT_MAD_BGR); +#endif _width = _width_orig; _height = _height_orig; break; case 1: +#ifdef M5STACK + writedata(TFT_MAD_BGR); +#else writedata(TFT_MAD_MV | TFT_MAD_BGR); +#endif _width = _height_orig; _height = _width_orig; break; case 2: +#ifdef M5STACK + writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR); +#else writedata(TFT_MAD_MY | TFT_MAD_BGR); +#endif _width = _width_orig; _height = _height_orig; break; case 3: +#ifdef M5STACK + writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); +#else writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); +#endif _width = _height_orig; _height = _width_orig; break; - // These next rotations are for bottum up BMP drawing + // These next rotations are for bottom up BMP drawing case 4: +#ifdef M5STACK + writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR); +#else writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); +#endif _width = _width_orig; _height = _height_orig; break; case 5: +#ifdef M5STACK + writedata(TFT_MAD_MV | TFT_MAD_BGR); +#else writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR); +#endif _width = _height_orig; _height = _width_orig; break; case 6: +#ifdef M5STACK + writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); +#else writedata(TFT_MAD_BGR); +#endif _width = _width_orig; _height = _height_orig; break; case 7: +#ifdef M5STACK + writedata(TFT_MAD_MY | TFT_MAD_BGR); +#else writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); +#endif _width = _height_orig; _height = _width_orig; break; diff --git a/User_Setup_Select.h b/User_Setup_Select.h index 53be50d..b62a8b0 100644 --- a/User_Setup_Select.h +++ b/User_Setup_Select.h @@ -32,6 +32,7 @@ //#include // Setup file configured for my ST7735 //#include // Setup file configured for my stock RPi TFT with touch //#include // Setup file configured for my stock RPi TFT with touch +//#include // Setup file for the ESP32 based M5Stack //#include // Setup file template for copying/editting diff --git a/User_Setups/Setup12_M5Stack.h b/User_Setups/Setup12_M5Stack.h new file mode 100644 index 0000000..f307497 --- /dev/null +++ b/User_Setups/Setup12_M5Stack.h @@ -0,0 +1,85 @@ +// USER DEFINED SETTINGS +// +// The User_Setup header that will be called up is defined in User_Setup_Select.h +// +// Set driver type, fonts to be loaded, pins used and SPI control method etc +// +// If this file is edited correctly then all the library example sketches should +// run without the need to make any more changes for a particular hardware setup! + +// ################################################################################## +// +// Section 0. Call up the right driver file and any options for it +// +// ################################################################################## + +#define ILI9341_DRIVER + +#define M5STACK + +// ################################################################################## +// +// Section 1. Define the pins that are used to interface with the display here +// +// ################################################################################## + +// M5Stack +#define TFT_MISO 19 +#define TFT_MOSI 23 +#define TFT_SCLK 18 +#define TFT_CS 14 // Chip select control pin +#define TFT_DC 27 // Data Command control pin +#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin) +#define TFT_BL 32 // LED back-light + +// ################################################################################## +// +// Section 2. Define the way the DC and/or CS lines are driven +// +// ################################################################################## + +// Not used + +// ################################################################################## +// +// Section 3. Define the fonts that are to be used here +// +// ################################################################################## + +// Comment out the #defines below with // to stop that font being loaded +// The ESP8366 had plenty of memory so commenting out fonts is not normally necessary +// If all fonts are loaded the extra FLASH space required is about 17Kbytes... +// To save FLASH space only enable the fonts you need! + +#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH +#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters +#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters +#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm +#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. +#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. +#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts + +// ################################################################################## +// +// Section 4. Not used +// +// ################################################################################## + + +// ################################################################################## +// +// Section 5. Other options +// +// ################################################################################## + +// Define the SPI clock frequency +// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails +// With a ST7735 display more than 27MHz may not work (spurious pixels and lines) + +// #define SPI_FREQUENCY 1000000 +// #define SPI_FREQUENCY 5000000 +// #define SPI_FREQUENCY 10000000 +// #define SPI_FREQUENCY 20000000 +// #define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3 + #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS +// #define SPI_FREQUENCY 80000000 diff --git a/library.properties b/library.properties index c6ff549..efbb286 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ -4name=TFT_eSPI -version=0.18.13 +name=TFT_eSPI +version=0.18.14 author=Bodmer maintainer=Bodmer sentence=A fast TFT library for ESP8266 processors and the Arduino IDE