/*
Just testing the ILI9341 Display with ESP32
*/
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup() {
pinMode(13, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
tft.begin();
tft.setRotation(1);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(25, 80);
tft.setTextSize(6);
tft.print("BOOTING");
delay(500);
tft.fillScreen(ILI9341_BLACK);
}
bool bal;
bool jobb;
bool gomb;
bool maxmin = HIGH;
int kor1=150;
int kor2=70;
int comax = 1100;
int comin = 800;
int szunet = 1;
void loop()
{
do
{
int battery = 60;
if (battery >=70)
tft.setTextColor(ILI9341_GREEN);
if (battery <70&&battery>30)
tft.setTextColor(ILI9341_ORANGE);
if (battery <=30)
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.setCursor(110, 10);
tft.print("Battery:");
tft.setCursor(250, 10);
tft.print(battery);
tft.setCursor(290, 10);
tft.print("%");
tft.setTextColor(ILI9341_GREENYELLOW);
tft.setCursor(250, 50);
tft.print("28");
tft.setCursor(290, 50);
tft.print("C");
tft.drawCircle(315, 50, 5, ILI9341_WHITE);
tft.drawCircle(315, 50, 4, ILI9341_WHITE);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(4);
tft.setCursor(15, 100);
tft.print("Co2: ");
tft.setCursor(110, 100);
tft.print("1100");
tft.setCursor(210, 100);
tft.print("ppm");
tft.setTextColor(ILI9341_CYAN);
tft.setTextSize(3);
tft.setCursor(0, 50);
tft.print("Humi:");
tft.setCursor(90, 50);
tft.print("50");
tft.setCursor(130, 50);
tft.print("%");
tft.setTextColor(ILI9341_GREEN);
tft.setCursor(0, 150);
tft.print("Max Co2: ");
tft.setCursor(140, 150);
tft.print(comax);
tft.setTextColor(ILI9341_RED);
tft.setCursor(0, 180);
tft.print("Min Co2: ");
tft.setCursor(140, 180);
tft.print(comin);
tft.setTextColor(ILI9341_OLIVE);
tft.setCursor(70, 210);
tft.print("Next scan:");
tft.setCursor(250, 210);
tft.print("100");
gomb = digitalRead(12);
} while (gomb!=LOW);
for (int i; i=1000;i++)
{
gomb = digitalRead(12);
jobb = digitalRead(14);
bal = digitalRead(13);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(5);
tft.setCursor(0, 10);
tft.print("Max Co");
tft.setCursor(190, 10);
tft.print(comax);
tft.drawLine(10,80, 280, 80, ILI9341_WHITE);
tft.fillCircle(kor1, 80, 8, ILI9341_WHITE);
tft.setCursor(0, 120);
tft.print("Min Co");
tft.setCursor(190, 120);
tft.print(comin);
tft.drawLine(10,200, 280, 200, ILI9341_WHITE);
tft.fillCircle(kor2, 200, 8, ILI9341_WHITE);
if (gomb == LOW)
{
maxmin = !maxmin;
delay(szunet);
}
if (maxmin == LOW)
tft.fillCircle(kor1, 80, 3, ILI9341_RED);
delay(szunet);
if (maxmin == HIGH)
tft.fillCircle(kor2, 200, 3, ILI9341_RED);
delay(szunet);
if (maxmin==LOW && bal == LOW)
{
kor1 = kor1-5;
comax = comax-10;
delay(szunet);
}
if (maxmin==LOW && jobb == LOW)
{
kor1= kor1+5;
comax=comax+10;
delay(szunet);
}
if (maxmin==HIGH && bal == LOW)
{
kor2 = kor2-5;
comin = comin-10;
delay(szunet);
}
if (maxmin==HIGH &&jobb == LOW)
{
kor2 = kor2+5;
comin = comin+10;
delay(szunet);
}
delay(10);
}
}