#include <FlickerFreePrint.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <SPI.h>
#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/FreeSans12pt7b.h>

#define PUP_LBLUE  0x051D
#define PUP_POISON 0xA7C9
#define C_BLACK    0x0000
#define C_BLUE     0x001F
#define C_RED      0xF800
#define C_GREEN    0x07E0
#define C_CYAN     0x07FF
#define C_MAGENTA  0xF81F
#define C_YELLOW   0xFFE0
#define C_WHITE    0xFFFF

#define TFT_RST 8
#define TFT_CS 10
#define TFT_DC 9

Adafruit_ST7789 GM02002 = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);

//Need one "line" for each element to update.
FlickerFreePrint<Adafruit_ST7789> Data1(&GM02002, C_WHITE, C_BLACK);
FlickerFreePrint<Adafruit_ST7789> Data2(&GM02002, C_WHITE, C_BLACK);
FlickerFreePrint<Adafruit_ST7789> Data3(&GM02002, C_WHITE, C_BLACK);
FlickerFreePrint<Adafruit_ST7789> Data4(&GM02002, C_WHITE, C_BLACK);
FlickerFreePrint<Adafruit_ST7789> Data5(&GM02002, C_WHITE, C_BLACK);
FlickerFreePrint<Adafruit_ST7789> Data6(&GM02002, C_WHITE, C_BLACK);
FlickerFreePrint<Adafruit_ST7789> Data7(&GM02002, C_WHITE, C_BLACK);
FlickerFreePrint<Adafruit_ST7789> Data8(&GM02002, C_WHITE, C_BLACK);

void setup() {
  // put your setup code here, to run once:
GM02002.init(240, 320, SPI_MODE3);
GM02002.setRotation(1);

GM02002.fillScreen(ST77XX_BLACK);
}

void loop() {
  // put your main code here, to run repeatedly:
GM02002.setFont(&FreeSans9pt7b);
GM02002.setCursor(2, 12);
//tft.setTextSize(2);
GM02002.setTextColor(PUP_POISON);
GM02002.println("Pontiac LeMans '69");
GM02002.drawLine(2, 18, 318, 18, PUP_POISON);
GM02002.drawLine(2, 19, 318, 19, PUP_POISON);

GM02002.setCursor(2, 46);
Data1.print("Temp Water: 85 'C");

GM02002.setCursor(2, 64);
Data2.print("Temp Oil: 96'C");

GM02002.setCursor(2, 82);
Data3.print("Pressure Oil: 2.23 b");

GM02002.setCursor(2, 100);
Data4.print("Fan Speed: 44%");

GM02002.setCursor(2, 136);
Data5.print("O2 Left Bank: 14.6");

GM02002.setCursor(2, 154);
Data6.print("O2 Right Bank: 14.5");

GM02002.setCursor(2, 172);
Data7.print("Vacuum (In.Hg): 4.2");

GM02002.setCursor(2, 190);
Data8.print("RPM: 1347");

delay(5000);
//tft.fillScreen(ST77XX_BLACK);

GM02002.setFont(&FreeSans9pt7b);
GM02002.setCursor(2, 12);
//tft.setTextSize(2);
GM02002.setTextColor(PUP_POISON);
GM02002.println("Pontiac LeMans '69");
GM02002.drawLine(2, 18, 318, 18, PUP_POISON);
GM02002.drawLine(2, 19, 318, 19, PUP_POISON);

GM02002.setCursor(2, 46);
Data1.print("Temp Water: 96 'C");

GM02002.setCursor(2, 64);
Data2.print("Temp Oil: 11'C");

GM02002.setCursor(2, 82);
Data3.print("Pressure Oil: 3.23 b");

GM02002.setCursor(2, 100);
Data4.print("Fan Speed: 87%");

GM02002.setCursor(2, 136);
Data5.print("O2 Left Bank: 12.4");

GM02002.setCursor(2, 154);
Data6.print("O2 Right Bank: 12.7");

GM02002.setCursor(2, 172);
Data7.print("Vacuum (In.Hg): 17.5");

GM02002.setCursor(2, 190);
Data8.print("RPM: 4712");

delay(5000);
//tft.fillScreen(ST77XX_BLACK);
}

/* LED = 3v3
SCK = 13
SDA = 11
AO = 9
RESET = 8
CS = 10
GND = GND
VCC = 5v
*/