Go Down

Topic: 3.2" tft lcd shield (SSD1289) White, Flickering Display Problem on UNO (Read 6352 times) previous topic - next topic

DotScott

Hey everyone. I've been after this for a while now but have yet to resolve this problem:

I purchased a 3.2" tft lcd shield + touch panel TF Reader for arduino that claims that it works with the Arduino UNO (even shows it being attached to an Arduino Uno in the product image). I have no idea what the name of the shield is since it doens't mention it on the shield or in the description for the item but it does say that it uses SSD1289 controller and links to that same website (but a different code [other than UTFT]?? check out the "downloads" on that ebay listing).

Link to the item (hopefully it will stick around for a while): http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=270972145966&fromMakeTrack=true#ht_2045wt_699

I've attached it to my Arduino UNO and am using code and libraries from the link below (standard UTFT). The display resolution on the LCD monitor is 320*240 pixels so naturally I tried the UTFT example meant for 320*240. I've modified the code for my display (as far as I know) but all I get is a white, randomly flickering screen (doesn't always flicker). In the code, I inserted SSD1289 for the controller (search for "DotScott" on this page to see my notes in the code).

Link to UTFT: http://www.henningkarlsen.com/electronics/library.php?id=51

320*240 example code, modified for UNO and my shield:

Code: [Select]
// UTFT_Demo_320x240 (C)2012 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program is a demo of how to use most of the functions
// of the library with a supported display modules.
//
// This demo was made for modules with a screen resolution
// of 320x240 pixels.
//
// This program requires the UTFT library.
//

#include <UTFT.h>

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

// Uncomment the next line for Arduino 2009/Uno
UTFT myGLCD(SSD1289,A1,A2,A0,A4,A5);  // Remember to change the model parameter to suit your display module!

//DotScott note: originally with UTFT myGLCD(SSD1289,19,18,17,16); but items' //code says UTFT myGLCD(SSD1289,A1,A2,A0,A4,A5);

// DotScott note: ^changed ITDB32S to SSD1289

// 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!

void setup()
{
 randomSeed(analogRead(0));
 
// Setup the LCD
 myGLCD.InitLCD(); // DotScott note: I've tried values of 0 and 1 here.
 myGLCD.setFont(SmallFont);
}

void loop()
{
 int buf[318];
 int x, x2;
 int y, y2;
 int r;

// Clear the screen and draw the frame
 myGLCD.clrScr();

 myGLCD.setColor(255, 0, 0);
 myGLCD.fillRect(0, 0, 319, 13);
 myGLCD.setColor(64, 64, 64);
 myGLCD.fillRect(0, 226, 319, 239);
 myGLCD.setColor(255, 255, 255);
 myGLCD.setBackColor(255, 0, 0);
 myGLCD.print("* Universal Color TFT Display Library *", CENTER, 1);
 myGLCD.setBackColor(64, 64, 64);
 myGLCD.setColor(255,255,0);
 myGLCD.print("<http://electronics.henningkarlsen.com>", CENTER, 227);

 myGLCD.setColor(0, 0, 255);
 myGLCD.drawRect(0, 14, 319, 225);

// Draw crosshairs
 myGLCD.setColor(0, 0, 255);
 myGLCD.setBackColor(0, 0, 0);
 myGLCD.drawLine(159, 15, 159, 224);
 myGLCD.drawLine(1, 119, 318, 119);
 for (int i=9; i<310; i+=10)
   myGLCD.drawLine(i, 117, i, 121);
 for (int i=19; i<220; i+=10)
   myGLCD.drawLine(157, i, 161, i);

// Draw sin-, cos- and tan-lines  
 myGLCD.setColor(0,255,255);
 myGLCD.print("Sin", 5, 15);
 for (int i=1; i<318; i++)
 {
   myGLCD.drawPixel(i,119+(sin(((i*1.13)*3.14)/180)*95));
 }
 
 myGLCD.setColor(255,0,0);
 myGLCD.print("Cos", 5, 27);
 for (int i=1; i<318; i++)
 {
   myGLCD.drawPixel(i,119+(cos(((i*1.13)*3.14)/180)*95));
 }

 myGLCD.setColor(255,255,0);
 myGLCD.print("Tan", 5, 39);
 for (int i=1; i<318; i++)
 {
   myGLCD.drawPixel(i,119+(tan(((i*1.13)*3.14)/180)));
 }

 delay(2000);

 myGLCD.setColor(0,0,0);
 myGLCD.fillRect(1,15,318,224);
 myGLCD.setColor(0, 0, 255);
 myGLCD.setBackColor(0, 0, 0);
 myGLCD.drawLine(159, 15, 159, 224);
 myGLCD.drawLine(1, 119, 318, 119);

// Draw a moving sinewave
 x=1;
 for (int i=1; i<(318*20); i++)
 {
   x++;
   if (x==319)
     x=1;
   if (i>319)
   {
     if ((x==159)||(buf[x-1]==119))
       myGLCD.setColor(0,0,255);
     else
       myGLCD.setColor(0,0,0);
     myGLCD.drawPixel(x,buf[x-1]);
   }
   myGLCD.setColor(0,255,255);
   y=119+(sin(((i*1.1)*3.14)/180)*(90-(i / 100)));
   myGLCD.drawPixel(x,y);
   buf[x-1]=y;
 }

 delay(2000);
 
 myGLCD.setColor(0,0,0);
 myGLCD.fillRect(1,15,318,224);

// Draw some filled rectangles
 for (int i=1; i<6; i++)
 {
   switch (i)
   {
     case 1:
       myGLCD.setColor(255,0,255);
       break;
     case 2:
       myGLCD.setColor(255,0,0);
       break;
     case 3:
       myGLCD.setColor(0,255,0);
       break;
     case 4:
       myGLCD.setColor(0,0,255);
       break;
     case 5:
       myGLCD.setColor(255,255,0);
       break;
   }
   myGLCD.fillRect(70+(i*20), 30+(i*20), 130+(i*20), 90+(i*20));
 }

 delay(2000);
 
 myGLCD.setColor(0,0,0);
 myGLCD.fillRect(1,15,318,224);

// Draw some filled, rounded rectangles
 for (int i=1; i<6; i++)
 {
   switch (i)
   {
     case 1:
       myGLCD.setColor(255,0,255);
       break;
     case 2:
       myGLCD.setColor(255,0,0);
       break;
     case 3:
       myGLCD.setColor(0,255,0);
       break;
     case 4:
       myGLCD.setColor(0,0,255);
       break;
     case 5:
       myGLCD.setColor(255,255,0);
       break;
   }
   myGLCD.fillRoundRect(190-(i*20), 30+(i*20), 250-(i*20), 90+(i*20));
 }
 
 delay(2000);
 
 myGLCD.setColor(0,0,0);
 myGLCD.fillRect(1,15,318,224);

// Draw some filled circles
 for (int i=1; i<6; i++)
 {
   switch (i)
   {
     case 1:
       myGLCD.setColor(255,0,255);
       break;
     case 2:
       myGLCD.setColor(255,0,0);
       break;
     case 3:
       myGLCD.setColor(0,255,0);
       break;
     case 4:
       myGLCD.setColor(0,0,255);
       break;
     case 5:
       myGLCD.setColor(255,255,0);
       break;
   }
   myGLCD.fillCircle(100+(i*20),60+(i*20), 30);
 }
 
 delay(2000);
 
 myGLCD.setColor(0,0,0);
 myGLCD.fillRect(1,15,318,224);

// Draw some lines in a pattern
 myGLCD.setColor (255,0,0);
 for (int i=15; i<224; i+=5)
 {
   myGLCD.drawLine(1, i, (i*1.44)-10, 224);
 }
 myGLCD.setColor (255,0,0);
 for (int i=224; i>15; i-=5)
 {
   myGLCD.drawLine(318, i, (i*1.44)-11, 15);
 }
 myGLCD.setColor (0,255,255);
 for (int i=224; i>15; i-=5)
 {
   myGLCD.drawLine(1, i, 331-(i*1.44), 15);
 }
 myGLCD.setColor (0,255,255);
 for (int i=15; i<224; i+=5)
 {
   myGLCD.drawLine(318, i, 330-(i*1.44), 224);
 }
 
 delay(2000);
 
 myGLCD.setColor(0,0,0);
 myGLCD.fillRect(1,15,318,225);

// Draw some random circles
 for (int i=0; i<100; i++)
 {
   myGLCD.setColor(random(255), random(255), random(255));
   x=32+random(256);
   y=45+random(146);
   r=random(30);
   myGLCD.drawCircle(x, y, r);
 }

 delay(2000);
 
 myGLCD.setColor(0,0,0);
 myGLCD.fillRect(1,15,318,224);

// Draw some random rectangles
 for (int i=0; i<100; i++)
 {
   myGLCD.setColor(random(255), random(255), random(255));
   x=2+random(316);
   y=16+random(207);
   x2=2+random(316);
   y2=16+random(207);
   myGLCD.drawRect(x, y, x2, y2);
 }

 delay(2000);
 
 myGLCD.setColor(0,0,0);
 myGLCD.fillRect(1,15,318,224);

// Draw some random rounded rectangles
 for (int i=0; i<100; i++)
 {
   myGLCD.setColor(random(255), random(255), random(255));
   x=2+random(316);
   y=16+random(207);
   x2=2+random(316);
   y2=16+random(207);
   myGLCD.drawRoundRect(x, y, x2, y2);
 }

 delay(2000);
 
 myGLCD.setColor(0,0,0);
 myGLCD.fillRect(1,15,318,224);

 for (int i=0; i<100; i++)
 {
   myGLCD.setColor(random(255), random(255), random(255));
   x=2+random(316);
   y=16+random(209);
   x2=2+random(316);
   y2=16+random(209);
   myGLCD.drawLine(x, y, x2, y2);
 }

 delay(2000);
 
 myGLCD.setColor(0,0,0);
 myGLCD.fillRect(1,15,318,224);

 for (int i=0; i<10000; i++)
 {
   myGLCD.setColor(random(255), random(255), random(255));
   myGLCD.drawPixel(2+random(316), 16+random(209));
 }

 delay(2000);

 myGLCD.fillScr(0, 0, 255);
 myGLCD.setColor(255, 0, 0);
 myGLCD.fillRoundRect(80, 70, 239, 169);
 
 myGLCD.setColor(255, 255, 255);
 myGLCD.setBackColor(255, 0, 0);
 myGLCD.print("That's it!", CENTER, 93);
 myGLCD.print("Restarting in a", CENTER, 119);
 myGLCD.print("few seconds...", CENTER, 132);
 
 myGLCD.setColor(0, 255, 0);
 myGLCD.setBackColor(0, 0, 255);
 myGLCD.print("Runtime: (msecs)", CENTER, 210);
 myGLCD.printNumI(millis(), CENTER, 225);
 
 delay (10000);
}


Arduino 1.0.1 as well as Arduino 0023.

Am I missing something somewhere? Is anyone else out there having this problem?

MarkT

Change the line:
Code: [Select]
UTFT myGLCD(SSD1289,A1,A2,A0,A4,A5);  // Remember to change the model parameter to suit your display module!


to:
Code: [Select]
UTFT myGLCD(SSD1289,A1,A2,A0,A3);   // A3 is RESET pin


So it corresponds to the pinout for the device as given in its user guide.
[ I won't respond to messages, use the forum please ]

DotScott

Thanks for your help, my friend! Unfortunately that didn't quite work. I still get the white screen.

I did, however, get the display to work with a different code. I'm going to compare the two to see where it is going wrong on the (newer) UTFT.

Here's the working (ITDB02) code for display that uses SSD1289 controller on Arduino UNO:
Code: [Select]
#include <Wire.h>

// ITDB02_Graph16_Demo (C)2011 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program is a demo of how to use most of the functions
// of the library with a supported 16bit display module.
//
// This demo was not made for the widescreen modules. Use
// ITDB02_Graph16_Demo_Widescreen instead.
//
// This program requires the ITDB02_Graph16 library.
//

#include <ITDB02_Graph16.h>

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

//myGLCD(RS,WR,CS,RST,ALE,mode);
ITDB02 myGLCD(A1,A2,A0,A4,A5,2);   //



void setup()
{
  //randomSeed(analogRead(0));
  //Serial.begin(9600);
// Setup the LCD
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
}
void loop1()
{
  myGLCD.LCD_Writ_Bus(0x55,0xaa);
  delay(10);
  myGLCD.LCD_Writ_Bus(0xaa,0x55);
  delay(10);
  //Serial.println("write bus");
  myGLCD.clrScr();
}
void loop()
{
  int buf[238];
  int x, x2;
  int y, y2;
  int r;

// Clear the screen and draw the frame
  myGLCD.clrScr();

  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 239, 13);
  myGLCD.setColor(64, 64, 64);
  myGLCD.fillRect(0, 306, 239, 319);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.print("QVGA TFT 240x320 Color Display", CENTER, 1);
  myGLCD.setColor(255, 128, 128);
  myGLCD.setBackColor(64, 64, 64);
  myGLCD.print("H.Karlsen", LEFT, 307);
  myGLCD.print("(C)2011", RIGHT, 307);
  myGLCD.setColor(255,255,0);
  myGLCD.print("Portrait", CENTER, 307);

  myGLCD.setColor(0, 0, 255);
  myGLCD.drawLine(0, 14, 239, 14);
  myGLCD.drawLine(0, 14, 0, 305);
  myGLCD.drawLine(239, 14, 239, 305);
  myGLCD.drawLine(0, 305, 239, 305);

// Draw crosshairs
  myGLCD.setColor(0, 0, 255);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.drawLine(119, 15, 119, 304);
  myGLCD.drawLine(1, 159, 238, 159);
  for (int i=9; i<240; i+=10)
    myGLCD.drawLine(i, 157, i, 161);
  for (int i=19; i<300; i+=10)
    myGLCD.drawLine(117, i, 121, i);
 
// Draw sin-, cos- and tan-lines 
  myGLCD.setColor(0,255,255);
  myGLCD.print("Sin", 5, 15);
  for (int i=1; i<238; i++)
  {
    myGLCD.drawPixel(i,159+(sin(((i*1.51)*3.14)/180)*100));
  }
 
  myGLCD.setColor(255,0,0);
  myGLCD.print("Cos", 5, 27);
  for (int i=1; i<238; i++)
  {
    myGLCD.drawPixel(i,159+(cos(((i*1.51)*3.14)/180)*100));
  }

  myGLCD.setColor(255,255,0);
  myGLCD.print("Tan", 5, 39);
  for (int i=1; i<238; i++)
  {
    myGLCD.drawPixel(i,159+(tan(((i*1.51)*3.14)/180)));
  }

  delay(2000);
 
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,238,304);
  myGLCD.setColor(0, 0, 255);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.drawLine(119, 15, 119, 304);
  myGLCD.drawLine(1, 159, 238, 159);

// Draw a moving sinewave
  x=1;
  for (int i=1; i<6902; i++)
  {
    x++;
    if (x==239)
      x=1;
    if (i>239)
    {
      if ((x==119)||(buf[x-1]==159))
        myGLCD.setColor(0,0,255);
      else
        myGLCD.setColor(0,0,0);
      myGLCD.drawPixel(x,buf[x-1]);
    }
    myGLCD.setColor(0,255,255);
    y=159+(sin(((i*1.4)*3.14)/180)*(100-(i / 100)));
    myGLCD.drawPixel(x,y);
    buf[x-1]=y;
  }

  delay(2000);
 
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,238,304);

