TACTILE2
Dependencies: Tactile TFT_fonts mbed
Fork of Seeed_TFT_Touch_Shield2 by
Diff: main.cpp
- Revision:
- 6:d89ac6f45eed
- Parent:
- 5:bc6dc122fc9c
- Child:
- 7:c9c4e478edc9
--- a/main.cpp Wed Jan 20 10:11:27 2016 +0000 +++ b/main.cpp Tue Mar 15 14:26:16 2016 +0000 @@ -43,58 +43,54 @@ int main() { + int i; + int a = 0,b = 0,c = 0, d = 0; + int pos_x = 0, pos_y = 0; + int Xperso,Yperso; + point p; + //Configure the display driver TFT.background(Black); TFT.foreground(White); - TFT.cls(); - - //Print a welcome message TFT.set_font((unsigned char*) Arial24x23); - TFT.locate(0,0); - TFT.printf("BTS snec 2015"); - - //Wait for 5 seconds - wait(5.0); - - //Draw some graphics - TFT.cls(); - TFT.set_font((unsigned char*) Arial24x23); - TFT.locate(100,100); - TFT.printf("Test Graphique"); - - TFT.line(0,0,100,0,Green); - TFT.line(0,0,0,200,Green); - TFT.line(0,0,100,200,Green); - - TFT.rect(100,50,150,100,Red); - TFT.fillrect(180,25,220,70,Blue); - - TFT.circle(80,150,33,White); - TFT.fillcircle(160,190,20,Yellow); - - double s; - for (int i = 0; i < 320; i++) { - s = 20 * sin((long double)i / 10); - TFT.pixel(i, 100 + (int)s, Red); + //TFT.calibrate(); + while(1) + { + TFT.cls(); + TFT.locate(0,0); + TFT.fillrect(190,15,230,55,Blue); + TFT.fillrect(150,250,230,295,Green); + TFT.fillcircle(30,280,25,Red); + wait(1.0); + while (TFT.getTouch(p) != 1); + TFT.locate(0,50); + TFT.printf("x1: %6i",p.x); + TFT.locate(0,80); + TFT.printf("y1: %6i",p.y); + TFT.locate(0,110); + Xperso =((p.x/1000)-15); + TFT.printf("x2: %6i",Xperso); + TFT.locate(0,130); + Yperso = ((p.y/1000)-21); + TFT.printf("y2: %6i",Yperso); + + if ((Xperso < 8)&& (Yperso >70)) + { + TFT.locate(0,200); + TFT.printf("Carre"); + } + if ((Xperso > 80)&& (Yperso >70)) + { + TFT.locate(0,200); + TFT.printf("Rectangle"); + } + if ((Xperso > 80)&& (Yperso <12)) + { + TFT.locate(0,200); + TFT.printf("Rond"); + } + wait(2.0); } - - //Wait for 5 seconds - wait(5.0); - - //Multiple fonts - TFT.foreground(White); - TFT.background(Blue); - TFT.cls(); - TFT.set_font((unsigned char*) Arial24x23); - TFT.locate(0,0); - TFT.printf("Different Fonts:"); - TFT.set_font((unsigned char*) Neu42x35); - TFT.locate(0,30); - TFT.printf("Test 1"); - TFT.set_font((unsigned char*) Arial24x23); - TFT.locate(20,80); - TFT.printf("Test 2"); - TFT.set_font((unsigned char*) Arial12x12); - TFT.locate(35,120); - TFT.printf("Test 3"); + + }