You've already forked TEF6686_ESP32
embed rtc driver, not sure if its that exact but should be better infact
This commit is contained in:
@@ -1,38 +1,8 @@
|
||||
// Color definitions for backwards compatibility with old sketches
|
||||
// use colour definitions like TFT_BLACK to make sketches more portable
|
||||
#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */
|
||||
#define ILI9341_NAVY 0x000F /* 0, 0, 128 */
|
||||
#define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */
|
||||
#define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */
|
||||
#define ILI9341_MAROON 0x7800 /* 128, 0, 0 */
|
||||
#define ILI9341_PURPLE 0x780F /* 128, 0, 128 */
|
||||
#define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */
|
||||
#define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */
|
||||
#define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */
|
||||
#define ILI9341_BLUE 0x001F /* 0, 0, 255 */
|
||||
#define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */
|
||||
#define ILI9341_CYAN 0x07FF /* 0, 255, 255 */
|
||||
#define ILI9341_RED 0xF800 /* 255, 0, 0 */
|
||||
#define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */
|
||||
#define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */
|
||||
#define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */
|
||||
#define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */
|
||||
#define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
|
||||
#define ILI9341_PINK 0xF81F
|
||||
|
||||
|
||||
// Delay between some initialisation commands
|
||||
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
|
||||
|
||||
#define TFT_NOP 0x00
|
||||
#define TFT_SWRST 0x01
|
||||
|
||||
#define TFT_INVOFF 0x20
|
||||
#define TFT_INVON 0x21
|
||||
|
||||
#define TFT_DISPOFF 0x28
|
||||
#define TFT_DISPON 0x29
|
||||
|
||||
#define TFT_CASET 0x2A
|
||||
#define TFT_PASET 0x2B
|
||||
#define TFT_RAMWR 0x2C
|
||||
@@ -49,74 +19,23 @@
|
||||
#define TFT_MAD_MH 0x04
|
||||
#define TFT_MAD_RGB 0x00
|
||||
|
||||
#ifdef TFT_RGB_ORDER
|
||||
#if (TFT_RGB_ORDER == 1)
|
||||
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
|
||||
#else
|
||||
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
|
||||
#endif
|
||||
#else
|
||||
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
|
||||
#endif
|
||||
|
||||
#define ILI9341_NOP 0x00
|
||||
#define ILI9341_SWRESET 0x01
|
||||
#define ILI9341_RDDID 0x04
|
||||
#define ILI9341_RDDST 0x09
|
||||
|
||||
#define ILI9341_SLPIN 0x10
|
||||
#define ILI9341_SLPOUT 0x11
|
||||
#define ILI9341_PTLON 0x12
|
||||
#define ILI9341_NORON 0x13
|
||||
|
||||
#define ILI9341_RDMODE 0x0A
|
||||
#define ILI9341_RDMADCTL 0x0B
|
||||
#define ILI9341_RDPIXFMT 0x0C
|
||||
#define ILI9341_RDIMGFMT 0x0A
|
||||
#define ILI9341_RDSELFDIAG 0x0F
|
||||
|
||||
#define ILI9341_INVOFF 0x20
|
||||
#define ILI9341_INVON 0x21
|
||||
#define ILI9341_GAMMASET 0x26
|
||||
#define ILI9341_DISPOFF 0x28
|
||||
#define ILI9341_DISPON 0x29
|
||||
|
||||
#define ILI9341_CASET 0x2A
|
||||
#define ILI9341_PASET 0x2B
|
||||
#define ILI9341_RAMWR 0x2C
|
||||
#define ILI9341_RAMRD 0x2E
|
||||
|
||||
#define ILI9341_PTLAR 0x30
|
||||
#define ILI9341_VSCRDEF 0x33
|
||||
#define ILI9341_MADCTL 0x36
|
||||
#define ILI9341_VSCRSADD 0x37
|
||||
#define ILI9341_PIXFMT 0x3A
|
||||
|
||||
#define ILI9341_WRDISBV 0x51
|
||||
#define ILI9341_RDDISBV 0x52
|
||||
#define ILI9341_WRCTRLD 0x53
|
||||
|
||||
#define ILI9341_FRMCTR1 0xB1
|
||||
#define ILI9341_FRMCTR2 0xB2
|
||||
#define ILI9341_FRMCTR3 0xB3
|
||||
#define ILI9341_INVCTR 0xB4
|
||||
#define ILI9341_DFUNCTR 0xB6
|
||||
|
||||
#define ILI9341_PWCTR1 0xC0
|
||||
#define ILI9341_PWCTR2 0xC1
|
||||
#define ILI9341_PWCTR3 0xC2
|
||||
#define ILI9341_PWCTR4 0xC3
|
||||
#define ILI9341_PWCTR5 0xC4
|
||||
#define ILI9341_VMCTR1 0xC5
|
||||
#define ILI9341_VMCTR2 0xC7
|
||||
|
||||
#define ILI9341_RDID4 0xD3
|
||||
#define ILI9341_RDINDEX 0xD9
|
||||
#define ILI9341_RDID1 0xDA
|
||||
#define ILI9341_RDID2 0xDB
|
||||
#define ILI9341_RDID3 0xDC
|
||||
#define ILI9341_RDIDX 0xDD
|
||||
|
||||
#define ILI9341_GMCTRP1 0xE0
|
||||
#define ILI9341_GMCTRN1 0xE1
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
writedata(0x86); //--
|
||||
|
||||
writecommand(ILI9341_MADCTL); // Memory Access Control
|
||||
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER); // Rotation 0 (portrait mode)
|
||||
writedata(TFT_MAD_MX | TFT_MAD_BGR); // Rotation 0 (portrait mode)
|
||||
|
||||
writecommand(ILI9341_PIXFMT);
|
||||
writedata(0x55);
|
||||
|
||||
@@ -1,82 +1,46 @@
|
||||
|
||||
// This is the command sequence that rotates the ILI9341 driver coordinate frame
|
||||
|
||||
rotation = m % 8; // Limit the range of values to 0-7
|
||||
|
||||
writecommand(TFT_MADCTL);
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||
#else
|
||||
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
|
||||
#endif
|
||||
writedata(TFT_MAD_MX | TFT_MAD_BGR);
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 1:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_COLOR_ORDER);
|
||||
#else
|
||||
writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||
#endif
|
||||
writedata(TFT_MAD_MV | TFT_MAD_BGR);
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 2:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
|
||||
#else
|
||||
writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
#endif
|
||||
writedata(TFT_MAD_MY | TFT_MAD_BGR);
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 3:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
#else
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||
#endif
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
// These next rotations are for bottom up BMP drawing
|
||||
case 4:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||
#else
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
#endif
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 5:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
#else
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
|
||||
#endif
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR);
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
case 6:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||
#else
|
||||
writedata(TFT_MAD_COLOR_ORDER);
|
||||
#endif
|
||||
writedata(TFT_MAD_BGR);
|
||||
_width = _init_width;
|
||||
_height = _init_height;
|
||||
break;
|
||||
case 7:
|
||||
#ifdef M5STACK
|
||||
writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER);
|
||||
#else
|
||||
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||
#endif
|
||||
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
_width = _init_height;
|
||||
_height = _init_width;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,6 @@
|
||||
#define TFT_ESPI_VERSION "2.5.43"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Print.h>
|
||||
#include <SPI.h>
|
||||
|
||||
#include <User_Setup_Select.h>
|
||||
@@ -187,9 +186,7 @@ class TFT_eSPI { friend class TFT_eSprite;
|
||||
void invertDisplay(bool i);
|
||||
void setAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h);
|
||||
void setViewport(int32_t x, int32_t y, int32_t w, int32_t h, bool vpDatum = true);
|
||||
bool checkViewport(int32_t x, int32_t y, int32_t w, int32_t h);
|
||||
void resetViewport();
|
||||
bool clipAddrWindow(int32_t* x, int32_t* y, int32_t* w, int32_t* h);
|
||||
bool clipWindow(int32_t* xs, int32_t* ys, int32_t* xe, int32_t* ye);
|
||||
void pushColor(uint16_t color, uint32_t len);
|
||||
void pushColors(uint16_t *data, uint32_t len, bool swap = true);
|
||||
@@ -211,17 +208,13 @@ class TFT_eSPI { friend class TFT_eSprite;
|
||||
void fillSmoothCircle(int32_t x, int32_t y, int32_t r, uint32_t color, uint32_t bg_color = 0x00FFFFFF);
|
||||
void drawSmoothRoundRect(int32_t x, int32_t y, int32_t r, int32_t ir, int32_t w, int32_t h, uint32_t fg_color, uint32_t bg_color = 0x00FFFFFF, uint8_t quadrants = 0xF);
|
||||
void fillSmoothRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color, uint32_t bg_color = 0x00FFFFFF);
|
||||
void drawSpot(float ax, float ay, float r, uint32_t fg_color, uint32_t bg_color = 0x00FFFFFF);
|
||||
void drawWedgeLine(float ax, float ay, float bx, float by, float aw, float bw, uint32_t fg_color, uint32_t bg_color = 0x00FFFFFF);
|
||||
void setSwapBytes(bool swap);
|
||||
bool getSwapBytes();
|
||||
void drawBitmap( int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor),
|
||||
drawBitmap( int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor),
|
||||
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor),
|
||||
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor),
|
||||
setBitmapColor(uint16_t fgcolor, uint16_t bgcolor);
|
||||
void setPivot(int16_t x, int16_t y);
|
||||
void pushRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data);
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data);
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data, uint16_t transparent);
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data, uint16_t transparent);
|
||||
@@ -229,8 +222,6 @@ class TFT_eSPI { friend class TFT_eSprite;
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *data, bool bpp8 = true, uint16_t *cmap = nullptr);
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *data, uint8_t transparent, bool bpp8 = true, uint16_t *cmap = nullptr);
|
||||
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint8_t *data, bool bpp8, uint16_t *cmap = nullptr);
|
||||
void readRectRGB(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *data);
|
||||
|
||||
|
||||
// Text rendering - value returned is the pixel width of the rendered text
|
||||
int16_t drawNumber(long intNumber, int32_t x, int32_t y, uint8_t font), // Draw integer using specified font number
|
||||
@@ -249,8 +240,8 @@ class TFT_eSPI { friend class TFT_eSprite;
|
||||
drawString(const String& string, int32_t x, int32_t y); // Draw string using current font
|
||||
|
||||
// Text rendering and font handling support functions
|
||||
void setCursor(int16_t x, int16_t y), // Set cursor for tft.print()
|
||||
setCursor(int16_t x, int16_t y, uint8_t font); // Set cursor and font number for tft.print()
|
||||
void setCursor(int16_t x, int16_t y),
|
||||
setCursor(int16_t x, int16_t y, uint8_t font);
|
||||
|
||||
void setTextColor(uint16_t color), // Set character (glyph) color only (background not over-written)
|
||||
setTextColor(uint16_t fgcolor, uint16_t bgcolor, bool bgfill = false), // Set character (glyph) foreground and background colour, optional background fill for smooth fonts
|
||||
@@ -274,20 +265,10 @@ class TFT_eSPI { friend class TFT_eSprite;
|
||||
uint16_t decodeUTF8(uint8_t *buf, uint16_t *index, uint16_t remaining),
|
||||
decodeUTF8(uint8_t c);
|
||||
|
||||
// Used by Smooth font class to fetch a pixel colour for the anti-aliasing
|
||||
void setCallback(getColorCallback getCol);
|
||||
|
||||
void spiwrite(uint8_t); // legacy support only
|
||||
void writecommand(uint8_t c); // Send an 8-bit command, function resets DC/RS high ready for data
|
||||
void writedata(uint8_t d); // Send data with DC/RS set high
|
||||
|
||||
void commandList(const uint8_t *addr); // Send a initialisation sequence to TFT stored in FLASH
|
||||
|
||||
uint8_t readcommand8( uint8_t cmd_function, uint8_t index = 0); // read 8 bits from TFT
|
||||
uint16_t readcommand16(uint8_t cmd_function, uint8_t index = 0); // read 16 bits from TFT
|
||||
uint32_t readcommand32(uint8_t cmd_function, uint8_t index = 0); // read 32 bits from TFT
|
||||
|
||||
|
||||
// Colour conversion
|
||||
// Convert 8-bit red, green and blue to 16 bits
|
||||
uint16_t color565(uint8_t red, uint8_t green, uint8_t blue);
|
||||
@@ -299,15 +280,8 @@ class TFT_eSPI { friend class TFT_eSprite;
|
||||
|
||||
// 16-bit colour alphaBlend with alpha dither (dither reduces colour banding)
|
||||
uint16_t alphaBlend(uint8_t alpha, uint16_t fgc, uint16_t bgc, uint8_t dither);
|
||||
// 24-bit colour alphaBlend with optional alpha dither
|
||||
uint32_t alphaBlend24(uint8_t alpha, uint32_t fgc, uint32_t bgc, uint8_t dither = 0);
|
||||
|
||||
bool initDMA(bool ctrl_cs = false); // Initialise the DMA engine and attach to SPI bus - typically used in setup()
|
||||
// Push a block of pixels into a window set up using setAddrWindow()
|
||||
void pushPixelsDMA(uint16_t* image, uint32_t len);
|
||||
|
||||
// Check if the DMA is complete - use while(tft.dmaBusy); for a blocking wait
|
||||
bool dmaBusy(); // returns true if DMA is still in progress
|
||||
void dmaWait(); // wait until DMA is complete
|
||||
|
||||
bool DMA_Enabled = false; // Flag for DMA enabled state
|
||||
@@ -319,7 +293,6 @@ class TFT_eSPI { friend class TFT_eSprite;
|
||||
void endWrite(); // End SPI transaction
|
||||
|
||||
// Global variables
|
||||
static SPIClass& getSPIinstance(); // Get SPI class handle
|
||||
uint32_t textcolor, textbgcolor; // Text foreground and background colours
|
||||
|
||||
uint32_t bitmap_fg, bitmap_bg; // Bitmap foreground (bit=1) and background (bit=0) colours
|
||||
|
||||
@@ -9,31 +9,7 @@
|
||||
#define SPI_READ_FREQUENCY 20000000
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
#define TFT_BGR 0 // Colour order Blue-Green-Red
|
||||
#define TFT_RGB 1 // Colour order Red-Green-Blue
|
||||
|
||||
#define TFT_WIDTH 240
|
||||
#define TFT_HEIGHT 320
|
||||
|
||||
#include <ILI9341_Defines.h>
|
||||
#define TFT_DRIVER 0x9341
|
||||
|
||||
#define PIN_D0 16 // GPIO16 WAKE
|
||||
#define PIN_D1 5 // GPIO5 User purpose
|
||||
#define PIN_D2 4 // GPIO4 User purpose
|
||||
#define PIN_D3 0 // GPIO0 Low on boot means enter FLASH mode
|
||||
#define PIN_D4 2 // GPIO2 TXD1 (must be high on boot to go to UART0 FLASH mode)
|
||||
#define PIN_D5 14 // GPIO14 HSCLK
|
||||
#define PIN_D6 12 // GPIO12 HMISO
|
||||
#define PIN_D7 13 // GPIO13 HMOSI RXD2
|
||||
#define PIN_D8 15 // GPIO15 HCS TXD0 (must be low on boot to enter UART0 FLASH mode)
|
||||
#define PIN_D9 3 // RXD0
|
||||
#define PIN_D10 1 // TXD0
|
||||
|
||||
#define PIN_MOSI 8 // SD1
|
||||
#define PIN_MISO 7 // SD0
|
||||
#define PIN_SCLK 6 // CLK
|
||||
#define PIN_HWCS 0 // D3
|
||||
|
||||
#define PIN_D11 9 // SD2
|
||||
#define PIN_D12 10 // SD4
|
||||
|
||||
Reference in New Issue
Block a user