// Draw some filled rectangles
  for (int i=1; i<6; i++)
  {
    switch (i)
    {
      case 1:
        myGLCD.setColor(255,0,255);
        break;
      case 2:
        myGLCD.setColor(255,0,0);
        break;
      case 3:
        myGLCD.setColor(0,255,0);
        break;
      case 4:
        myGLCD.setColor(0,0,255);
        break;
      case 5:
        myGLCD.setColor(255,255,0);
        break;
    }
    myGLCD.fillRect(30+(i*20), 70+(i*20), 90+(i*20), 130+(i*20));
  }

  delay(2000);
 
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,238,304);

// Draw some filled, rounded rectangles
  for (int i=1; i<6; i++)
  {
    switch (i)
    {
      case 1:
        myGLCD.setColor(255,0,255);
        break;
      case 2:
        myGLCD.setColor(255,0,0);
        break;
      case 3:
        myGLCD.setColor(0,255,0);
        break;
      case 4:
        myGLCD.setColor(0,0,255);
        break;
      case 5:
        myGLCD.setColor(255,255,0);
        break;
    }
    myGLCD.fillRoundRect(150-(i*20),70+(i*20), 210-(i*20), 130+(i*20));
  }
 
  delay(2000);
 
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,238,304);

// Draw some filled circles
  for (int i=1; i<6; i++)
  {
    switch (i)
    {
      case 1:
        myGLCD.setColor(255,0,255);
        break;
      case 2:
        myGLCD.setColor(255,0,0);
        break;
      case 3:
        myGLCD.setColor(0,255,0);
        break;
      case 4:
        myGLCD.setColor(0,0,255);
        break;
      case 5:
        myGLCD.setColor(255,255,0);
        break;
    }
    myGLCD.fillCircle(60+(i*20),100+(i*20), 30);
  }
 
  delay(2000);
 
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,238,304);

