#include "SPI.h"
#include "Adafruit_ILI9341.h"
#include "Adafruit_GFX.h"
#include "Fonts/FreeSans9pt7b.h"
#include "Fonts/FreeSans12pt7b.h"
#include "Fonts/FreeSansBold9pt7b.h"
#include "Fonts/FreeSansBold12pt7b.h"
#include "Fonts/FreeSansBoldOblique9pt7b.h"
#include "Fonts/FreeSansBoldOblique12pt7b.h"
#include "Fonts/FreeMono9pt7b.h"
#include "Fonts/FreeMono12pt7b.h"
#include "Fonts/FreeMonoBold9pt7b.h"
#include "Fonts/FreeMonoBold12pt7b.h"
#include "Fonts/FreeMonoBoldOblique9pt7b.h"
#include "Fonts/FreeMonoBoldOblique12pt7b.h"
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define LIGHT_BLUE 0x8EDF
#define LIGHT_GRAY 0xC618
#define TCS_pin 10
#define RST_pin 9
#define DC_pin 8
#define startButton 2
#define miscButton 3
bool startBtnState = false;
bool miscBtnState = false;
Adafruit_ILI9341 tft_display = Adafruit_ILI9341(TCS_pin, DC_pin, RST_pin);
void setup() {
tft_display.begin();
//tft_display.cp437(true);
tft_display.setRotation(1);
tft_display.setCursor(26, 120);
tft_display.setTextColor(RED);
tft_display.setTextSize(3);
tft_display.println("Hello, TFT!");
tft_display.setCursor(20, 160);
tft_display.setTextColor(GREEN);
tft_display.setTextSize(2);
tft_display.println("Ayo");
pinMode(startButton, INPUT_PULLUP);
pinMode(miscButton, INPUT_PULLUP);
}
void loop() {
if (digitalRead(startButton) == LOW) {
tft_display.fillScreen(WHITE);
inProgressScreen();
delay(5000);
resultScreen();
}
if (digitalRead(miscButton) == LOW) {
miscScreen();
}
}
void resultScreen() {
// tft_display.drawRoundRect(260, 10, 50, 18, 6, BLACK);
// tft_display.fillRoundRect(261, 11, 30, 16, 6, GREEN);
// tft_display.setCursor(275, 15);
// tft_display.setTextColor(BLACK);
// tft_display.setTextSize(1);
// tft_display.print("60%");
tft_display.setFont(&FreeSansBoldOblique12pt7b);
tft_display.fillRoundRect(16, 43, 289, 29, 4, BLACK);
tft_display.fillRoundRect(18, 45, 285, 25, 4, LIGHT_BLUE);
tft_display.setCursor(22, 63);
tft_display.setTextColor(BLACK);
tft_display.setTextSize(1);
tft_display.print("Algae Detection Results");
tft_display.fillRoundRect(16, 80, 289, 149, 5, BLACK);
tft_display.fillRoundRect(18, 82, 285, 145, 5, WHITE);
tft_display.setCursor(22, 120);
tft_display.setTextColor(BLACK);
tft_display.setTextSize(1);
tft_display.setFont(&FreeSansBold9pt7b);
tft_display.print("Algae Species:");
tft_display.setCursor(22, 190);
tft_display.setTextColor(BLACK);
tft_display.setTextSize(1);
tft_display.print("Concentration:");
tft_display.setCursor(180, 120);
tft_display.setTextColor(BLACK);
tft_display.setTextSize(1);
tft_display.setFont(&FreeSans9pt7b);
tft_display.print("Microcystis");
tft_display.setCursor(180, 190);
tft_display.setTextColor(BLACK);
tft_display.setTextSize(1);
tft_display.print("3000 cells/mL");
}
void inProgressScreen() {
tft_display.drawRoundRect(260, 10, 50, 18, 6, BLACK);
tft_display.fillRoundRect(261, 11, 30, 16, 6, GREEN);
tft_display.setCursor(275, 15);
tft_display.setTextColor(BLACK);
tft_display.setTextSize(1);
tft_display.print("60%");
tft_display.setFont(&FreeSansBoldOblique12pt7b);
tft_display.setCursor(50, 100);
tft_display.setTextColor(BLACK);
tft_display.setTextSize(1);
tft_display.print("Testing in Progress");
tft_display.fillCircle(tft_display.width()/4, 200, 20, LIGHT_GRAY);
tft_display.fillCircle(tft_display.width()/2, 200, 20, LIGHT_GRAY);
tft_display.fillCircle(tft_display.width()*(0.75), 200, 20, LIGHT_GRAY);
}
void startScreen() {
}
void miscScreen() {
tft_display.fillRoundRect(40, 100, 239, 99, 5, BLACK);
tft_display.fillRoundRect(42, 102, 235, 95, 5, WHITE);
}
int getBatteryLevel() {
return 1;
}