TACTILE2

Dependencies:   Tactile TFT_fonts mbed

Fork of Seeed_TFT_Touch_Shield2 by Patrice HAESAERT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "SeeedStudioTFTv2.h"
00003 #include "Arial12x12.h"
00004 #include "Arial24x23.h"
00005 #include "Arial28x28.h"
00006 #include "font_big.h"
00007 
00008 #define PIN_XP          A3
00009 #define PIN_XM          A1
00010 #define PIN_YP          A2
00011 #define PIN_YM          A0
00012 #define PIN_MOSI        D11
00013 #define PIN_MISO        D12
00014 #define PIN_SCLK        D13
00015 #define PIN_CS_TFT      D5
00016 #define PIN_DC_TFT      D6
00017 #define PIN_BL_TFT      D7
00018 #define PIN_CS_SD       D4
00019 
00020 SeeedStudioTFTv2 TFT(PIN_XP, PIN_XM, PIN_YP, PIN_YM, PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TFT, PIN_DC_TFT, PIN_BL_TFT, PIN_CS_SD);
00021 
00022 int main()
00023 {
00024     int Xperso,Yperso;
00025     point p;
00026     //Configure the display driver
00027     TFT.background(Black);
00028     TFT.foreground(White);
00029     TFT.set_font((unsigned char*) Arial24x23);
00030     while(1)
00031         {
00032          TFT.cls();
00033          TFT.fillrect(190,15,230,55,Blue);
00034          TFT.fillrect(150,250,230,295,Green);
00035          TFT.fillcircle(30,280,25,Red);
00036          wait(1.0);
00037          while (TFT.getTouch(p) != 1);
00038          TFT.locate(0,20);
00039          TFT.printf("x1: %6i",p.x);
00040          TFT.locate(0,50);
00041          TFT.printf("y1: %6i",p.y);
00042          TFT.locate(0,110);
00043          Xperso =((p.x/1000)-15);
00044          TFT.printf("x2: %6i",Xperso);
00045          TFT.locate(0,130);
00046          Yperso = ((p.y/1000)-21);
00047          TFT.printf("y2: %6i",Yperso);
00048         
00049         if ((Xperso < 8)&& (Yperso >70))
00050             {
00051              TFT.locate(0,200);
00052              TFT.printf("Carre");
00053             }
00054         if ((Xperso > 80)&& (Yperso >70))
00055             {
00056              TFT.locate(0,200);
00057              TFT.printf("Rectangle");
00058             }
00059         if ((Xperso > 80)&& (Yperso <12))
00060             {
00061             TFT.locate(0,200);
00062             TFT.printf("Rond");
00063             }     
00064         wait(2.0);
00065         }
00066 }