Go Down

Topic: 3.2" TFT LCD with touch screen,SD card slot and Mega Touch LCD Shield Expansion (Read 15196 times) previous topic - next topic

ronyboss

Hello All,

I am using Arduino Mega 2560 with Proto Shield. Recently i bought 3.2" TFT LCD touch Screen display which has a build in SD card slot,and also bought a Mega Touch LCD Shield Expansion board for my Arduino mega.Exactly these things,

1.This LCD Module with Touch Screen Panel and SD Card slot
http://www.aliexpress.com/item/3-2-TFT-LCD-Module-Display-Touch-Screen-Panel-PCB-Adapter-Blue-SSD1289-with-SD-Card/943009595.html

2.This Mega Touch LCD Shield Expansion v2.2
http://www.aliexpress.com/item/TFT-3-2-Mega-touch-LCD-expansion-board-shield-for-Arduino/770470313.html

Now my questions are,
1.Can i use the touch screen LCD module directly with mega 2560 without the LCD Shield?Will Touch,LCD Screen and SD card all will work fine?
2.Can i use the Library that arduino provided in arduino 1.0.3?
3.Can you provide me some tutorials including demo codes with exactly this LCD?
4.Can you tell me the limitations and features of this LCD? Because i want to be cautious to use this.
5.Can i play video or Flash or any animation using mega 2560 and this TFT Touch Screen LCD?

Thanks in Advance.

HazardsMind

Quote
1.Can i use the touch screen LCD module directly with mega 2560 without the LCD Shield?Will Touch,LCD Screen and SD card all will work fine? NO
2.Can i use the Library that arduino provided in arduino 1.0.3? Possibly but don't count on it, get the library from your seller
3.Can you provide me some tutorials including demo codes with exactly this LCD? Comes with the file from the sender or find another seller with the same lcd and download that folder
4.Can you tell me the limitations and features of this LCD? Because i want to be cautious to use this. Your limited to what your library can do, unless you can make further functions for the library
5.Can i play video or Flash or any animation using mega 2560 and this TFT Touch Screen LCD? No, not at all, however if you do want to try, go ahead, I can tell you that it will be very slow and choppy.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories


HazardsMind

You need to get the correct library from the seller and you need to use the expansion shield.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

TTU.ABD


1.Can i use the touch screen LCD module directly with mega 2560 without the LCD Shield?Will Touch,LCD Screen and SD card all will work fine? 
yes by wires, but I don't know how. I advise you buy from website
http://www.sainsmart.com/home-page-view/sainsmart-mega2560-board-3-5-tft-lcd-module-display-shield-kit-for-atmel-atmega-avr-16au-atmega8u2.html

[ 2.Can i use the Library that arduino provided in arduino 1.0.3?
3.Can you provide me some tutorials including demo codes with exactly this LCD? ]
look the website :
http://www.sainsmart.com/home-page-view/sainsmart-mega2560-board-3-5-tft-lcd-module-display-shield-kit-for-atmel-atmega-avr-16au-atmega8u2.html

5.Can i play video or Flash or any animation using mega 2560 and this TFT Touch Screen LCD?
you can upload images to tft lcd only.
Thanks in Advance.

ronyboss


You need to get the correct library from the seller and you need to use the expansion shield.


Thanks.But it is china made,locally brought from Bangladesh and no library provided.I will use the expansion card,as i found it operates in 3.3V and arduino mega 2560 supplies 5V.So expansion board is needed or i have to connect it with wires manually.As i have the expansion board so i will use that.

ronyboss


yes by wires, but I don't know how. I advise you buy from website
http://www.sainsmart.com/home-page-view/sainsmart-mega2560-board-3-5-tft-lcd-module-display-shield-kit-for-atmel-atmega-avr-16au-atmega8u2.html

look the website :
http://www.sainsmart.com/home-page-view/sainsmart-mega2560-board-3-5-tft-lcd-module-display-shield-kit-for-atmel-atmega-avr-16au-atmega8u2.html

you can upload images to tft lcd only.


Thanks buddy u made my day.I was looking for something like that.I will study them and will try today with the help of SainSmart's documents. If more tutorial available please let me know.

Thanks

rolfmeurer

I puzzled some hours with exactly the same hardware setup and made a quick & dirty, but successfully test script, combining LCD, Touch and SD Card Features.
While googeling I read some hints about wrong Hardware pin mistakes made by the SainSmart V1 Display boards.
I can NOT agree These discusions.
My board is a SainSmart V1.0 and everything works properly with maximum SPI Speed. 
The hardes part was to get the SD Card filenames on my TFT Display. (not possible with the sd.h library.)
But with the <tinyFAT.h> it works!
It seems to be a good choice to use These libs.
SD.h                comfortable Serial file System features
tinyFAT.h         the only way to get filenames on the tft display
UTFT.h            easy going Display library
UTouch.h         a perfect and easy to use touch screen scanning lib
UTFT_tinyFAT   an addon for the tinyFAT.h lib, comes with a Picture Frame demo

