Code:
Index: Adafruit_ST7735.cpp
===================================================================
--- Adafruit_ST7735.cpp (revision 61)
+++ Adafruit_ST7735.cpp (working copy)
@@ -1,10 +1,15 @@
-/***************************************************
+/***************************************************
This is a library for the Adafruit 1.8" SPI display.
- This library works with the Adafruit 1.8" TFT Breakout w/SD card
+
+This library works with the Adafruit 1.8" TFT Breakout w/SD card
----> http://www.adafruit.com/products/358
- as well as Adafruit raw 1.8" TFT display
+The 1.8" TFT shield
+ ----> https://www.adafruit.com/product/802
+The 1.44" TFT breakout
+ ----> https://www.adafruit.com/product/2088
+as well as Adafruit raw 1.8" TFT display
----> http://www.adafruit.com/products/618
-
+
Check out the links above for our tutorials and wiring diagrams
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional)
@@ -25,7 +30,7 @@
// Constructor when using software SPI. All output pins are configurable.
Adafruit_ST7735::Adafruit_ST7735(uint8_t cs, uint8_t rs, uint8_t sid,
- uint8_t sclk, uint8_t rst) : Adafruit_GFX(ST7735_TFTWIDTH, ST7735_TFTHEIGHT)
+ uint8_t sclk, uint8_t rst) : Adafruit_GFX(ST7735_TFTWIDTH, ST7735_TFTHEIGHT_18)
{
_cs = cs;
_rs = rs;
@@ -39,7 +44,7 @@
// Constructor when using hardware SPI. Faster, but must use SPI pins
// specific to each board type (e.g. 11,13 for Uno, 51,52 for Mega, etc.)
Adafruit_ST7735::Adafruit_ST7735(uint8_t cs, uint8_t rs, uint8_t rst) :
- Adafruit_GFX(ST7735_TFTWIDTH, ST7735_TFTHEIGHT) {
+ Adafruit_GFX(ST7735_TFTWIDTH, ST7735_TFTHEIGHT_18) {
_cs = cs;
_rs = rs;
_rst = rst;
@@ -233,6 +238,8 @@
if (pin == 2 || pin == 6 || pin == 9) return true;
if (pin == 10 || pin == 15) return true;
if (pin >= 20 && pin <= 23) return true;
+ Serial.print ("spi_pin_is_cs failed, ");
+ Serial.println (pin);
return false;
}
@@ -249,6 +256,8 @@
case 22: CORE_PIN22_CONFIG = PORT_PCR_MUX(2); return 0x08; // PTC1
case 15: CORE_PIN15_CONFIG = PORT_PCR_MUX(2); return 0x10; // PTC0
}
+ Serial.print ("spi_configure_cs_pin failed, ");
+ Serial.println (pin);
return 0;
}
@@ -467,6 +476,15 @@
0x00, 0x00, // XSTART = 0
0x00, 0x9F }, // XEND = 159
+ Rcmd2green144[] = { // Init for 7735R, part 2 (green 1.44 tab)
+ 2, // 2 commands in list:
+ ST7735_CASET , 4 , // 1: Column addr set, 4 args, no delay:
+ 0x00, 0x00, // XSTART = 0
+ 0x00, 0x7F, // XEND = 127
+ ST7735_RASET , 4 , // 2: Row addr set, 4 args, no delay:
+ 0x00, 0x00, // XSTART = 0
+ 0x00, 0x7F }, // XEND = 127
+
Rcmd3[] = { // Init for 7735R, part 3 (red or green tab)
4, // 4 commands in list:
ST7735_GMCTRP1, 16 , // 1: Magical unicorn dust, 16 args, no delay:
@@ -572,7 +590,7 @@
csport ->PIO_CODR |= cspinmask; // Set control bits to LOW (idle)
-#elif defined(__MK20DX128__) || defined(__MK20DX256__)
+#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
if (_sid == (uint8_t)-1) _sid = 11;
if (_sclk == (uint8_t)-1) _sclk = 13;
if ( spi_pin_is_cs(_cs) && spi_pin_is_cs(_rs)
@@ -701,6 +719,11 @@
commandList(Rcmd2green);
colstart = 2;
rowstart = 1;
+ } else if(options == INITR_144GREENTAB) {
+ _height = ST7735_TFTHEIGHT_144;
+ commandList(Rcmd2green144);
+ colstart = 2;
+ rowstart = 3;
} else {
// colstart, rowstart left at default '0' values
commandList(Rcmd2red);
@@ -811,7 +834,12 @@
writedata(MADCTL_MX | MADCTL_MY | MADCTL_BGR);
}
_width = ST7735_TFTWIDTH;
- _height = ST7735_TFTHEIGHT;
+
+ if (tabcolor == INITR_144GREENTAB)
+ _height = ST7735_TFTHEIGHT_144;
+ else
+ _height = ST7735_TFTHEIGHT_18;
+
break;
case 1:
if (tabcolor == INITR_BLACKTAB) {
@@ -819,7 +847,12 @@
} else {
writedata(MADCTL_MY | MADCTL_MV | MADCTL_BGR);
}
- _width = ST7735_TFTHEIGHT;
+
+ if (tabcolor == INITR_144GREENTAB)
+ _width = ST7735_TFTHEIGHT_144;
+ else
+ _width = ST7735_TFTHEIGHT_18;
+
_height = ST7735_TFTWIDTH;
break;
case 2:
@@ -829,7 +862,11 @@
writedata(MADCTL_BGR);
}
_width = ST7735_TFTWIDTH;
- _height = ST7735_TFTHEIGHT;
+ if (tabcolor == INITR_144GREENTAB)
+ _height = ST7735_TFTHEIGHT_144;
+ else
+ _height = ST7735_TFTHEIGHT_18;
+
break;
case 3:
if (tabcolor == INITR_BLACKTAB) {
@@ -837,7 +874,11 @@
} else {
writedata(MADCTL_MX | MADCTL_MV | MADCTL_BGR);
}
- _width = ST7735_TFTHEIGHT;
+ if (tabcolor == INITR_144GREENTAB)
+ _width = ST7735_TFTHEIGHT_144;
+ else
+ _width = ST7735_TFTHEIGHT_18;
+
_height = ST7735_TFTWIDTH;
break;
}
Index: Adafruit_ST7735.h
===================================================================
--- Adafruit_ST7735.h (revision 61)
+++ Adafruit_ST7735.h (working copy)
@@ -1,10 +1,15 @@
/***************************************************
This is a library for the Adafruit 1.8" SPI display.
- This library works with the Adafruit 1.8" TFT Breakout w/SD card
+
+This library works with the Adafruit 1.8" TFT Breakout w/SD card
----> http://www.adafruit.com/products/358
- as well as Adafruit raw 1.8" TFT display
+The 1.8" TFT shield
+ ----> https://www.adafruit.com/product/802
+The 1.44" TFT breakout
+ ----> https://www.adafruit.com/product/2088
+as well as Adafruit raw 1.8" TFT display
----> http://www.adafruit.com/products/618
-
+
Check out the links above for our tutorials and wiring diagrams
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional)
@@ -44,8 +49,16 @@
#define INITR_REDTAB 0x1
#define INITR_BLACKTAB 0x2
+#define INITR_18GREENTAB INITR_GREENTAB
+#define INITR_18REDTAB INITR_REDTAB
+#define INITR_18BLACKTAB INITR_BLACKTAB
+#define INITR_144GREENTAB 0x1
+
#define ST7735_TFTWIDTH 128
-#define ST7735_TFTHEIGHT 160
+// for 1.44" display
+#define ST7735_TFTHEIGHT_144 128
+// for 1.8" display
+#define ST7735_TFTHEIGHT_18 160
#define ST7735_NOP 0x00
#define ST7735_SWRESET 0x01
@@ -100,7 +113,7 @@
#define ST7735_GREEN 0x07E0
#define ST7735_CYAN 0x07FF
#define ST7735_MAGENTA 0xF81F
-#define ST7735_YELLOW 0xFFE0
+#define ST7735_YELLOW 0xFFE0
#define ST7735_WHITE 0xFFFF