mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-08-01 19:54:43 +02:00
Add support for ST7735 128x128 TFT
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
// Change the width and height if required (defined in portrait mode)
|
||||
// or use the constructor to over-ride defaults
|
||||
#define TFT_WIDTH 128
|
||||
#define TFT_HEIGHT 160
|
||||
#ifndef TFT_WIDTH
|
||||
#define TFT_WIDTH 128
|
||||
#endif
|
||||
#ifndef TFT_HEIGHT
|
||||
#define TFT_HEIGHT 160
|
||||
#endif
|
||||
|
||||
|
||||
// Enumerate the different configurations
|
||||
@@ -9,6 +13,7 @@
|
||||
#define INITR_REDTAB 0x1
|
||||
#define INITR_BLACKTAB 0x2
|
||||
#define INITR_GREENTAB2 0x3 // Use if you get random pixels on two edges of green tab display
|
||||
#define INITR_GREENTAB3 0x4 // Use if you get random pixels on edge(s) of 128x128 screen
|
||||
#define INITB 0xB
|
||||
|
||||
|
||||
@@ -22,6 +27,9 @@
|
||||
#elif defined (ST7735_GREENTAB2)
|
||||
#define TAB_COLOUR INITR_GREENTAB2
|
||||
|
||||
#elif defined (ST7735_GREENTAB3)
|
||||
#define TAB_COLOUR INITR_GREENTAB3
|
||||
|
||||
#elif defined (ST6635_REDTAB)
|
||||
#define TAB_COLOUR INITR_REDTAB
|
||||
|
||||
|
@@ -163,6 +163,12 @@
|
||||
colstart = 2;
|
||||
rowstart = 1;
|
||||
}
|
||||
else if (tabcolor == INITR_GREENTAB3)
|
||||
{
|
||||
commandList(Rcmd2green);
|
||||
colstart = 2;
|
||||
rowstart = 3;
|
||||
}
|
||||
else if (tabcolor == INITR_REDTAB)
|
||||
{
|
||||
commandList(Rcmd2red);
|
||||
|
@@ -12,6 +12,10 @@
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
|
||||
colstart = 2;
|
||||
rowstart = 1;
|
||||
} else if(tabcolor == INITR_GREENTAB3) {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
|
||||
colstart = 2;
|
||||
rowstart = 3;
|
||||
} else {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
|
||||
}
|
||||
@@ -24,6 +28,10 @@
|
||||
} else if(tabcolor == INITR_GREENTAB2) {
|
||||
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_RGB);
|
||||
colstart = 1;
|
||||
rowstart = 2;
|
||||
} else if(tabcolor == INITR_GREENTAB3) {
|
||||
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
colstart = 3;
|
||||
rowstart = 2;
|
||||
} else {
|
||||
writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
@@ -38,6 +46,10 @@
|
||||
writedata(TFT_MAD_RGB);
|
||||
colstart = 2;
|
||||
rowstart = 1;
|
||||
} else if(tabcolor == INITR_GREENTAB3) {
|
||||
writedata(TFT_MAD_BGR);
|
||||
colstart = 2;
|
||||
rowstart = 1;
|
||||
} else {
|
||||
writedata(TFT_MAD_BGR);
|
||||
}
|
||||
@@ -50,6 +62,10 @@
|
||||
} else if(tabcolor == INITR_GREENTAB2) {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB);
|
||||
colstart = 1;
|
||||
rowstart = 2;
|
||||
} else if(tabcolor == INITR_GREENTAB3) {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
colstart = 1;
|
||||
rowstart = 2;
|
||||
} else {
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
|
||||
|
12
TFT_eSPI.cpp
12
TFT_eSPI.cpp
@@ -1438,7 +1438,7 @@ inline void TFT_eSPI::setAddrWindow(int32_t xs, int32_t ys, int32_t xe, int32_t
|
||||
addr_col = 0xFFFF;
|
||||
addr_row = 0xFFFF;
|
||||
|
||||
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (GREENTAB2))
|
||||
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3))
|
||||
xs+=colstart;
|
||||
xe+=colstart;
|
||||
ys+=rowstart;
|
||||
@@ -1520,7 +1520,7 @@ inline void TFT_eSPI::setAddrWindow(int32_t x0, int32_t y0, int32_t x1, int32_t
|
||||
addr_col = 0xFFFF;
|
||||
addr_row = 0xFFFF;
|
||||
|
||||
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (GREENTAB2))
|
||||
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3))
|
||||
x0+=colstart;
|
||||
x1+=colstart;
|
||||
y0+=rowstart;
|
||||
@@ -1576,7 +1576,7 @@ void TFT_eSPI::readAddrWindow(int32_t xs, int32_t ys, int32_t xe, int32_t ye)
|
||||
addr_col = 0xFFFF;
|
||||
addr_row = 0xFFFF;
|
||||
|
||||
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (GREENTAB2))
|
||||
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3))
|
||||
xs+=colstart;
|
||||
xe+=colstart;
|
||||
ys+=rowstart;
|
||||
@@ -1641,7 +1641,7 @@ void TFT_eSPI::readAddrWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
|
||||
addr_col = 0xFFFF;
|
||||
addr_row = 0xFFFF;
|
||||
|
||||
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (GREENTAB2))
|
||||
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3))
|
||||
x0+=colstart;
|
||||
x1+=colstart;
|
||||
y0+=rowstart;
|
||||
@@ -1690,7 +1690,7 @@ void TFT_eSPI::drawPixel(uint32_t x, uint32_t y, uint32_t color)
|
||||
// Faster range checking, possible because x and y are unsigned
|
||||
if ((x >= _width) || (y >= _height)) return;
|
||||
|
||||
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (GREENTAB2))
|
||||
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3))
|
||||
x+=colstart;
|
||||
y+=rowstart;
|
||||
#endif
|
||||
@@ -1774,7 +1774,7 @@ void TFT_eSPI::drawPixel(uint32_t x, uint32_t y, uint32_t color)
|
||||
if ((x >= _width) || (y >= _height)) return;
|
||||
spi_begin();
|
||||
|
||||
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (GREENTAB2))
|
||||
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3))
|
||||
x+=colstart;
|
||||
y+=rowstart;
|
||||
#endif
|
||||
|
23
User_Setup.h
23
User_Setup.h
@@ -14,11 +14,30 @@
|
||||
// ##################################################################################
|
||||
|
||||
// Only define one driver, the other ones must be commented out
|
||||
//#define ILI9341_DRIVER
|
||||
#define ST7735_DRIVER
|
||||
#define ILI9341_DRIVER
|
||||
//#define ST7735_DRIVER
|
||||
//#define ILI9163_DRIVER
|
||||
//#define S6D02A1_DRIVER
|
||||
|
||||
// For ST7735 ONLY, define the type of display, originally this was based on the
|
||||
// colour of the tab on the screen protector film but this is not always true, so try
|
||||
// out the different options below if the screen does not display graphics correctly,
|
||||
// e.g. colours wrong, mirror images, or tray pixels at the edges.
|
||||
// Comment out ALL BUT ONE of these options for a ST7735 display driver, save this
|
||||
// this User_Setup file, then rebuild and upload the sketch to the board again:
|
||||
|
||||
//#define ST7735_INITB
|
||||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// For ST7735 ONLY, define the pixel width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
|
@@ -27,9 +27,15 @@
|
||||
//#define ST7735_INITB
|
||||
//#define ST7735_GREENTAB
|
||||
//#define ST7735_GREENTAB2
|
||||
//#define ST7735_GREENTAB3
|
||||
#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// For ST7735 ONLY define the width and height in portrait orientation
|
||||
#define TFT_WIDTH 128
|
||||
#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
|
@@ -32,6 +32,11 @@
|
||||
//#define ST7735_REDTAB
|
||||
//#define ST7735_BLACKTAB
|
||||
|
||||
// For ST7735 ONLY define the width and height in portrait orientation
|
||||
//#define TFT_WIDTH 128
|
||||
//#define TFT_HEIGHT 160
|
||||
//#define TFT_HEIGHT 128
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Define the pins that are used to interface with the display here
|
||||
|
Reference in New Issue
Block a user