Go Down

Topic: Only Backlight On in ILI9341 TFT LCD Display Module (Read 264 times) previous topic - next topic

chummer1010

Jun 08, 2019, 10:07 pm Last Edit: Jun 08, 2019, 10:09 pm by chummer1010
I ordered a 3.2in Geekcreit ILI9341 TFT LCD Display Module, however none of the example code from the UTFT and URTouch libraries were running - only the white backlight turns on. Has anyone used this screen before that could help point me in the right direction? I am using an Arduino Mega and a shield compatible with the screen, all linked below.


Screen

Shield

URTouch: http://rinkydinkelectronics.com/library.php?id=92
UTFT: http://rinkydinkelectronics.com/library.php?id=51

#include <signature.h>

chummer1010

Here is the code of one of the examples:

Code: [Select]

#include <UTFT.h>
#include <URTouch.h>

UTFT    myGLCD(SSD1289,38,39,40,41);

URTouch  myTouch( 6, 5, 4, 3, 2);

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

int x, y;
char stCurrent[20]="";
int stCurrentLen=0;
char stLast[20]="";

/*************************
**   Custom functions   **
*************************/

void drawButtons()
{
// Draw the upper row of buttons
  for (x=0; x<5; x++)
  {
    myGLCD.setColor(0, 0, 255);
    myGLCD.fillRoundRect (10+(x*60), 10, 60+(x*60), 60);
    myGLCD.setColor(255, 255, 255);
    myGLCD.drawRoundRect (10+(x*60), 10, 60+(x*60), 60);
    myGLCD.printNumI(x+1, 27+(x*60), 27);
  }
// Draw the center row of buttons
  for (x=0; x<5; x++)
  {
    myGLCD.setColor(0, 0, 255);
    myGLCD.fillRoundRect (10+(x*60), 70, 60+(x*60), 120);
    myGLCD.setColor(255, 255, 255);
    myGLCD.drawRoundRect (10+(x*60), 70, 60+(x*60), 120);
    if (x<4)
      myGLCD.printNumI(x+6, 27+(x*60), 87);
  }
  myGLCD.print("0", 267, 87);
// Draw the lower row of buttons
  myGLCD.setColor(0, 0, 255);
  myGLCD.fillRoundRect (10, 130, 150, 180);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (10, 130, 150, 180);
  myGLCD.print("Clear", 40, 147);
  myGLCD.setColor(0, 0, 255);
  myGLCD.fillRoundRect (160, 130, 300, 180);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (160, 130, 300, 180);
  myGLCD.print("Enter", 190, 147);
  myGLCD.setBackColor (0, 0, 0);
}

void updateStr(int val)
{
  if (stCurrentLen<20)
  {
    stCurrent[stCurrentLen]=val;
    stCurrent[stCurrentLen+1]='\0';
    stCurrentLen++;
    myGLCD.setColor(0, 255, 0);
    myGLCD.print(stCurrent, LEFT, 224);
  }
  else
  {
    myGLCD.setColor(255, 0, 0);
    myGLCD.print("BUFFER FULL!", CENTER, 192);
    delay(500);
    myGLCD.print("            ", CENTER, 192);
    delay(500);
    myGLCD.print("BUFFER FULL!", CENTER, 192);
    delay(500);
    myGLCD.print("            ", CENTER, 192);
    myGLCD.setColor(0, 255, 0);
  }
}

// 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())
    myTouch.read();
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
}

/*************************
**  Required functions  **
*************************/

void setup()
{
// Initial setup
  myGLCD.InitLCD();
  myGLCD.clrScr();

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM);

  myGLCD.setFont(BigFont);
  myGLCD.setBackColor(0, 0, 255);
  drawButtons(); 
}

