#include <Adafruit_ILI9341.h>
#include <Adafruit_GFX.h>
#include <SPI.h>
#define TFT_RST 6
#define TFT_DC 5
#define TFT_CS 10
#define TFT_MOSI 11
#define TFT_MISO 12
#define TFT_CLK 13
const uint16_t BLACK = 0x0000;
const uint16_t GREY = 0x7AEF;
const uint16_t BLUE = 0x001F;
const uint16_t RED = 0xF800;
const uint16_t GREEN = 0x07E0;
const uint16_t CYAN = 0x07FF;
const uint16_t MAGENTA = 0xF81F;
const uint16_t YELLOW = 0xFFE0;
const uint16_t WHITE = 0xFFFF;
float hum1; //Stores humidity value
float temp1; //Stores temperature value
float hum2; //Stores humidity value
float temp2; //Stores temperature value
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
int16_t r; // determines the radius of the corner
int16_t x; // horizontal starting position
int16_t y; // verticle starting postion
int16_t w; // width
int16_t h; // height
int color;
void drawTheThing(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, int color) {
int i = 0;
int lH = 1;
tft.fillRect((x + r - 1), y, (w - 2 * r + 2), lH, color);
for (i = 1; i < (r - 2); i++) {
tft.fillRect((x + r - 2 - i), (y + i), (w + 2 * i - 2 * r + 4), lH, color);
tft.fillRect((x + i), (y + i + h - r + 1), (w - 2 * i), lH, color);
}
tft.fillRect((x + r - i - 1), (y + i), (w + 2 * i - 2 * r + 2), lH, color);
tft.fillRect((x + r - i - 2), (y + i + 1), (w + 2 * i - 2 * r + 4), lH, color);
tft.fillRect((x + r - i - 2), (y + i + 2), (w + 2 * i - 2 * r + 4), (h - 2 * r + 1), color);
tft.fillRect((x + 1), (y + h - r + 1), (w - 2), lH, color);
tft.fillRect((x + i + 1), (y + i - r + h + 1), (w - 2 * i - 2), lH, color);
i = 0;
}
void setup() {
// put your setup code here, to run once:
tft.begin();
//tft.fillScreen(ILI9341_BLACK);
//drawTheThing(10, 10, 100, 300, 7, ILI9341_GREEN); // Custom function
//tft.fillRoundRect(130, 10, 100, 300, 8, ILI9341_RED); // Builtin to Adafruit_GFX
//tft.begin();
tft.setRotation(3);
tft.setTextSize(2);
tft.setTextColor(GREEN);
// tft.setTextColor(RED);
tft.fillScreen(BLACK);
tft.fillRect(250, 140, 5, 90, RED);
tft.fillRect(50, 140, 5, 90, RED);
tft.fillRect(255, 135, 5, 5, RED);
tft.fillRect(45, 135, 5, 5, RED);
tft.fillRect(250, 130, 5, 5, RED);
tft.fillRect(50, 130, 5, 5, RED);
tft.fillRect(245, 125, 5, 5, RED);
tft.fillRect(55, 125, 5, 5, RED);
tft.fillRect(240, 120, 5, 5, RED);
tft.fillRect(60, 120, 5, 5, RED);
tft.fillRect(235, 115, 5, 5, RED);
tft.fillRect(65, 115, 5, 5, RED);
tft.fillRect(230, 110, 5, 5, RED);
tft.fillRect(70, 110, 5, 5, RED);
tft.fillRect(225, 105, 5, 5, RED);
tft.fillRect(75, 105, 5, 5, RED);
tft.fillRect(220, 100, 5, 5, RED);
tft.fillRect(80, 100, 5, 5, RED);
tft.fillRect(215, 95, 5, 5, RED);
tft.fillRect(85, 95, 5, 5, RED);
tft.fillRect(210, 90, 5, 5, RED);
tft.fillRect(90, 90, 5, 5, RED);
tft.fillRect(205, 85, 5, 5, RED);
tft.fillRect(95, 85, 5, 5, RED);
tft.fillRect(200, 80, 5, 5, RED);
tft.fillRect(100, 80, 5, 5, RED);
tft.fillRect(195, 75, 5, 5, RED);
tft.fillRect(105, 75, 5, 5, RED);
tft.fillRect(190, 70, 5, 5, RED);
tft.fillRect(110, 70, 5, 5, RED);
tft.fillRect(185, 65, 5, 5, RED);
tft.fillRect(115, 65, 5, 5, RED);
tft.fillRect(180, 60, 5, 5, RED);
tft.fillRect(120, 60, 5, 5, RED);
tft.fillRect(175, 55, 5, 5, RED);
tft.fillRect(125, 55, 5, 5, RED);
tft.fillRect(170, 50, 5, 5, RED);
tft.fillRect(130, 50, 5, 5, RED);
tft.fillRect(165, 45, 5, 5, RED);
tft.fillRect(135, 45, 5, 5, RED);
tft.fillRect(160, 40, 5, 5, RED);
tft.fillRect(140, 40, 5, 5, RED);
tft.fillRect(155, 35, 5, 5, RED);
tft.fillRect(145, 35, 5, 5, RED);
tft.fillRect(150, 30, 5, 5, RED);
tft.drawLine(85,37,101,37,YELLOW);
tft.drawLine(85,38,101,38,YELLOW);
tft.drawLine(85,39,101,39,YELLOW);
tft.drawLine(85,40,101,40,YELLOW);
tft.drawLine(85,41,85,53,YELLOW);
tft.drawLine(86,41,86,53,YELLOW);
tft.drawLine(87,41,87,53,YELLOW);
tft.drawLine(88,41,88,53,YELLOW);
tft.drawLine(117,135,133,135,YELLOW);
tft.drawLine(118,134,133,134,YELLOW);
tft.drawLine(119,133,133,133,YELLOW);
tft.drawLine(119,132,133,132,YELLOW);
tft.drawLine(115,135,115,119,YELLOW);
tft.drawLine(116,135,116,119,YELLOW);
tft.drawLine(117,135,117,119,YELLOW);
tft.drawLine(118,135,118,119,YELLOW);
tft.drawLine(90,41,186,135,YELLOW); //start: (0, 0) end: (239, 319), color : RED
tft.drawLine(89,41,185,135,YELLOW);
tft.drawLine(89,42,184,135,YELLOW);
tft.drawLine(120,131,215,42,YELLOW);
tft.drawLine(119,130,214,41,YELLOW);
tft.drawLine(119,131,215,41,YELLOW);
//tft.drawLine(85,40,101,40,RED);
//tft.fillRect(215,42, 1, 1, GREEN);
//tft.fillRect(89,42, 5, 5, RED);
tft.setCursor(170, 160);
tft.println(hum1, 1);
tft.setCursor(225, 160);
tft.println("%");
tft.setCursor(170, 140);
tft.println(temp1, 1);
tft.setCursor(225, 140);
tft.println("C");
tft.setCursor(60, 160);
tft.println(hum2, 1 );
tft.setCursor(130, 160);
tft.println("%");
tft.setCursor(60, 140);
tft.println(temp2, 1);
tft.setCursor(130, 140);
tft.println("C");
tft.setCursor(90, 210);
tft.setTextColor(YELLOW, BLACK);
tft.setTextSize(2);
tft.println("PWM = ");
tft.setCursor(220, 210);
tft.println("P = ");
}
void loop() {
// put your main code here, to run repeatedly:
}