TACTILE2

Dependencies:   Tactile TFT_fonts mbed

Fork of Seeed_TFT_Touch_Shield2 by Patrice HAESAERT

main.cpp

Committer:
pathae
Date:
2016-03-15
Revision:
6:d89ac6f45eed
Parent:
5:bc6dc122fc9c
Child:
7:c9c4e478edc9

File content as of revision 6:d89ac6f45eed:

/*
  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"
#include "Arial24x23.h"
#include "Arial28x28.h"
#include "font_big.h"

#define PIN_XP          A3
#define PIN_XM          A1
#define PIN_YP          A2
#define PIN_YM          A0
#define PIN_MOSI        D11
#define PIN_MISO        D12
#define PIN_SCLK        D13
#define PIN_CS_TFT      D5
#define PIN_DC_TFT      D6
#define PIN_BL_TFT      D7
#define PIN_CS_SD       D4

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);

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");
        }
    if ((Xperso > 80)&& (Yperso <12))
        {
        TFT.locate(0,200);
        TFT.printf("Rond");
        }     
    wait(2.0);
    }
 
    
}