Sorry,
da hats doch nur den halben Sketch kopiert. Nun also alles bislang. aber viel mehr ist da nicht.
#include <UTFT.h>
#include <URTouch.h>
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
UTFT myGLCD(CTE70,38,39,40,41);
URTouch myTouch(6,5,4,3,2);
int x,y;
int buf[318];
void setup()
{
randomSeed(analogRead(0));
// Setup LCD
myGLCD.InitLCD();
myGLCD.clrScr();
myTouch.InitTouch();
myTouch.setPrecision(PREC_MEDIUM);
HomeScreen();
}
void loop()
{
int x,y;
int buf[318];
if (myTouch.dataAvailable())
{
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
myGLCD.setColor(255,0,0); //roter Testpunkt
myGLCD.fillCircle(x,y,6);
}
if ((x>=35) && (x<=285) && (y>=90) && (y<=130))
{ Button1();
}
if ((x>=30) && (x<=40) && (y>=135) && (y<=145))
{
Button2();
}
if ((x>=33) && (x<=41) && (y>=206) && (y<=214))
{
Button3();
}
}
//Eigene Funktionen
void HomeScreen()
{
// Kopfzeile
myGLCD.setBackColor(0,0,0);
myGLCD.setColor(255,255,255);
myGLCD.setFont(BigFont);
myGLCD.print("7' TFT Test", CENTER,10); //Textausgabe
myGLCD.setColor(255,0,0);
myGLCD.drawLine(0,32,799,32);
myGLCD.setColor(255,255,255);
myGLCD.setFont(SmallFont);
myGLCD.print("Mika's Weichenprojekt",CENTER,41); //Textausgabe
// Button 1
myGLCD.setColor(16,167,103);
myGLCD.fillRoundRect(35,90,285,130);
myGLCD.setColor(255,255,255);
myGLCD.drawRoundRect(35,90,285,130);
myGLCD.setFont(BigFont);
myGLCD.setBackColor(16,167,103);
myGLCD.print("Button 1",CENTER,102); //Textausgabe
// Button 2
myGLCD.setColor(16,167,103);
myGLCD.fillCircle(35,140,10);
myGLCD.setColor(255,255,255);
myGLCD.drawCircle(35,140,10);
myGLCD.setFont(BigFont);
myGLCD.setBackColor(16,167,103);
myGLCD.print("Button 2",CENTER, 152); //Textausgabe
// Button 3
myGLCD.setColor(16,167,103);
myGLCD.fillCircle(37,210,8);
myGLCD.setColor(255,255,255);
myGLCD.drawCircle(37,210,8);
myGLCD.setFont(SmallFont);
myGLCD.setBackColor(16,167,103);
myGLCD.print("Button 3",CENTER, 203); //Textausgabe
}
// Unterfunktionen definieren
void Button1(){
myGLCD.clrScr();
myGLCD.setColor(16,167,103);
myGLCD.fillRoundRect(35,90,285,130);
myGLCD.setColor(255,255,255);
myGLCD.drawRoundRect(35,90,285,130);
myGLCD.setFont(SmallFont);
myGLCD.setBackColor(265,165,0);
delay(2000);
myGLCD.clrScr();
HomeScreen();
}
void Button2() {
myGLCD.clrScr();
HomeScreen();
}
void Button3() {
myGLCD.clrScr();
HomeScreen();
}