#include <Adafruit_GFX.h> // Core graphics library
#include <SPI.h> // this is needed for display
#include <Adafruit_ILI9341.h>
#include <Arduino.h> // this is needed for FT6206
#include <Adafruit_FT6206.h>
#include <DHT.h>
#define DHTPIN 5
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
//#include "img01.h"
Adafruit_FT6206 ctp = Adafruit_FT6206();
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;
void setup(void) {
//while (!Serial); // used for leonardo debugging
Serial.begin(115200);
Serial.println(F("Cap Touch Paint!"));
Wire.setPins(10, 8); // redefine first I2C port to be on pins 10/8
tft.begin();
if (! ctp.begin(40)) { // pass in 'sensitivity' coefficient
Serial.println("Couldn't start FT6206 touchscreen controller");
while (1);
}
Serial.println("Capacitive touchscreen started");
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(80,15);
tft.setTextColor(0xFFE0);
tft.setTextSize(2);
tft.print("A120E101");
tft.setCursor(10,200);
tft.setTextColor(0xFFFF);
tft.setTextSize(3);
tft.print("TEMP: ");
tft.setCursor(10,230);
tft.setTextColor(0xFFFF);
tft.setTextSize(3);
tft.print("HUMI: ");
}
void loop() {
delay(10);
// Wait for a touch
float temp = dht.readTemperature();
float humi = dht.readHumidity();
// Retrieve a point
TS_Point p = ctp.getPoint();
// flip it around to match the screen.
p.x = map(p.x, 0, 240, 240, 0);
p.y = map(p.y, 0, 320, 320, 0);
// Print out the remapped (rotated) coordinates
Serial.print("("); Serial.print(p.x);
Serial.print(", "); Serial.print(p.y);
Serial.println(")");
//if(temp>40)
//{
//tft.fillRect(60,50,110,110,0xF800);
//}
//else
//{
///tft.fillRect(60,50,110,110,0x07E0);
//}
//tft.fillRect(120,200,200,250,ILI9341_BLACK);
tft.setCursor(120,200);
tft.setTextColor(0xFFE0);
tft.setTextSize(3);
tft.print(temp);
tft.setCursor(120,230);
tft.setTextColor(0xFFE0);
tft.setTextSize(3);
tft.print(humi);
if (! ctp.touched()) {
return;
}
}