#include <FreeDefaultFonts.h>
#include <MCUFRIEND_kbv.h>
#include <TFT_HX8357GLUE.h>
#include <UTFTGLUE.h>
#include <Adafruit_GFX.h>
#include <Adafruit_GrayOLED.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>
#define TS_MINX 124
#define TS_MAXX 906
#define TS_MINY 83
#define TS_MAXY 893
#include "Adafruit_GFX.h"
#include "MCUFRIEND_kbv.h"
#include "TouchScreen.h" // only when you want to use touch screen
#define YP A3 // must be an analog pin, use "An" notation!
#define XM A2 // must be an analog pin, use "An" notation!
#define YM 9 // can be a digital pin
#define XP 8 // can be a digital pin
#define WHITE 0x0000 // مشکی -> سفید
#define YELLOW 0x001F // آبی -> زرد
#define CYAN 0xF800 // قرمز -> آبی سیر
#define PINK 0x07E0 // سبز -> صورتی
#define RED 0x07FF // آبی سیر -> قرمز
#define GREEN 0xF81F // صورتی -> سبز
#define BLUE 0xFFE0 // زرد -> آبی
#define BLACK 0xFFFF // سفید -> مشکی
//#include "bitmap_mono.h" // when you want to display a bitmap image from library
//#include "bitmap_RGB.h" // when you want to display a bitmap image from library
#include "Fonts/FreeSans9pt7b.h" // when you want other fonts
#include "Fonts/FreeSans12pt7b.h" // when you want other fonts
#include "Fonts/FreeSerif12pt7b.h" // when you want other fonts
#include "FreeDefaultFonts.h" // when you want other fonts
#include "SPI.h" // using sdcard for display bitmap image
#include "SD.h"
MCUFRIEND_kbv tft(A3, A2, A1, A0, A4);
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
#include "DHT.h"
#define DHTPIN 13
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
float h;
void setup() {
dht.begin();
Serial.begin(9600);
uint16_t ID = tft.readID();
tft.begin(ID);
tft.width(); //int16_t width(void);
tft.height(); //int16_t height(void);
tft.fillScreen(WHITE); //fillScreen(uint16_t t);
tft.println("Initializing... Please wait.");
#define MINPRESSURE 10
#define MAXPRESSURE 1000
tft.fillRect(0, 0, 240, 80, WHITE );
//tft.fillRect (0,260,60,60,RED);
tft.writeFillRect(0, 260, 60, 60, BLUE);
}
void loop(){
float h = dht.readHumidity();
float t = dht.readTemperature();
tft.setTextSize(1);
tft.print("h is :");
tft.print(h);
tft.print(" t is :");
tft.println(t);
delay(2000);
TSPoint p = ts.getPoint();
int X = p.y;
int Y = p.x;
Serial.print(X); Serial.print(','); Serial.println(Y);// + " " + Y);
delay(1000);
}