// Draw some lines in a pattern
  myGLCD.setColor (255,0,0);
  for (int i=15; i<304; i+=5)
  {
    myGLCD.drawLine(1, i, (i/1.22)-10, 304);
  }
  myGLCD.setColor (255,0,0);
  for (int i=304; i>15; i-=5)
  {
    myGLCD.drawLine(238, i, (i/1.22)-11, 15);
  }
  myGLCD.setColor (0,255,255);
  for (int i=304; i>15; i-=5)
  {
    myGLCD.drawLine(1, i, 251-(i/1.22), 15);
  }
  myGLCD.setColor (0,255,255);
  for (int i=15; i<304; i+=5)
  {
    myGLCD.drawLine(238, i, 250-(i/1.22), 304);
  }
 
  delay(2000);
 
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,238,304);

// Draw some random circles
  for (int i=0; i<100; i++)
  {
    myGLCD.setColor(random(255), random(255), random(255));
    x=32+random(175);
    y=45+random(212);
    r=random(30);
    myGLCD.drawCircle(x, y, r);
  }

  delay(2000);
 
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,238,304);

// Draw some random rectangles
  for (int i=0; i<100; i++)
  {
    myGLCD.setColor(random(255), random(255), random(255));
    x=2+random(236);
    y=16+random(287);
    x2=2+random(236);
    y2=16+random(287);
    myGLCD.drawRect(x, y, x2, y2);
  }

  delay(2000);
 
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,238,304);

