#include <Adafruit_GFX.h> // Core graphics library
#include <ST7735_t3.h> // Hardware-specific library
#include <ST7789_t3.h> // Hardware-specific library
#include <SPI.h>
#if defined(__IMXRT1052__) || defined(__IMXRT1062__) // Teensy 4.x
//#define USE_SPI2
//#define NON_SPI_PINS
#ifdef USE_SPI2
#define TFT_SCLK 37 // SCLK can also use pin 14
#define TFT_MOSI 35 // MOSI can also use pin 7
#elif defined(NON_SPI_PINS)
#define TFT_SCLK 7 // SCLK can also use pin 14
#define TFT_MOSI 8 // MOSI can also use pin 7
#else
#define TFT_SCLK 13 // SCLK can also use pin 14
#define TFT_MOSI 11 // MOSI can also use pin 7
#endif
#define TFT_CS 10 // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
#define TFT_DC 9 // but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
#define TFT_RST 23 // RST can use any pin
#define SD_CS 4 // CS for SD card, can use any pin
#else
// T3.X
//#define USE_SPI1
#define USE_SPI2
#ifdef USE_SPI1
#define TFT_SCLK 32 // T3.5/T3.6
#define TFT_MOSI 0 //
#define TFT_CS 10 // random digital pin
#define TFT_DC 31 // Only Hardware CS pin on SPI1
#elif defined(USE_SPI2)
#define TFT_SCLK 46 // T3.5/T3.6
#define TFT_MOSI 44 //
#define TFT_CS 54 // Hardware CS on SPI2
#define TFT_DC 55 // Hardware CS pin on SPI2
#else
#define TFT_SCLK 13 // SCLK can also use pin 14
#define TFT_MOSI 11 // MOSI can also use pin 7
#define TFT_CS 10 // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
#define TFT_DC 9 // but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
#endif
#define TFT_RST 8 // RST can use any pin
#define SD_CS 4 // CS for SD card, can use any pin
#endif
// Option 1: use any pins but a little slower
//ST7735_t3 tft = ST7735_t3(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
ST7789_t3 tft = ST7789_t3(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
// Option 2: must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
//ST7735_t3 tft = ST7735_t3(cs, dc, rst);
float p = 3.1415926;
void setup(void) {
pinMode(SD_CS, INPUT_PULLUP); // don't touch the SD card
Serial.begin(9600);
Serial.print("hello!");
// Use this initializer if you're using a 1.8" TFT
//tft.initR(INITR_BLACKTAB);
// Use this initializer (uncomment) if you're using a 1.44" TFT
//tft.initR(INITR_144GREENTAB);
tft.init(240,240); // use for ILI9488
Serial.println("init");
}
uint8_t rotation = 0;
void loop() {
tft.setRotation(rotation);
Serial.printf("Set Rotation: %d width: %d height: %d\n", rotation, tft.width(), tft.height());
rotation = (rotation + 1) & 0x3;
elapsedMillis timer;
uint16_t time = millis();
tft.fillScreen(ST7735_RED);
tft.fillRect(tft.width()/2-32, 20, 64, tft.height()-40, ST7735_GREEN);
tft.fillRect(0, 0, 8, 8, ST7735_BLACK);
tft.fillRect(tft.width()-8, tft.height()-8, 8, 8, ST7735_WHITE);
// large block of text
//delay(2500);
Serial.println("Hit any key to continue");
while (!Serial.available()) ;
while (Serial.read() != -1) ;
}