and here Comes the quich & dirty test hack:
I hope you apologise my real dirty hack style :-)

// UTFT_ViewFont (C)2012 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program is a demo of the included fonts.
//
// This demo was made for modules with a screen resolution
// of 320x240 pixels.
//
// This program requires the UTFT library.
//

// set up variables using the SD utility library functions:
#include <SD.h>
#include <tinyFAT.h>
#include <UTFT.h>
#include <UTouch.h>

Sd2Card card;
SdVolume volume;
SdFile root;

const int chipSelect = 53;

int x, y;
int bg[] = {
  0, 0, 255};
int fg[] = {
  255, 255, 255};

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];

// Uncomment the next line for Arduino 2009/Uno
//UTFT myGLCD(ITDB32S,19,18,17,16);   // Remember to change the model parameter to suit your display module!

// Uncomment the next line for Arduino Mega
UTFT     myGLCD(ITDB32S,38,39,40,41);   // Remember to change the model parameter to suit your display module!
UTouch   myTouch(6,5,4,3,2);

byte initres;
byte res;
byte input;

void setup()
{
START:
  // Initialize serial communication
  Serial.begin(115200);
  Serial.println("press the ENTER button on your Touch Screen!");
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myGLCD.setColor(0, 255, 0);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.setFont(SmallFont);
  myGLCD.print("Initializing SD card...", CENTER, 0);
  pinMode(chipSelect, OUTPUT);

  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    myGLCD.print("initialization failed. Things to check:", CENTER, 16);
    myGLCD.print("* is a card inserted?", CENTER, 32);
    myGLCD.print("* Is your wiring correct?", CENTER, 48);
    myGLCD.print("* Is your CS pin setting correct?", CENTER, 64);
    delay(5000);
    goto START;
  }
  else {
    myGLCD.print("Wiring is correct and a card is present.", CENTER, 16);


    String CT = "Card type: ";
    switch(card.type()) {
    case SD_CARD_TYPE_SD1:
      CT = CT + " SD1";
      break;
    case SD_CARD_TYPE_SD2:
      CT = CT + " SD2";
      break;
    case SD_CARD_TYPE_SDHC:
      CT = CT + " SDHC";
      break;
    default:
      CT = CT + "Unknown";
    }
    myGLCD.print(CT, CENTER, 32);

    // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
    if (!volume.init(card)) {
      myGLCD.print("Could not find FAT16/FAT32 partition.Make sure you've formatted the card", CENTER, 48);
      delay (5000);
      goto START;
    }
    else{
      // print the type and size of the first FAT-type volume
      myGLCD.print("Volume type is FAT "+(String)volume.fatType(), CENTER, 48);
      uint32_t volumesize;
      volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
      volumesize *= volume.clusterCount();       // we'll have a lot of clusters
      volumesize *= 512;                         // SD card blocks are always 512 bytes
      myGLCD.print("Volume size (bytes): "+(String)volumesize, CENTER, 64);
      volumesize /= 1024;
      myGLCD.print("Volume size (Kbytes): "+(String)volumesize, CENTER, 80);
      volumesize /= 1024;
      myGLCD.print("Volume size (Mbytes): "+(String)volumesize, CENTER, 96);
      myGLCD.print("Files found on the card", CENTER, 112);
      myGLCD.print("Open the Serial Monitor", CENTER, 128);
      myGLCD.print("and wait for instructions!", CENTER, 144);
      myGLCD.setFont(BigFont);
      myGLCD.setBackColor(bg[0], bg[1], bg[2]);

      initres=file.initFAT();
      if (initres!=NO_ERROR)
      {
        myGLCD.print("***** ERROR: ",CENTER,144);
        while (true) {
        };
      }
        drawButtons(); 
    }
  }
}


void drawButtons()
{
  // Draw the ENTER buttons
  myGLCD.setColor(bg[0], bg[1], bg[2]);
  myGLCD.fillRoundRect (90, 180, 220, 230);
  myGLCD.setColor(fg[0], fg[1], fg[2]);
  myGLCD.drawRoundRect (90, 180, 220, 230);
  myGLCD.print("Enter", 115, 195);
  myGLCD.setBackColor (0, 0, 0);
  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM); 
}

