//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Arduino TFT Touchscreen DHT22 & Control LED
//----------------------------------------Include Library
#include <Adafruit_GFX.h> // Core graphics library
#include <SPI.h> // this is needed for display
#include <Adafruit_ILI9341.h>
#include <Wire.h> // this is needed for FT6206
#include <Adafruit_FT6206.h> // Hardware-specific library
#include <TouchScreen.h>
#include <DHT.h>
//----------------------------------------
//----------------------------------------
#if defined(__SAM3X8E__)
#undef __FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif
//----------------------------------------
Adafruit_FT6206 ctp = Adafruit_FT6206();
//----------------------------------------Pin configuration and initialization for LCD TFT
#define LCD_CS 10
#define LCD_CD 9
Adafruit_ILI9341 tft = Adafruit_ILI9341(LCD_CS, LCD_CD);
//----------------------------------------
//----------------------------------------Defines colors
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define LIGHT_BLUE 0x0575
#define RED 0xF800
#define GREEN 0x07E0
#define GREY 0x8410
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define ORANGE 0xFD20
#define DARKORANGE 0xFB60
#define MAROON 0x7800
#define BLACKM 0x18E3
#define PINK 0xFDF9
#define VIOLET 0x781F
#define CREAM 0xEF7D
//----------------------------------------
//----------------------------------------Defines an LED pin
#define LED 7 // Red
#define LED1 6 // Green
#define LED2 5 // Blue
//----------------------------------------
//----------------------------------------Button location at point x and y
int BtnGreenX = 40;
int BtnGreenY = 30;
int BtnRedX = 40;
int BtnRedY = 115;
int BtnGreenX1 = 125;
int BtnGreenY1 = 30;
int BtnRedX1 = 125;
int BtnRedY1 = 115;
int BtnGreenX2 = 210;
int BtnGreenY2 = 30;
int BtnRedX2 = 210;
int BtnRedY2 = 115;
//----------------------------------------
//---------------------------------------DHT22 configuration and data variables
#define DHTPIN A3
#define DHTTYPE DHT22
DHT dht22 = DHT(DHTPIN, DHTTYPE);
//---------------------------------------DEFINING THE TRIG AND ECHO ULTRASONIC PIN
#define trigPin 6
#define echoPin 7
int buzzerPin = 8;
int h;
float t;
float f;
float hif;
float hic;
int safeState, riskyState, dangerState;
//----------------------------------------
//----------------------------------------The x and y points for the Temperature bar
int x_bar_t = 20;
int y_bar_t = 60;
//----------------------------------------
//----------------------------------------The variable to hold the conversion value from the temperature value to the value for the temperature bar
int T_to_Bar;
//----------------------------------------
//----------------------------------------Menu = 0 to display the Main Menu Display, Menu = 1 to control the LED and Menu = 2 to display DHT22 sensor data
int Menu = 0;
//----------------------------------------
//----------------------------------------Variable for the x, y and z points on the touch screen
int x_set_rotatoon_135;
int y_set_rotatoon_135;
//----------------------------------------Millis variable to update the temperature and humidity values
unsigned long previousMillis = 0; //--> will store last time updated
// constants won't change:
const long interval = 2000; //--> interval
//----------------------------------------
//========================================================================VOID SETUP()
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
tft.begin(); //--> SPFD5408/ILI9341
if (! ctp.begin(40)) { // pass in 'sensitivity' coefficient
Serial.println("Couldn't start FT6206 touchscreen controller");
while (1);
}
//Pin Mode Setup
pinMode(buzzerPin, OUTPUT);
pinMode(LED2, OUTPUT), pinMode(LED1, OUTPUT), pinMode(LED, OUTPUT);
pinMode(trigPin, OUTPUT), pinMode(echoPin, INPUT);
tft.setRotation(3); //--> Need for the Mega, please changed for your choice or rotation initial
tft.fillScreen(WHITE); //--> TFT LCD background color
dht22.begin();
Menu_display();
}
//========================================================================
//========================================================================GetTSPoint()
void GetTSPoint() {
// Wait for a touch
if (! ctp.touched()) {
return;
}
// Retrieve a point
TS_Point p = ctp.getPoint();
y_set_rotatoon_135 = map(p.x, 0, 240, 0, tft.height());
x_set_rotatoon_135 = map(tft.width() - p.y, 0, 320, 0, tft.width());
}
//========================================================================
//========================================================================RGB Function Setup
void setRGB(int r, int g, int b) // RGB Function Setup
{
analogWrite(LED, r);
analogWrite(LED1, g);
analogWrite(LED2, b);
}
//========================================================================
//========================================================================SET MSG
void tft_msg(int x, int y, int sz, const GFXfont * f, String msg)
{
int16_t x1, y1;
uint16_t wid, ht;
tft.setFont(f);
tft.setCursor(x, y);
tft.setTextColor(BLACK);
tft.setTextSize(sz);
tft.print(msg);
}
//========================================================================
//========================================================================SET SIGN
void tft_signs(int x, int y, int sz, const GFXfont * f, String msg, uint16_t color)
{
int16_t x1, y1;
uint16_t wid, ht;
tft.setFont(f);
tft.setCursor(x, y);
tft.setTextColor(color);
tft.setTextSize(sz);
tft.print(msg);
}
//========================================================================
//========================================================================VOID LOOP()
void loop() {
//----------------------------------------Main Menu Display
if (Menu == 0) {
GetTSPoint();
//----------------------------------------Conditions for detecting when the Button for controlling the LED is touched and its command (Enter the LED controlling menu)
if (x_set_rotatoon_135 > 17 && x_set_rotatoon_135 < (17+130) && y_set_rotatoon_135 > 90 && y_set_rotatoon_135 < (90+40)) {
Menu = 1;
DrawButtonControlLEDPress();
delay(150);
DrawButtonControlLED();
delay(500);
tft.fillScreen(WHITE);
delay(500);
DrawButtonGreen(BtnGreenX,BtnGreenY);
DrawButtonRed(BtnRedX, BtnRedY);
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(50, 180);
tft.print("RED");
DrawButtonGreen1(BtnGreenX1,BtnGreenY1);
DrawButtonRed1(BtnRedX1, BtnRedY1);
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(125, 180);
tft.print("GREEN");
DrawButtonGreen2(BtnGreenX2,BtnGreenY2);
DrawButtonRed2(BtnRedX2, BtnRedY2);
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(215, 180);
tft.print("BLUE");
DrawButtonBack(10, 200);
}
//----------------------------------------Condition to detect when the button to display DHT22 sensor data is touched and the command (Enter the menu displays DHT22 sensor data)
if (x_set_rotatoon_135 > 17 && x_set_rotatoon_135 < (17+130) && y_set_rotatoon_135 > 160 && y_set_rotatoon_135 < (160+40)) {
Menu = 2;
DrawButtonTempHumPress();
delay(150);
DrawButtonTempHum();
delay(500);
tft.fillScreen(WHITE);
delay(500);
tft.drawLine(15, 40, 300, 40, MAROON);
tft.drawLine(15, 39, 300, 39, MAROON);
tft.setTextSize(2);
tft.setTextColor(BLUE);
tft.setCursor(40, 13);
tft.print("Temperature & Humidity");
draw_bar(x_bar_t, y_bar_t);
tft.drawLine(190, 60, 190, 227, MAROON);
tft.drawLine(190, 127, 300, 127, MAROON);
tft.fillRect(202, 60, 100, 27, CYAN);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setCursor(205, 65);
tft.print("Humidity");
tft.fillRect(202, 140, 100, 43, GREEN);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setCursor(227, 145);
tft.print("Heat");
tft.setCursor(220, 165);
tft.print("Index");
DrawButtonBack(8, 6);
GetDHT22Data();
delay(1000);
}
//----------------------------------------Conditions for detecting when the Button for Ultrasensor is touched and its command (Enter the Distance Measuring menu)
if (x_set_rotatoon_135 > 167 && x_set_rotatoon_135 < (167+130) && y_set_rotatoon_135 > 90 && y_set_rotatoon_135 < (90+40)) {
Menu = 3;
DrawButtonDistancePress();
delay(150);
DrawButtonDistance();
delay(500);
setRGB(0, 0, 0), delay(200);
setRGB(255, 0, 0), delay(200);
setRGB(0, 0, 255), delay(200);
setRGB(125, 125, 125), delay(200);
setRGB(255, 255, 255), delay(200);
tft.fillScreen(BLACK);
tft.fillRoundRect(10, 5, 230, 40, 5, CREAM);
tft.fillRoundRect(250, 5, 50, 10, 3, WHITE);
int sety = 5;
for (int z = 0; z < 3; z++)
{
tft.fillRoundRect(260, sety, 50, 9, 3, WHITE);
tft.drawRoundRect(260, sety, 50, 9, 3, GREY);
sety += 14;
}
tft_msg(22, 18, 2, NULL, "By BobWithTech");
tft.fillRoundRect(10, 50, 300, 60, 5, GREY);
tft.drawRoundRect(10, 50, 300, 60, 5, CREAM);
tft.drawRoundRect(11, 51, 298, 58, 5, CREAM);
tft.drawRoundRect(12, 52, 296, 56, 5, CREAM);
tft_msg(16, 70, 3, NULL, "DISTANCE:");
tft.fillRoundRect(10, 118, 200, 30, 5, LIGHT_BLUE);
tft.drawRoundRect(10, 118, 200, 30, 5, CREAM);
tft.drawRoundRect(11, 1119, 198, 28, 5, CREAM);
tft_msg(14, 126, 2, NULL, "STATUS:");
DrawButtonBack(8, 6);
GetUltraData();
delay(1000);
}
//----------------------------------------Conditions for detecting when the Button for Photoresistor is touched and its command (Enter the Photoresistor menu)
if (x_set_rotatoon_135 > 167 && x_set_rotatoon_135 < (167+130) && y_set_rotatoon_135 > 160 && y_set_rotatoon_135 < (160+40)) {
Menu = 4;
DrawButtonPhotoPress();
delay(150);
DrawButtonPhoto();
delay(500);
tft.fillScreen(WHITE);
delay(500);
}
//----------------------------------------
}
//----------------------------------------
//----------------------------------------Menu or Mode to control the LED
if (Menu == 1) {
ControlTheLED();
}
//----------------------------------------
//----------------------------------------Menu or Mode to display DHT22 sensor data
if (Menu == 2) {
ShowDHT22Data();
}
//----------------------------------------
//----------------------------------------Menu or Mode to display DHT22 sensor data
if (Menu == 3) {
ShowUltraData();
}
//----------------------------------------
//----------------------------------------Menu or Mode to display DHT22 sensor data
if (Menu == 4) {
ShowPhotoData();
}
//----------------------------------------
}
//========================================================================
//========================================================================DrawButtonControlLED()
void DrawButtonControlLED() {
tft.fillRoundRect(17, 90, 130, 40, 10, BLACKM);
tft.fillRoundRect(19, 92, 126, 36, 10, GREEN);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setCursor(22, 103);
tft.print("LED Switch");
}
//========================================================================
//========================================================================DrawButtonControlLEDPress()
void DrawButtonControlLEDPress() {
tft.fillRoundRect(17, 90, 130, 40, 10, BLACKM);
}
//========================================================================
//========================================================================DrawButtonTempHum()
void DrawButtonTempHum() {
tft.fillRoundRect(17, 160, 130, 40, 10, BLACKM);
tft.fillRoundRect(19, 162, 126, 36, 10, BLUE);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setCursor(22, 173);
tft.print("Temp & Hum");
}
//========================================================================
//========================================================================DrawButtonTempHumPress()
void DrawButtonTempHumPress() {
tft.fillRoundRect(17, 160, 130, 40, 10, BLACKM);
}
//========================================================================
//========================================================================DrawButtonDistance()
void DrawButtonDistance() {
tft.fillRoundRect(167, 90, 130, 40, 10, BLACKM);
tft.fillRoundRect(169, 92, 126, 36, 10, VIOLET);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setCursor(185, 103);
tft.print("Distance");
}
//========================================================================
//========================================================================DrawButtonDistancePress()
void DrawButtonDistancePress() {
tft.fillRoundRect(167, 90, 130, 40, 10, BLACKM);
}
//========================================================================
//========================================================================DrawButtonPhoto()
void DrawButtonPhoto() {
tft.fillRoundRect(167, 160, 130, 40, 10, BLACKM);
tft.fillRoundRect(169, 162, 126, 36, 10, PINK);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setCursor(175, 173);
tft.print("Lux Sensor");
}
//========================================================================
//========================================================================DrawButtonPhotoPress()
void DrawButtonPhotoPress() {
tft.fillRoundRect(167, 160, 130, 40, 10, BLACKM);
}
//========================================================================
//========================================================================DrawButtonGreen(x, y) Red
void DrawButtonGreen(int xp, int yp) {
tft.fillRoundRect(xp, yp, 54, 54, 10, BLACKM);
tft.fillRoundRect(xp+2, yp+2, 50, 50, 10, GREEN);
tft.setCursor(xp+18, yp+22);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.println("ON");
}
//========================================================================
//========================================================================DrawButtonGreenPress(x, y)
void DrawButtonGreenPress(int xp, int yp) {
tft.fillRoundRect(xp, yp, 54, 54, 10, BLACKM);
}
//========================================================================
//========================================================================DrawButtonRed(x, y) Red
void DrawButtonRed(int xp, int yp) {
tft.fillRoundRect(xp, yp, 54, 54, 10, BLACKM);
tft.fillRoundRect(xp+2, yp+2, 50, 50, 10, RED);
tft.setCursor(xp+12, yp+22);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.println("OFF");
}
//========================================================================
//========================================================================DrawButtonRedPress(x, y)
void DrawButtonRedPress(int xp, int yp) {
tft.fillRoundRect(xp, yp, 54, 54, 10, BLACKM);
}
//========================================================================
//========================================================================DrawButtonGreen(x, y) Green
void DrawButtonGreen1(int xp, int yp) {
tft.fillRoundRect(xp, yp, 54, 54, 10, BLACKM);
tft.fillRoundRect(xp+2, yp+2, 50, 50, 10, GREEN);
tft.setCursor(xp+18, yp+22);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.println("ON");
}
//========================================================================
//========================================================================DrawButtonGreenPress(x, y)
void DrawButtonGreenPress1(int xp, int yp) {
tft.fillRoundRect(xp, yp, 54, 54, 10, BLACKM);
}
//========================================================================
//========================================================================DrawButtonRed(x, y) Green
void DrawButtonRed1(int xp, int yp) {
tft.fillRoundRect(xp, yp, 54, 54, 10, BLACKM);
tft.fillRoundRect(xp+2, yp+2, 50, 50, 10, RED);
tft.setCursor(xp+12, yp+22);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.println("OFF");
}
//========================================================================
//========================================================================DrawButtonRedPress(x, y)
void DrawButtonRedPress1(int xp, int yp) {
tft.fillRoundRect(xp, yp, 54, 54, 10, BLACKM);
}
//========================================================================
//========================================================================DrawButtonGreen(x, y) Blue
void DrawButtonGreen2(int xp, int yp) {
tft.fillRoundRect(xp, yp, 54, 54, 10, BLACKM);
tft.fillRoundRect(xp+2, yp+2, 50, 50, 10, GREEN);
tft.setCursor(xp+18, yp+22);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.println("ON");
}
//========================================================================
//========================================================================DrawButtonGreenPress(x, y)
void DrawButtonGreenPress2(int xp, int yp) {
tft.fillRoundRect(xp, yp, 54, 54, 10, BLACKM);
}
//========================================================================
//========================================================================DrawButtonRed(x, y) Blue
void DrawButtonRed2(int xp, int yp) {
tft.fillRoundRect(xp, yp, 54, 54, 10, BLACKM);
tft.fillRoundRect(xp+2, yp+2, 50, 50, 10, RED);
tft.setCursor(xp+12, yp+22);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.println("OFF");
}
//========================================================================
//========================================================================DrawButtonRedPress(x, y)
void DrawButtonRedPress2(int xp, int yp) {
tft.fillRoundRect(xp, yp, 54, 54, 10, BLACKM);
}
//========================================================================
//========================================================================DrawButtonBack(x, y)
void DrawButtonBack(int x_btn_back, int y_btn_back) {
tft.fillRoundRect(x_btn_back, y_btn_back, 30, 30, 5, BLACKM);
tft.fillRoundRect(x_btn_back+2, y_btn_back+2, 26, 26, 5, YELLOW);
tft.setTextSize(2);
tft.setTextColor(BLACKM);
tft.setCursor(x_btn_back+7, y_btn_back+7);
tft.print("<");
}
//========================================================================
//========================================================================DrawButtonBackPress(x, y)
void DrawButtonBackPress(int x_btn_back, int y_btn_back) {
tft.fillRoundRect(x_btn_back, y_btn_back, 30, 30, 5, BLACKM);
}
//========================================================================
//========================================================================GetDHT22Data()
void GetDHT22Data() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
h = dht22.readHumidity();
// Read temperature as Celsius (the default)
t = dht22.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
f = dht22.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
return;
}
// Compute heat index in Fahrenheit (the default)
hif = dht22.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
hic = dht22.computeHeatIndex(t, h, false);
}
//========================================================================
//========================================================================GetUltraData()
void GetUltraData() {
}
//========================================================================
//========================================================================draw_bar (Temperature Bar)
void draw_bar(int x_bar, int y_bar) {
tft.fillRoundRect(x_bar, y_bar, 35, 120, 5, BLACK);
tft.fillCircle(x_bar+17, y_bar+140, 30, BLACK);
tft.fillRoundRect(x_bar+4, y_bar+4, 27, 120, 2, WHITE);
tft.fillCircle(x_bar+17, y_bar+140, 25, WHITE);
tft.fillRect(x_bar+8, y_bar+8, 19, 120, DARKORANGE);
tft.fillCircle(x_bar+17, y_bar+140, 21, DARKORANGE);
//tft.fillRect(41, 58, 19, 108, RED);
tft.drawLine(x_bar+37, y_bar+8, x_bar+42, y_bar+8, RED);
tft.setTextSize(1);
tft.setTextColor(RED);
tft.setCursor(x_bar+47, y_bar+4);
tft.println("50");
tft.drawLine(x_bar+37, y_bar+115, x_bar+42, y_bar+115, RED);
tft.setCursor(x_bar+47, y_bar+111);
tft.println("0");
}
//========================================================================
//========================================================================Menu_display()
void Menu_display() {
tft.setTextSize(3);
tft.setTextColor(BLACK);
tft.setCursor(120, 43);
tft.print("MENU");
DrawButtonControlLED();
DrawButtonTempHum();
DrawButtonDistance();
DrawButtonPhoto();
}
//========================================================================
//========================================================================ControlTheLED()
void ControlTheLED() {
GetTSPoint();
if (x_set_rotatoon_135 > BtnGreenX && x_set_rotatoon_135 < (BtnGreenX+54) && y_set_rotatoon_135 > BtnGreenY && y_set_rotatoon_135 < (BtnGreenY+54)) {
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(50, 180);
tft.print("R ON ");
digitalWrite(LED, HIGH);
DrawButtonGreenPress(BtnGreenX, BtnGreenY);
delay(100);
DrawButtonGreen(BtnGreenX,BtnGreenY);
}
if (x_set_rotatoon_135 > BtnRedX && x_set_rotatoon_135 < (BtnRedX+54) && y_set_rotatoon_135 > BtnRedY && y_set_rotatoon_135 < (BtnRedY+54)) {
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(50, 180);
tft.print("R OFF");
digitalWrite(LED, LOW);
DrawButtonRedPress(BtnRedX, BtnRedY);
delay(100);
DrawButtonRed(BtnRedX, BtnRedY);
}
if (x_set_rotatoon_135 > BtnGreenX1 && x_set_rotatoon_135 < (BtnGreenX1+54) && y_set_rotatoon_135 > BtnGreenY1 && y_set_rotatoon_135 < (BtnGreenY1+54)) {
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(125, 180);
tft.print("G ON ");
digitalWrite(LED1, HIGH);
DrawButtonGreenPress(BtnGreenX1, BtnGreenY1);
delay(100);
DrawButtonGreen(BtnGreenX1,BtnGreenY1);
}
if (x_set_rotatoon_135 > BtnRedX1 && x_set_rotatoon_135 < (BtnRedX1+54) && y_set_rotatoon_135 > BtnRedY1 && y_set_rotatoon_135 < (BtnRedY1+54)) {
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(125, 180);
tft.print("G OFF");
digitalWrite(LED1, LOW);
DrawButtonRedPress(BtnRedX1, BtnRedY1);
delay(100);
DrawButtonRed(BtnRedX1, BtnRedY1);
}
if (x_set_rotatoon_135 > BtnGreenX2 && x_set_rotatoon_135 < (BtnGreenX2+54) && y_set_rotatoon_135 > BtnGreenY2 && y_set_rotatoon_135 < (BtnGreenY2+54)) {
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(215, 180);
tft.print("B ON ");
digitalWrite(LED2, HIGH);
DrawButtonGreenPress(BtnGreenX2, BtnGreenY2);
delay(100);
DrawButtonGreen(BtnGreenX2,BtnGreenY2);
}
if (x_set_rotatoon_135 > BtnRedX2 && x_set_rotatoon_135 < (BtnRedX2+54) && y_set_rotatoon_135 > BtnRedY2 && y_set_rotatoon_135 < (BtnRedY2+54)) {
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(215, 180);
tft.print("B OFF");
digitalWrite(LED2, LOW);
DrawButtonRedPress(BtnRedX2, BtnRedY2);
delay(100);
DrawButtonRed(BtnRedX2, BtnRedY2);
}
if (x_set_rotatoon_135 > 10 && x_set_rotatoon_135 < (10+30) && y_set_rotatoon_135 > 200 && y_set_rotatoon_135 < (200+30)) {
Menu = 0;
DrawButtonBackPress(10, 200);
delay(100);
DrawButtonBack(10, 200);
delay(500);
tft.fillScreen(WHITE);
delay(500);
Menu_display();
}
}
//========================================================================
//========================================================================ShowDHT22Data()
void ShowDHT22Data() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
GetDHT22Data();
}
T_to_Bar = map(t, 0.0, 50.0, 108, 0);
tft.fillRect(x_bar_t+8, (y_bar_t+8)+T_to_Bar, 19, 108-T_to_Bar, ORANGE);
tft.fillRect(x_bar_t+8, y_bar_t+8, 19, T_to_Bar, WHITE);
tft.setTextSize(2);
tft.setTextColor(ORANGE, WHITE);
tft.setCursor(75, 100);
tft.print(t);
if (t < 10) tft.print(" ");
tft.setCursor(160, 100);
tft.print((char)247);
tft.println("C");
tft.setCursor(75, 135);
tft.print(f);
if (f < 100) tft.print(" ");
tft.setCursor(160, 135);
tft.print((char)247);
tft.println("F");
tft.setTextSize(3);
tft.setTextColor(CYAN, WHITE);
tft.setCursor(205, 95);
tft.print(h);
tft.print(" %");
tft.setTextSize(1);
tft.setTextColor(GREEN, WHITE);
tft.setCursor(205, 200);
tft.print(hic);
tft.print(" ");
tft.print((char)247);
tft.print("C");
if (hic < 10) tft.print(" ");
tft.setTextSize(1);
tft.setTextColor(GREEN, WHITE);
tft.setCursor(205, 220);
tft.print(hif);
tft.print(" ");
tft.print((char)247);
tft.print("F");
if (hif < 100) tft.print(" ");
GetTSPoint();
if (x_set_rotatoon_135 > 8 && x_set_rotatoon_135 < (8+30) && y_set_rotatoon_135 > 6 && y_set_rotatoon_135 < (6+30)) {
Menu = 0;
DrawButtonBackPress(8, 6);
delay(100);
DrawButtonBack(8, 6);
delay(500);
tft.fillScreen(WHITE);
delay(500);
Menu_display();
}
}
//========================================================================
//========================================================================ShowUltraData()
void ShowUltraData() {
}
//========================================================================
//========================================================================ShowPhotoData()
void ShowPhotoData() {
GetTSPoint();
if (x_set_rotatoon_135 > BtnGreenX && x_set_rotatoon_135 < (BtnGreenX+54) && y_set_rotatoon_135 > BtnGreenY && y_set_rotatoon_135 < (BtnGreenY+54)) {
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(50, 180);
tft.print("R ON ");
digitalWrite(LED, HIGH);
DrawButtonGreenPress(BtnGreenX, BtnGreenY);
delay(100);
DrawButtonGreen(BtnGreenX,BtnGreenY);
}
if (x_set_rotatoon_135 > BtnRedX && x_set_rotatoon_135 < (BtnRedX+54) && y_set_rotatoon_135 > BtnRedY && y_set_rotatoon_135 < (BtnRedY+54)) {
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(50, 180);
tft.print("R OFF");
digitalWrite(LED, LOW);
DrawButtonRedPress(BtnRedX, BtnRedY);
delay(100);
DrawButtonRed(BtnRedX, BtnRedY);
}
if (x_set_rotatoon_135 > BtnGreenX1 && x_set_rotatoon_135 < (BtnGreenX1+54) && y_set_rotatoon_135 > BtnGreenY1 && y_set_rotatoon_135 < (BtnGreenY1+54)) {
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(125, 180);
tft.print("G ON ");
digitalWrite(LED1, HIGH);
DrawButtonGreenPress(BtnGreenX1, BtnGreenY1);
delay(100);
DrawButtonGreen(BtnGreenX1,BtnGreenY1);
}
if (x_set_rotatoon_135 > BtnRedX1 && x_set_rotatoon_135 < (BtnRedX1+54) && y_set_rotatoon_135 > BtnRedY1 && y_set_rotatoon_135 < (BtnRedY1+54)) {
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(125, 180);
tft.print("G OFF");
digitalWrite(LED1, LOW);
DrawButtonRedPress(BtnRedX1, BtnRedY1);
delay(100);
DrawButtonRed(BtnRedX1, BtnRedY1);
}
if (x_set_rotatoon_135 > BtnGreenX2 && x_set_rotatoon_135 < (BtnGreenX2+54) && y_set_rotatoon_135 > BtnGreenY2 && y_set_rotatoon_135 < (BtnGreenY2+54)) {
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(215, 180);
tft.print("B ON ");
digitalWrite(LED2, HIGH);
DrawButtonGreenPress(BtnGreenX2, BtnGreenY2);
delay(100);
DrawButtonGreen(BtnGreenX2,BtnGreenY2);
}
if (x_set_rotatoon_135 > BtnRedX2 && x_set_rotatoon_135 < (BtnRedX2+54) && y_set_rotatoon_135 > BtnRedY2 && y_set_rotatoon_135 < (BtnRedY2+54)) {
tft.setTextSize(2);
tft.setTextColor(BLUE, WHITE);
tft.setCursor(215, 180);
tft.print("B OFF");
digitalWrite(LED2, LOW);
DrawButtonRedPress(BtnRedX2, BtnRedY2);
delay(100);
DrawButtonRed(BtnRedX2, BtnRedY2);
}
if (x_set_rotatoon_135 > 10 && x_set_rotatoon_135 < (10+30) && y_set_rotatoon_135 > 200 && y_set_rotatoon_135 < (200+30)) {
Menu = 0;
DrawButtonBackPress(10, 200);
delay(100);
DrawButtonBack(10, 200);
delay(500);
tft.fillScreen(WHITE);
delay(500);
Menu_display();
}
}
//========================================================================
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Loading
ili9341-cap-touch
ili9341-cap-touch