TACTILE2
Dependencies: Tactile TFT_fonts mbed
Fork of Seeed_TFT_Touch_Shield2 by
Diff: main.cpp
- Revision:
- 7:c9c4e478edc9
- Parent:
- 6:d89ac6f45eed
- Child:
- 8:3627a6d60ea7
--- a/main.cpp Tue Mar 15 14:26:16 2016 +0000 +++ b/main.cpp Sat Oct 07 15:38:54 2017 +0000 @@ -1,25 +1,3 @@ -/* - main.cpp - 2014 Copyright (c) Seeed Technology Inc. All right reserved. - - Author:lawliet zou(lawliet.zou@gmail.com) - 2014-02-17 - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - #include "mbed.h" #include "SeeedStudioTFTv2.h" #include "Arial12x12.h" @@ -43,54 +21,46 @@ 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.set_font((unsigned char*) Arial24x23); - //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"); + TFT.cls(); + 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); } - if ((Xperso > 80)&& (Yperso <12)) - { - TFT.locate(0,200); - TFT.printf("Rond"); - } - wait(2.0); - } - - }