/*
Simple "Hello World" for ILI9341 LCD
https://wokwi.com/arduino/projects/308024602434470466
https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
*/
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
String fuses[]={"LPWSP","LHORN","LMIDB","LFILL","SUBFR","MOBDG",
"RPWSP","RHORN","RM1DB","RFILL","SUBRR","BXDSP"};
//#include <Fonts/FreeMonoBoldOblique12pt7b.h>
//#include <Fonts/FreeMonoBoldOblique18pt7b.h>
//#include <Fonts/FreeSansBold9pt7b.h>
#include <Fonts/FreeSansBold12pt7b.h>
#include <Fonts/FreeMono12pt7b.h>
#include <Fonts/FreeSerifBoldItalic12pt7b.h>
#define TFT_DC 9
#define TFT_CS 10
#define F1 2
#define F2 3
#define F3 4
#define F4 5
#define F5 6
#define F6 7
#define F7 8
#define F8 A0
#define F9 A1
#define F10 A2
#define F11 A3
#define F12 A4
int fusePin[]={F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12};
const int circleR = 10;
const int xOffset =170;
const int xOffset2 = 260;
const int yOffset= 35;
const int xStart = 10;
const int yStart = 55;
int xPos ;
int yPos;
float voltage;
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup() {
Serial.begin(57600);
tft.begin();
tft.fillScreen(ILI9341_BLACK);
//tft.setFont(&FreeMonoBoldOblique12pt7b);
//tft.setFont(&FreeSansBold9pt7b);
//tft.setFont(&FreeSans12pt7b);
tft.setFont(&FreeMono12pt7b);
//tft.setFont(&FreeMonoBold12pt7b);
tft.setRotation(1);
tft.setTextSize(1);
tft.fillRect(5,0,300,30,ILI9341_BLUE);
tft.setTextColor(ILI9341_YELLOW);
tft.setCursor(10, 23);
tft.setFont(&FreeSansBold12pt7b);
tft.println("FUSE STATUS ");
yPos = 0;
tft.setTextSize(1);
tft.setTextColor(ILI9341_WHITE);
tft.setFont(&FreeMono12pt7b);
for(int i = 0;i<=5;i++){
tft.setCursor(xStart, yStart+yPos);
tft.println(fuses[i]);
tft.setCursor(xStart+xOffset, yStart+yPos);
tft.println(fuses[i+6]);
yPos +=yOffset;
}
}
void loop() {
yPos=yStart-6;
for(int i = 0;i<6;i++){
if(digitalRead(fusePin[i])==1)
tft.fillCircle(110, yPos, circleR, ILI9341_GREEN);
else
tft.fillCircle(110, yPos, circleR, ILI9341_RED);
if(digitalRead(fusePin[i+6])==1)
tft.fillCircle(270, yPos, circleR, ILI9341_GREEN);
else
tft.fillCircle(270, yPos, circleR, ILI9341_RED);
yPos +=yOffset;
}
tft.setCursor(230,23);
tft.setTextColor(ILI9341_WHITE);
tft.setFont(&FreeSerifBoldItalic12pt7b);
//tft.println(analogRead(A5));
voltage=analogRead(A5)*5.0*34/10240;
tft.fillRect(230,0,90,30,ILI9341_BLUE);
tft.print(voltage);
tft.print("V");
Serial.println(voltage);
delay(500);
}