void loop()
{
  while (true)
  {
    if (myTouch.dataAvailable())
    {
      myTouch.read();
      x=myTouch.getX();
      y=myTouch.getY();
     
      if ((y>=10) && (y<=60))  // Upper row
      {
        if ((x>=10) && (x<=60))  // Button: 1
        {
          waitForIt(10, 10, 60, 60);
          updateStr('1');
        }
        if ((x>=70) && (x<=120))  // Button: 2
        {
          waitForIt(70, 10, 120, 60);
          updateStr('2');
        }
        if ((x>=130) && (x<=180))  // Button: 3
        {
          waitForIt(130, 10, 180, 60);
          updateStr('3');
        }
        if ((x>=190) && (x<=240))  // Button: 4
        {
          waitForIt(190, 10, 240, 60);
          updateStr('4');
        }
        if ((x>=250) && (x<=300))  // Button: 5
        {
          waitForIt(250, 10, 300, 60);
          updateStr('5');
        }
      }

      if ((y>=70) && (y<=120))  // Center row
      {
        if ((x>=10) && (x<=60))  // Button: 6
        {
          waitForIt(10, 70, 60, 120);
          updateStr('6');
        }
        if ((x>=70) && (x<=120))  // Button: 7
        {
          waitForIt(70, 70, 120, 120);
          updateStr('7');
        }
        if ((x>=130) && (x<=180))  // Button: 8
        {
          waitForIt(130, 70, 180, 120);
          updateStr('8');
        }
        if ((x>=190) && (x<=240))  // Button: 9
        {
          waitForIt(190, 70, 240, 120);
          updateStr('9');
        }
        if ((x>=250) && (x<=300))  // Button: 0
        {
          waitForIt(250, 70, 300, 120);
          updateStr('0');
        }
      }

      if ((y>=130) && (y<=180))  // Upper row
      {
        if ((x>=10) && (x<=150))  // Button: Clear
        {
          waitForIt(10, 130, 150, 180);
          stCurrent[0]='\0';
          stCurrentLen=0;
          myGLCD.setColor(0, 0, 0);
          myGLCD.fillRect(0, 224, 319, 239);
        }
        if ((x>=160) && (x<=300))  // Button: Enter
        {
          waitForIt(160, 130, 300, 180);
          if (stCurrentLen>0)
          {
            for (x=0; x<stCurrentLen+1; x++)
            {
              stLast[x]=stCurrent[x];
            }
            stCurrent[0]='\0';
            stCurrentLen=0;
            myGLCD.setColor(0, 0, 0);
            myGLCD.fillRect(0, 208, 319, 239);
            myGLCD.setColor(0, 255, 0);
            myGLCD.print(stLast, LEFT, 208);
          }
          else
          {
            myGLCD.setColor(255, 0, 0);
            myGLCD.print("BUFFER EMPTY", CENTER, 192);
            delay(500);
            myGLCD.print("            ", CENTER, 192);
            delay(500);
            myGLCD.print("BUFFER EMPTY", CENTER, 192);
            delay(500);
            myGLCD.print("            ", CENTER, 192);
            myGLCD.setColor(0, 255, 0);
          }
        }
      }
    }
  }
}
#include <signature.h>

david_prentice

#2
Jun 08, 2019, 11:44 pm Last Edit: Jun 08, 2019, 11:46 pm by david_prentice
Go on.   Your links show a pcb which clearly says TFT_320QVT_9341  (i.e. Ilitech ILI9341)

It is extremely unlikely that any old TFT_320QVT screens with SSD1289 are left on the market.   As far as I know,   the TFT_320QVT_9341 screens have been sold for the last 4 or 5 years.

Install the current UTFT library.   (I think it is v2.82 version 2.83)
Use an appropriate constructor e.g.
Code: [Select]

UTFT    myGLCD(ILI9341_16,38,39,40,41);

 

I do not own a TFT_320QVT_9341 screen or your 40-pin Adapter shield.
But I would expect both items to work 100%.    And I am certain that their are many readers who own exactly the same screen and Adapter shield.

David.

chummer1010

Go on.   Your links show a pcb which clearly says TFT_320QVT_9341  (i.e. Ilitech ILI9341)

It is extremely unlikely that any old TFT_320QVT screens with SSD1289 are left on the market.   As far as I know,   the TFT_320QVT_9341 screens have been sold for the last 4 or 5 years.

Install the current UTFT library.   (I think it is v2.82 version 2.83)
Use an appropriate constructor e.g.
Code: [Select]

UTFT    myGLCD(ILI9341_16,38,39,40,41);

 

I do not own a TFT_320QVT_9341 screen or your 40-pin Adapter shield.
But I would expect both items to work 100%.    And I am certain that their are many readers who own exactly the same screen and Adapter shield.

David.
Thank you David! That was the correct model parameter, I did not use the right one initially. The LCD is up and running- however the touchscreen is not. I know the pins (6, 5, 4, 3, 2) are the correct ones for the Mega shield.. maybe outdated library?
#include <signature.h>

chummer1010

Every time I upload a sketch, these messages pop up- it still uploads and runs the sketch though.

Code: [Select]

/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino: In function 'void drawButtons()':
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino:75:28: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   myGLCD.print("0", 267, 87);
                            ^
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino:81:32: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   myGLCD.print("Clear", 40, 147);
                                ^
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino:86:33: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   myGLCD.print("Enter", 190, 147);
                                 ^
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino: In function 'void updateStr(int)':
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino:103:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     myGLCD.print("BUFFER FULL!", CENTER, 192);
                                             ^
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino:105:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     myGLCD.print("            ", CENTER, 192);
                                             ^
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino:107:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     myGLCD.print("BUFFER FULL!", CENTER, 192);
                                             ^
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino:109:45: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     myGLCD.print("            ", CENTER, 192);
                                             ^
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino: In function 'void loop()':
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino:240:53: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
             myGLCD.print("BUFFER EMPTY", CENTER, 192);
                                                     ^
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino:242:53: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
             myGLCD.print("            ", CENTER, 192);
                                                     ^
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino:244:53: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
             myGLCD.print("BUFFER EMPTY", CENTER, 192);
                                                     ^
/var/folders/50/9h_yyw5n0cv61qpw41mm_ldr0000gn/T/arduino_modified_sketch_68987/URTouch_ButtonTest.ino:246:53: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
             myGLCD.print("            ", CENTER, 192);
                                                     ^
#include <signature.h>

Go Up