Go Down

Topic: arduino 2.8'' TFT Touch Shield seeed (Read 6951 times) previous topic - next topic

automotive78

I have the following am a beginner of arduino
with the following components:

display and library: http://seeedstudio.com/wiki/2.8''_TFT_Touch_Shield
controller : uno smd and mega

now stands there Touch Screen Demo Sketch:
now I get error messages kopier and.

You can also download an example codes with draw texts, and there is also a folder with touchscreen h and cpp and tft h and cpp.
now I need to change seeduino at tft line mega
But how do I add this to my sketch than import or file?

Please help am already doing 24 hours and days
I get it really isn't...






PaulS

Quote
now I need to change seeduino at tft line mega

What does this mean? What code are you trying to change?


automotive78

There is in the
I need to change in the
tft file?
http://seeedstudio.com/wiki/2.8''_TFT_Touch_Shield
please help

PaulS

Quote
There is in the
I need to change in the
tft file?

Apparently, English is not your native language. Perhaps posting your question in your native language would help. Google translate works fairly well, for some languages, at least.

It would also help if you posted the exact error messages you are getting. The TFT library should work fine with the Mega.

automotive78

have the following,
I have the Touch Screen Demo Sketch van seeed copied on my sketch,
I have the library code tft h file and toucscreen h file on my Desktop copieed (There was also a cpp file at)
and put this location on myn sketch include.
I have the following changes on myn demo screen sketch the 2the line # include < my location
\tft.h >
and 3 line # include<  my location\touchscreen.h >.
Should I also change the 1 line  # <stdint.h>.
Can you explain me how to do it or am I doing something wrong
I'm already busy days.
=( =( =( =( =( =( =(


PaulS

Quote
Can you explain me how to do it or am I doing something wrong

How to do what? I can't tell if you are doing something wrong, because I don't know what problem(s) you are having.

Some simple steps.
1) Post your code.
2) If the code does not compile, post the error messages.
3) If it does compile, explain what it is doing, and how that differs from what you want it to do.

automotive78

#6
Aug 09, 2012, 09:23 am Last Edit: Aug 09, 2012, 10:02 am by automotive78 Reason: 1
This is tft demo sketch i have it copied f this on  myn arduino sketch 1.0.1:
Quote
#include <stdint.h>
#include <C:\Documents and Settings\wp\desktop\TouchScreen.h>
#include <C:\Documents and Settings\wp\desktop\TFT.h>
//Measured ADC values for (0,0) and (240-1,320-1)
//TS_MINX corresponds to ADC value when X = 0
//TS_MINY corresponds to ADC value when Y = 0
//TS_MAXX corresponds to ADC value when X = 240 -1
//TS_MAXY corresponds to ADC value when Y = 320 -1
static unsigned int TS_MINX, TS_MAXX, TS_MINY, TS_MAXY;
//Touch Screen Co-ordinate mapping register
static unsigned int MapX1, MapX2, MapY1, MapY2;
// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// The 2.8" TFT Touch shield has 300 ohms across the X plate
/* Usage: TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
Where, XP = X plus, YP = Y plus, XM = X minus and YM = Y minus */
//init TouchScreen port pins. This would be reinitialized in setup() based on the hardware detected.
TouchScreen ts = TouchScreen(17, A2, A1, 14, 300);

void setup(void)
{
 Tft.init();//init TFT
 initTouchScreenParameters(); //initializes Touch Screen parameters based on the detected TFT Touch Schield hardware

 //Lines
 Tft.drawLine(0,0,50,50,RED);//draw a 45degree red line point(0,0) to point(50,50)
 Tft.drawVerticalLine(25,0,50,GREEN);//draw a vertical green line point(25,0) to point(25,50)
 Tft.drawHorizontalLine(0,25,50,BLUE);//draw a horizontal blue line point(0,25) to point(50,25)

 //Rectangle
 Tft.drawRectangle(50,0,80,50,WHITE);//draw a white rectangle, length=80(X-AXIS), width=50(Y-AXIS)
 Tft.fillRectangle(0,50,50,80,CYAN);//fill a cyan rectangle, length=50(X-AXIS), width=80(Y-AXIS)

 //Circle
 Tft.drawCircle(75,75,25,RED);//draw a red circle, circle centre(75,75) radius=25
 Tft.fillCircle(150,100,50,GREEN);//fill a green circle, circle centre(150,100) radius=50

 //Text
 Tft.drawChar('S',0,150,2,RED);//draw a char, start from point(0,150) font size 2(16*16)
 Tft.drawString("Seeed Studio",8,166,2,GREEN);//draw a char, start from point(8,166) font size 2(16*16)
}

void loop(void)
{
 // a point object holds x y and z coordinates
 Point p = ts.getPoint();

 p.x = map(p.x, TS_MINX, TS_MAXX, MapX1, MapX2);
 p.y = map(p.y, TS_MINY, TS_MAXY, MapY1, MapY2);

 // we have some minimum pressure we consider 'valid'
 // pressure of 0 means no pressing!
 if (p.z > ts.pressureThreshhold)
 {
   //p.x;
   //p.y;
   //p.z;
   Tft.fillCircle(p.x,p.y,2,GREEN);
 }
}

void initTouchScreenParameters()
{
 //This function initializes Touch Screen parameters based on the detected TFT Touch Schield hardware

 if(Tft.IC_CODE == 0x5408) //SPFD5408A TFT driver based Touchscreen hardware detected
 {
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
   ts = TouchScreen(54, A1, A2, 57, 300); //init TouchScreen port pins
#else
   ts = TouchScreen(14, A1, A2, 17, 300); //init TouchScreen port pins
#endif
   //Touchscreen parameters for this hardware
   TS_MINX = 120;
   TS_MAXX = 910;
   TS_MINY = 120;
   TS_MAXY = 950;

   MapX1 = 239;
   MapX2 = 0;
   MapY1 = 0;
   MapY2 = 319;
 }
 else //ST7781R TFT driver based Touchscreen hardware detected
 {
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
   ts = TouchScreen(57, A2, A1, 54, 300); //init TouchScreen port pins
#else
   ts = TouchScreen(17, A2, A1, 14, 300); //init TouchScreen port pins
#endif

   //Touchscreen parameters for this hardware
   TS_MINX = 140;
   TS_MAXX = 900;
   TS_MINY = 120;
   TS_MAXY = 940;

   MapX1 = 239;
   MapX2 = 0;
   MapY1 = 319;
   MapY2 = 0;
 }
}


This is tft fil.h on myn desktop:
Quote
/*
 ST7781R TFT Library.
*/
/*
 
*/
#include <Arduino.h>
#include <avr/pgmspace.h>

#ifndef TFT_h
#define TFT_h

#define MEGA

//Basic Colors
#define RED      0xf800
#define GREEN      0x7e00
#define BLUE      0x001f
#define BLACK      0x0000
#define YELLOW      0xffe0
#define WHITE      0xffff

//Other Colors
#define CYAN      0x07ff   
#define BRIGHT_RED   0xf810   
#define GRAY1      0x8410  
#define GRAY2      0x4208  

//TFT resolution 240*320
#define MIN_X   0
#define MIN_Y   0
#define MAX_X   240
#define MAX_Y   320

#ifdef SEEEDUINO

//========================================
#define DDR_CS      DDRB
#define PORT_CS     PORTB
#define CS_BIT      0x04
#define CS_OUTPUT   {DDR_CS|=CS_BIT;}
#define CS_HIGH     {PORT_CS|=CS_BIT;}
#define CS_LOW      {PORT_CS&=~CS_BIT;}

//-----------------------------------------

#define DDR_RS      DDRB
#define PORT_RS     PORTB
#define RS_BIT      0x08
#define RS_OUTPUT   {DDR_RS|=RS_BIT;}
#define RS_HIGH     {PORT_RS|=RS_BIT;}
#define RS_LOW      {PORT_RS&=~RS_BIT;}

//-----------------------------------------

#define DDR_WR      DDRB
#define PORT_WR     PORTB
#define WR_BIT      0x10
#define WR_OUTPUT   {DDR_WR|=WR_BIT;}
#define WR_HIGH     {PORT_WR|=WR_BIT;}
#define WR_LOW      {PORT_WR&=~WR_BIT;}
#define WR_RISING   {PORT_WR|=WR_BIT;PORT_WR&=~WR_BIT;}

//-----------------------------------------

#define DDR_RD      DDRB
#define PORT_RD     PORTB
#define RD_BIT      0x20
#define RD_OUTPUT   {DDR_RD|=RD_BIT;}
#define RD_HIGH     {PORT_RD|=RD_BIT;}
#define RD_LOW      {PORT_RD&=~RD_BIT;}
#define RD_RISING   {PORT_RD|=RD_BIT;PORT_RD&=~RD_BIT;}
//========================================

#endif

#ifdef MEGA
//==================/CS=====================
#define DDR_CS      DDRB
#define PORT_CS     PORTB
#define CS_BIT      0x10
#define CS_OUTPUT   {DDR_CS|=CS_BIT;}
#define CS_HIGH     {PORT_CS|=CS_BIT;}
#define CS_LOW      {PORT_CS&=~CS_BIT;}

//------------------RS----------------------

#define DDR_RS      DDRB
#define PORT_RS     PORTB
#define RS_BIT      0x20
#define RS_OUTPUT   {DDR_RS|=RS_BIT;}
#define RS_HIGH     {PORT_RS|=RS_BIT;}
#define RS_LOW      {PORT_RS&=~RS_BIT;}

//------------------WR----------------------

#define DDR_WR      DDRB
#define PORT_WR     PORTB
#define WR_BIT      0x40
#define WR_OUTPUT   {DDR_WR|=WR_BIT;}
#define WR_HIGH     {PORT_WR|=WR_BIT;}
#define WR_LOW      {PORT_WR&=~WR_BIT;}
#define WR_RISING   {PORT_WR|=WR_BIT;PORT_WR&=~WR_BIT;}

//------------------RD---------------------

#define DDR_RD      DDRB
#define PORT_RD     PORTB
#define RD_BIT      0x80
#define RD_OUTPUT   {DDR_RD|=RD_BIT;}
#define RD_HIGH     {PORT_RD|=RD_BIT;}
#define RD_LOW      {PORT_RD&=~RD_BIT;}
#define RD_RISING   {PORT_RD|=RD_BIT;PORT_RD&=~RD_BIT;}
//========================================

#endif

#ifdef MAPLE
// not yet implemented
#endif

/**Macro definitions for char display direction**/
#define LEFT2RIGHT 0
#define DOWN2UP    1
#define RIGHT2LEFT 2
#define UP2DOWN    3

extern unsigned char simpleFont[][8];

class TFT
{
public:

   void init (void);
   void sendCommand(unsigned int index);
   void sendData(unsigned int data);
   void pushData(unsigned char data);
   unsigned char getData(void);
   unsigned int readRegister(unsigned int index);

   void setXY(unsigned int poX, unsigned int poY);
   void setPixel(unsigned int poX, unsigned int poY,unsigned int color);
   void drawLine(unsigned int x0,unsigned int y0,unsigned int x1,unsigned int y1,unsigned int color);
   void drawVerticalLine(unsigned int poX, unsigned int poY,unsigned int length,unsigned int color);
   void drawHorizontalLine(unsigned int poX, unsigned int poY,unsigned int length,unsigned int color);
   void drawRectangle(unsigned int poX, unsigned int poY, unsigned int length,unsigned int width,unsigned int color);
   void fillRectangle(unsigned int poX, unsigned int poY, unsigned int length, unsigned int width, unsigned int color);
   void drawCircle(int poX, int poY, int r,unsigned int color);
   void fillCircle(int poX, int poY, int r,unsigned int color);
   void drawChar(unsigned char ascii,unsigned int poX, unsigned int poY,unsigned int size, unsigned int fgcolor);
   void drawString(char *string,unsigned int poX, unsigned int poY,unsigned int size,unsigned int fgcolor);
   
   void all_pin_input(void);
   void all_pin_output(void);
   void all_pin_low(void);

   void setOrientation(unsigned int HV);
   void setDisplayDirect(unsigned char = LEFT2RIGHT);
private:
   void exitStandBy(void);
   unsigned char DisplayDirect;
};

extern TFT Tft;

#endif


this is touchscreen file:
Quote
// Touch screen library with X Y and Z (pressure) readings as well
// as oversampling to avoid 'bouncing'
// (c) ladyada / adafruit
// Code under MIT License

class Point {
public:
 Point(void);
 Point(int16_t x, int16_t y, int16_t z);
 
 bool operator==(Point);
 bool operator!=(Point);

 int16_t x, y, z;
};

class TouchScreen {
public:
 TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym);
 TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym, uint16_t rx);

 bool isTouching(void);
 uint16_t pressure(void);
 int readTouchY();
 int readTouchX();
 Point getPoint();
 int16_t pressureThreshhold;

private:
 uint8_t _yp, _ym, _xm, _xp;
 uint16_t _rxplate;
};


this is error;
cpp; in function 'void init touchscreenparameters()':
70;  class tft has no member named ic_cod
=( =( =(

PaulS

Quote
this is error;
cpp; in function 'void init touchscreenparameters()':
70;  class tft has no member named ic_cod

You know, there is a reason why we ask you to post EXACT error messages. That is NOT the error message you are getting.

The function initTouchScreenParameters() tries to reference Tft.IC_CODE. Tft is an instance of the class TFT.

If you look at the TFT class definition, you'll see that it does not have a member named IC_CODE, so the compiler is perfectly correct.

On the link to the library that you showed, there is this:
Quote
Ask questions on Seeed forum.

The Seeed forum is NOT at arduino.cc/forum.

Riva

Quote
The function initTouchScreenParameters() tries to reference Tft.IC_CODE. Tft is an instance of the class TFT.

IC_CODE is only present in the old pre Arduino 1.0 TFT library, the newer library for Arduino 1.0 does not contain this reference. It looks like the demo sketch your using is for the older library. FYI I compiled ALL the demo's supplied with the Arduino 1.0 compatible libraries (Touch & TFT) without problem.

automotive78

what can i need then is ther arduino sketch compiler 1.0? or

zparticle

If you need a simple GUI library for the v1 SeeedStudio 2.8" TFT Touch Screen check out this lib I just put up:

http://code.google.com/p/touch-screen-menu-library/

also you can see a little video of it at:

http://www.youtube.com/watch?v=sOUUsHCkTHI&feature=youtu.be

Riva


what can i need then is ther arduino sketch compiler 1.0? or

Sorry automotive78 I missed your reply and the thread did not get flagged up again until zparticle replied.
The TFT driver and Touch libraries along with examples I got from this page http://www.seeedstudio.com/wiki/2.8%27%27_TFT_Touch_Shield_v2.0#Software_Installation

Go Up