#include <Adafruit_GFX.h> // https://github.com/adafruit/Adafruit-GFX-Library
#include <Adafruit_ILI9341.h> // https://github.com/adafruit/Adafruit_ILI9341
// #include <Adafruit_BusIO.h> //https://github.com/adafruit/Adafruit_BusIO
// ansi
// https://gist.github.com/ConnerWill/d4b6c776b509add763e17f9f113fd25b
// https://forum.arduino.cc/t/ansi-output-in-serial-monitor/1443596
#define TFT_MISO 15
#define TFT_CLK 18
#define TFT_MOSI 23
#define TFT_DC 2 // incorrect DC to screen pin gives white screen
#define TFT_RST 4
#define TFT_CS 5
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(115200);
tft.begin();
tft.setRotation(1);
tft.setTextSize(1);
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
// Serial.println(tft.width());
// Serial.println(tft.height());
nessoN1();
}
void loop() {
delay(10);
}
void nessoN1() {
int nessoW = 240;
int nessoH = 135;
int startX = (tft.width() - nessoW) / 2;
int startY = (tft.height() - nessoH) / 2;
tft.drawRect(startX, startY, nessoW, nessoH, ILI9341_WHITE);
tft.setCursor(0,0); tft.print("Nesso N1 Screen");
tft.setCursor(0,10); tft.print("startX: "); tft.print(startX);
tft.setCursor(0,20); tft.print("startY: "); tft.print(startY);
}
void text() {
int x = 45, y = 160;
tft.setCursor(x, y);
tft.print("Hello, World!");
}
void pixel() {
int y = 180, color = ILI9341_YELLOW;
for (int x = 80; x < 180; x += 5) // increase left to right
tft.drawPixel(x, y, color);
}
void line() {
int xStart = 0, yStart = 0, xEnd = 240, yEnd = 320, color = ILI9341_RED;
tft.drawLine(xStart, yStart, xEnd, yEnd, color);
}
void rect() {
int x = 40, y = 150, width = 160, height = 40, color = ILI9341_CYAN;
tft.drawRect(x, y, width, height, color);
}
void circle() {
int x = 120, y = 170, radius = 90, color = ILI9341_GREEN;
tft.drawCircle(x, y, radius, color);
}
void test() {
uint8_t x = tft.readcommand8(ILI9341_RDMODE);
Serial.println();
Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDMADCTL);
Serial.print("MADCTL Mode : 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDPIXFMT);
Serial.print("Pixel Format : 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDIMGFMT);
Serial.print("Image Format : 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDSELFDIAG);
Serial.print("Self Diagnostic : 0x"); Serial.println(x, HEX);
while (1);
}