#include <stdint.h>
#include "TouchScreen.h"
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset
pin
// Colors LCD
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x152C
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A3 // must be an analog pin, use "An" notation!
#define YM 8 // can be a digital pin
#define XP 9 // can be a digital pin
#define BOXSIZE 40
#define PENRADIUS 3
#define TS_MINX 940
#define TS_MINY 160
#define TS_MAXX 160
#define TS_MAXY 970
#define MINPRESSURE 10
#define MAXPRESSURE 1000
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
//Globale Variabeln
bool change = 0;
bool touch = 0;
bool site=0;
int tempbutton=30;
unsigned long starttime=0;
void setup() {
Serial.begin(9600);
tft.reset();
uint16_t identifier = tft.readID();
if(identifier == 0x9325) {
Serial.println(F("Found ILI9325 LCD driver"));
} else if(identifier == 0x9328) {
Serial.println(F("Found ILI9328 LCD driver"));
} else if(identifier == 0x7575) {
Serial.println(F("Found HX8347G LCD driver"));
} else if(identifier == 0x9341) {
Serial.println(F("Found ILI9341 LCD driver"));
} else if(identifier == 0x8357) {
Serial.println(F("Found HX8357D LCD driver"));
} else {
Serial.print(F("Unknown LCD driver chip: "));
Serial.println(identifier, HEX);
Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield,
the line:"));
Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
Serial.println(F("should appear in the library header
(Adafruit_TFT.h)."));
Serial.println(F("If using the breakout board, it should NOT be
#defined!"));
Serial.println(F("Also if using the breakout, double-check that all
wiring"));
Serial.println(F("matches the tutorial."));
return;
}
tft.begin(identifier);
HomeScreen();//HomeScreen wird geladen
}
void loop() {
TSPoint p = ts.getPoint();
pinMode(XM, OUTPUT); //Touchscreen wird gelesen und auf dem
Serialmonitor ausgegeben
pinMode(YP, OUTPUT);
if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
Serial.print("("); Serial.print(p.x);
Serial.print(", "); Serial.print(p.y);
Serial.println(")");
if (p.x > 52 && p.x < 274) { //Wird überprüft ob der Button
Maische gedrückt worden ist
if (p.y > 64 && p.y < 90) {
if(site==0){
Maischen();
}}
}
if (p.x > 52 && p.x < 274) { //Wird überprüft ob der Button
Rast.1 gedrückt worden ist
if (p.y > 115 && p.y < 145) {
if(site==0){
Rast1();
}
}
}
if (p.x > 52 && p.x < 274) { //Wird überprüft ob der Button
Rast.2 gedrückt worden ist
if (p.y > 163 && p.y < 190) {
if(site==0){
Rast2();
}
}
}
if (p.x > 52 && p.x < 274) { //Wird überprüft ob der Button
Abmaischen gedrückt worden ist
if (p.y > 211 && p.y < 240) {
if(site==0){
Abmaischen();
}
}
}
if (p.x > -5 && p.x < 45) { //Wird überprüft ob der Button
Temp - gedrückt worden ist
if (p.y > 117 && p.y < 155) {
if(site==1){
tempbutton--;
Maischen();
}
}
}
if (p.x > 286 && p.x < 326) { //Wird überprüft ob der Button
Temp - gedrückt worden ist
if (p.y > 118 && p.y < 159) {
if(site==1){
tempbutton++;
}
}
}
if (p.x > 0 && p.x < 55) { //Wird überprüft ob der Button
Back gedrückt worden ist
if (p.y > 25 && p.y < 70) {
if (site==1){
HomeScreen();
}}
}
}
}
void HomeScreen ()
{ site=0;
tft.setRotation(1);
tft.fillScreen(BLACK);
tft.drawRoundRect(0, 0, 319, 240, 8, WHITE); //Page border
tft.setCursor(20, 10);
tft.setTextColor(WHITE);
tft.setTextSize(3);
tft.println("BRAUMEISTER V1.0");
tft.drawLine(3,40,316,40,RED);
tft.fillRoundRect(60, 50, 200, 35, 8,GREEN );
tft.drawRoundRect(60, 50, 200, 35, 8, WHITE) ;
tft.fillRoundRect(60, 95, 200, 35, 8,GREEN );
tft.drawRoundRect(60, 95, 200, 35, 8, WHITE) ;
tft.fillRoundRect(60, 140, 200, 35, 8,GREEN );
tft.drawRoundRect(60, 140, 200, 35, 8, WHITE) ;
tft.fillRoundRect(60, 185, 200, 35, 8,GREEN );
tft.drawRoundRect(60, 185, 200, 35, 8, WHITE) ;
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.setCursor(112, 60);
tft.println("Maischen");
tft.setCursor(125, 105);
tft.println("1.Rast");
tft.setCursor(125, 150);
tft.println("2.Rast");
tft.setCursor(103,195);
tft.println("Abmaischen");
}
void Maischen ()
{
site=1;
int Time1=0;
tft.setRotation(1);
tft.fillScreen(BLACK);
tft.fillRoundRect(10, 10, 50, 50, 8,GREEN ); //Back Button
tft.drawRoundRect(10, 10, 50, 50, 8, WHITE) ;
tft.setTextColor(WHITE);
tft.setTextSize(3);
tft.setCursor(110,25);
tft.println("Maischen");
tft.drawLine(100,60,260,60,RED);
tft.fillRoundRect(63, 100, 200, 40, 8,GREEN );//Temperatur & Time
Button
tft.drawRoundRect(63, 100, 200, 40, 8, WHITE) ;
tft.fillRoundRect(63, 150, 200, 40, 8,GREEN );
tft.drawRoundRect(63, 150, 200, 40, 8, WHITE) ;
tft.fillRoundRect(6, 100, 50, 40, 8,GREEN );// down Button
tft.drawRoundRect(6, 100, 50, 40, 8, WHITE) ;
tft.fillRoundRect(6, 150, 50, 40, 8,GREEN );
tft.drawRoundRect(6, 150, 50, 40, 8, WHITE) ;
tft.fillRoundRect(270, 100, 50, 40, 8,GREEN );// Up Button
tft.drawRoundRect(270, 100, 50, 40, 8, WHITE) ;
tft.fillRoundRect(270, 150, 50, 40, 8,GREEN );
tft.drawRoundRect(270, 150, 50, 40, 8, WHITE) ;
//Beschriftungen
tft.setCursor(25,25);
tft.println("<"); //Back
tft.setCursor(20,110);
tft.println("<"); //Down Temp
tft.setCursor(20,160);
tft.println("<");// Down Time
tft.setCursor(290,110);
tft.println(">");// Up Temp
tft.setCursor(290,160);
tft.println(">");// Up Time
tft.setCursor(80,110);
tft.println("Temperatur"); // Temp
tft.setCursor(120,160);
tft.println("Zeit"); // Time
//Ausgabewerte
tft.setCursor(10,70);
tft.print(tempbutton);
tft.print(" Grad");
tft.setCursor(180,70);
tft.print(Time1);
tft.print("Min");
}