// Draw a red frame while a button is touched
void waitForIt(int x1, int y1, int x2, int y2)
{
  myGLCD.setColor(255, 0, 0);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
  while (myTouch.dataAvailable()){
  }
  delay(20);

  root.openRoot(volume);
  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE); 
  ListFiles(); 
  myGLCD.setColor(fg[0], fg[1], fg[2]);
  myGLCD.drawRoundRect (x1, y1, x2, y2); 
}

void loop()
{
  if(Serial.available()){
    int ib = Serial.read();
    String is = (String)(char)ib;
    myGLCD.print("                  ",CENTER,160);
    myGLCD.print(is, CENTER,160);
  }
  if (myTouch.dataAvailable())
  {
    delay(10);
    int xt;
    int yt;
    myTouch.read();
    x=myTouch.getX();
    y=myTouch.getY();

    if (x>=90 && x<=220 && y >=180 && y<=230)  // Button: Enter
    {
      waitForIt(90, 180, 220, 230);     
    }
    else {
      if (y >= 5 && y <= 235 && x >= 5 && x <= 315){
        myGLCD.print("   ",260,160);
        int x1 = ((x-5)/72+1)*72-72+4;
        int x2 = x1 + 65;
        int y1 = ((y-5)/10+1)*10-10+5;
        int y2 = y1 + 10;
        myGLCD.print((String)((y-5)/10+1),260,160);
        myGLCD.print((String)((x-5)/72+1),280,160);
        myGLCD.setColor(255, 0, 0);
        myGLCD.drawRoundRect (x1, y1, x2, y2);       
        while(myTouch.dataAvailable()){   
        }
        delay(20);
        myGLCD.setColor(0, 255, 0);
        myGLCD.drawRoundRect (x1, y1, x2, y2);   
      }
    }
  }
}


void ListFiles(){
  int x = 5;
  int y = 5;
  String FN;
  String EX;
  myGLCD.clrScr();
  myGLCD.setColor(0, 255, 0);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.setFont(SmallFont); 

  res = file.findFirstFile(&file.DE);
  if (res==NO_ERROR)
  {
    EX = (String)file.DE.fileext;
    EX.trim();
    if(EX == "RAW"){
      myGLCD.print(file.DE.filename, x, y);
      myGLCD.drawRoundRect (x-1, y, x+64, y+10);
      y+=10;
    }
  }
  else
  {
    myGLCD.print("No files found...",CENTER,144);
  }
  while (res==NO_ERROR)
  {
    res = file.findNextFile(&file.DE);
    if (res==NO_ERROR)
    {
      EX = (String)file.DE.fileext;
      EX.trim();
      if(EX == "RAW"){
        myGLCD.print(file.DE.filename, x, y);
        myGLCD.drawRoundRect (x-1, y, x+64, y+10);
        y+=10;
        if (y > 230){
          y = 5;
          x+=72;
        }     
      }
    }
  }
}

ronyboss


I puzzled some hours with exactly the same hardware setup and made a quick & dirty, but successfully test script, combining LCD, Touch and SD Card Features.
While googeling I read some hints about wrong Hardware pin mistakes made by the SainSmart V1 Display boards.
I can NOT agree These discusions.
My board is a SainSmart V1.0 and everything works properly with maximum SPI Speed. 
The hardes part was to get the SD Card filenames on my TFT Display. (not possible with the sd.h library.)
But with the <tinyFAT.h> it works!


Thanks a lot. :) But I already solved the problem. I am using all UTFT libs. ITDB02 Libs also works perfectly.

vahakn

Hi Rony

Im interested in using a TFT for realtime user interface, whilst the arduino handles analog and digital inputs and provides serial Tx outputs to Midi.
I have all the A i/o and Midi stuff working. I wonder if you would recommend this TFT for realtime fast visual feedback?

thanks

Vahakn

garygid

For real-time display, a faster processor might be needed,
like the Due. I have been using the ColdTears Electronics
CTE32HR, CTE35,  CTE40, CTE50, and CTE70 with the Due.
CTE has one shield for the Due, and another for the Mega.

I have modified the UTFT, UTFT_CTE, and UTouch libraries
to support them all, and my Sketch, for the Due, supports
various touch buttons, etc.

Cheers, Gary
Cheers, Gary
Due for controlling Electric car charging.
Nissan LEAF - Mini Quick Charge (mQC)

ronyboss

Thanks for your interest. Please find pictures, demo code and video for TFT touch screen with arduino mega. make sure you download UTFT library from internet.

http://www.mediafire.com/download/z9hu3wv03jyo529/TFT_LCD_with_Mega.rar

Md. Rashedul Amin
Embedded System Engineer
SinePulse GmbH

Go Up