// trek-80
// #include <SPI.h>
#include <Adafruit_GFX.h> // https://github.com/adafruit/Adafruit-GFX-Library
// https://learn.adafruit.com/adafruit-gfx-graphics-library/graphics-primitives
#include <Adafruit_ILI9341.h> // https://github.com/adafruit/Adafruit_ILI9341
#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10
#define TFT_MOSI 11
#define TFT_MISO 12
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define HALF_WIDTH SCREEN_WIDTH / 2
#define HALF_HEIGHT SCREEN_HEIGHT / 2
int rowHeight = 8, colWidth = 33;
int row = 3, col = 3, chr = 0;
#define RED 0xF800 // 565 0b 11111 000000 00000 // https://rgbcolorpicker.com/565
#define ORG 0xFC00 // 565 0b 11111 100000 00000
#define YEL 0xFFE0 // 565 0b 11111 111111 00000
#define GRN 0x07E0 // 565 0b 00000 111111 00000
#define CYN 0x07FF // 565 0b 00000 111111 11111
#define BLU 0x001F // 565 0b 00000 000000 11111
#define MAG 0xF81F // 565 0b 11111 000000 11111
#define WHT 0xFFFF // 565 0b 11111 111111 11111
#define GRY 0xC618 // 565 0b 11000 110000 11000
#define BLK 0x0000 // 565 0b 00000 000000 00000
void setup() {
Serial.begin(115200);
tft.begin();
tft.setRotation(3); // rotate 270 degrees
// helloWorld();
}
void loop() {
}
void helloWorld() {
tft.drawPixel(100, 10, WHT);
tft.drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, WHT);
char text[] = {"Hello, World!"};
int textwidth = sizeof(text) / sizeof(text[0]);
int lineheight = 7;
tft.drawLine(HALF_WIDTH, 0, HALF_WIDTH, HALF_HEIGHT - lineheight / 2 - 2, WHT);
tft.drawLine(HALF_WIDTH, HALF_HEIGHT + lineheight / 2 + 2, HALF_WIDTH, SCREEN_HEIGHT, WHT);
tft.drawLine(0, HALF_HEIGHT, HALF_WIDTH - ((textwidth / 2) * 6) - 2, HALF_HEIGHT, WHT);
tft.drawLine(HALF_WIDTH + (((textwidth - 1) / 2) * 6), HALF_HEIGHT, SCREEN_WIDTH, HALF_HEIGHT, WHT);
tft.setCursor(HALF_WIDTH - (textwidth * 3), HALF_HEIGHT - lineheight * 1 / 2);
tft.setTextSize(1);
tft.setTextColor(GRN);
tft.write(text);
Serial.println(text);
}
// https://en.wikipedia.org/wiki/Trek-80
// https://archive.org/details/manualzilla-id-5711820
// https://zeitgame.net/archives/10609