// Draw some random rounded rectangles
  for (int i=0; i<100; i++)
  {
    myGLCD.setColor(random(255), random(255), random(255));
    x=2+random(236);
    y=16+random(287);
    x2=2+random(236);
    y2=16+random(287);
    myGLCD.drawRoundRect(x, y, x2, y2);
  }

  delay(2000);
 
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(2,16,238,304);

  for (int i=0; i<100; i++)
  {
    myGLCD.setColor(random(255), random(255), random(255));
    x=2+random(236);
    y=16+random(289);
    x2=2+random(236);
    y2=16+random(289);
    myGLCD.drawLine(x, y, x2, y2);
  }

  delay(2000);
 
  myGLCD.setColor(0,0,0);
  myGLCD.fillRect(1,15,238,304);

  for (int i=0; i<10000; i++)
  {
    myGLCD.setColor(random(255), random(255), random(255));
    myGLCD.drawPixel(2+random(236), 16+random(289));
  }

  delay(2000);

  myGLCD.fillScr(0, 0, 255);
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRoundRect(30, 100, 209, 219);
 
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.print("That's it!", CENTER, 133);
  myGLCD.print("Restarting in a", CENTER, 159);
  myGLCD.print("few seconds...", CENTER, 172);
 
  myGLCD.setColor(0, 0, 0);
  myGLCD.setBackColor(0, 0, 255);
  myGLCD.print("Runtime: (msecs)", CENTER, 290);
  myGLCD.printNumI(millis(), CENTER, 305);
 
  delay (10000);
}

MarkT

You should try and work out whether the user guide is right or wrong about the reset pinout - it doesn't agree with either of those
drivers...
[ I won't respond to messages, use the forum please ]

sanni

Here try this modified library.
It's working great together with my Uno R3 and this lcd tft shield.

I also have a question for anyone that also has this shield. I need to free up a pin. Which pin would be easiest. I don't want to destroy the LCD TFT by outputting 5V to some part I shouldn't.

DotScott

Thanks, Sanni! I'll give it a shot as soon as I can and let you know how it goes. I have gotten the screen to work properly but not touch. I have tried a few different codes and have been working on modifying them but no success yet. Have you had that problem?

sanni

The samples included in my attachement work fine for me. Be sure to run the touch calibration sample first to see if you need to recalibrate the touchscreen.

http://www.youtube.com/watch?v=rqaveUGnhY4

I also attached the schematics:

tscott19106

Hello everyone. I've got the same tft shield, when I first recieved it, I was able to get the graph demo working. But now it has the same problem, it is just a white screen. No matter what sketch I use, the screen just stays white.

Is this thing fried?? or is there some sort of test I can do to determine if it is still working??

Thanks in advance for any help.

Go Up