Go Down

Topic: Adafruit TFTLCD not working (Read 521 times) previous topic - next topic

czvikik

Hello, I have a problem. The library Adadruit_TFTLCD cant be compiled, but idont know why. Please help.

i use Arduino IDE 1.8.10

Paul__B

Aww, shucks!

We don't know either!  :smiley-eek:

czvikik

#2
Jul 18, 2019, 07:36 am Last Edit: Jul 18, 2019, 07:37 am by czvikik
And you don't know at least some alternative with same functions?

sterretje

#3
Jul 18, 2019, 08:19 am Last Edit: Jul 18, 2019, 08:20 am by sterretje
What Paul__B is saying is that your post is missing details.

1)
Exactly which library? I googled arduino Adadruit_TFTLCD and found https://github.com/adafruit/TFTLCD-Library. Downloaded and installed it.
2)
Which board? I successfully compiled the rotationtest example for an Arduino Leonardo.
3)
Version of the IDE? I'm still using IDE 1.8.5.

Conclusion the problem is at your side but without knowing your code and the errors that you get, we can't help. Please read the sticky How to use this forum - please read and pay specific attention to point #7 about posting code.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

david_prentice

#4
Jul 18, 2019, 08:35 am Last Edit: Jul 18, 2019, 08:37 am by david_prentice
The most important info is a link to  the actual display that is on your desk e.g.  Ebay sale

Then we know what  to advise.

If you are determined to use "Adafruit_TFTLCD"  you must provide a  link to the actual library that you have installed e.g. from IDE Library Manager.
Unfortunately there are many hacked versions of the original Adafruit library code.

The Arduino board is easy.   Just quote the model  name e.g. Uno, Zero, Due, ...

David.

czvikik

#5
Jul 18, 2019, 05:33 pm Last Edit: Jul 18, 2019, 05:35 pm by czvikik
I use the version that i downloaded 2 days ago. Im using arduino MEGA and this display..

https://www.banggood.com/Geekcreit-UNO-R3-Improved-Version-2_8TFT-LCD-Touch-Screen-2_4TFT-Touch-Screen-Display-Module-Kit-For-Arduino-p-1428291.html?rmmds=myorder&cur_warehouse=CN

The 2.8 One

The code was that:
Code: [Select]

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library

// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0

#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
//   D0 connects to digital pin 8  (Notice these are
//   D1 connects to digital pin 9   NOT in order!)
//   D2 connects to digital pin 2
//   D3 connects to digital pin 3
//   D4 connects to digital pin 4
//   D5 connects to digital pin 5
//   D6 connects to digital pin 6
//   D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).

// Assign human-readable names to some common 16-bit color values:
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
// If using the shield, all control and data lines are fixed, and
// a simpler declaration can optionally be used:
// Adafruit_TFTLCD tft;

void setup(void) {
  Serial.begin(9600);
  Serial.println(F("TFT LCD test"));

#ifdef USE_ADAFRUIT_SHIELD_PINOUT
  Serial.println(F("Using Adafruit 2.8\" TFT Arduino Shield Pinout"));
#else
  Serial.println(F("Using Adafruit 2.8\" TFT Breakout Board Pinout"));
#endif

  Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());

  tft.reset();

  uint16_t identifier = tft.readID();

  if(identifier == 0x9325) {
    Serial.println(F("Found ILI9325 LCD driver"));
  } else if(identifier == 0x9328) {
    Serial.println(F("Found ILI9328 LCD driver"));
  } else if(identifier == 0x7575) {
    Serial.println(F("Found HX8347G LCD driver"));
  } else if(identifier == 0x9341) {
    Serial.println(F("Found ILI9341 LCD driver"));
  } else if(identifier == 0x8357) {
    Serial.println(F("Found HX8357D LCD driver"));
  } else {
    Serial.print(F("Unknown LCD driver chip: "));
    Serial.println(identifier, HEX);
    Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
    Serial.println(F("  #define USE_ADAFRUIT_SHIELD_PINOUT"));
    Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
    Serial.println(F("If using the breakout board, it should NOT be #defined!"));
    Serial.println(F("Also if using the breakout, double-check that all wiring"));
    Serial.println(F("matches the tutorial."));
    return;
  }

  tft.begin(identifier);

  Serial.println(F("Benchmark                Time (microseconds)"));

  Serial.print(F("Screen fill              "));
  Serial.println(testFillScreen());
  delay(500);

  Serial.print(F("Text                     "));
  Serial.println(testText());
  delay(3000);

  Serial.print(F("Lines                    "));
  Serial.println(testLines(CYAN));
  delay(500);

  Serial.print(F("Horiz/Vert Lines         "));
  Serial.println(testFastLines(RED, BLUE));
  delay(500);

  Serial.print(F("Rectangles (outline)     "));
  Serial.println(testRects(GREEN));
  delay(500);

  Serial.print(F("Rectangles (filled)      "));
  Serial.println(testFilledRects(YELLOW, MAGENTA));
  delay(500);

  Serial.print(F("Circles (filled)         "));
  Serial.println(testFilledCircles(10, MAGENTA));

  Serial.print(F("Circles (outline)        "));
  Serial.println(testCircles(10, WHITE));
  delay(500);

  Serial.print(F("Triangles (outline)      "));
  Serial.println(testTriangles());
  delay(500);

  Serial.print(F("Triangles (filled)       "));
  Serial.println(testFilledTriangles());
  delay(500);

  Serial.print(F("Rounded rects (outline)  "));
  Serial.println(testRoundRects());
  delay(500);

  Serial.print(F("Rounded rects (filled)   "));
  Serial.println(testFilledRoundRects());
  delay(500);

  Serial.println(F("Done!"));
}

void loop(void) {
  for(uint8_t rotation=0; rotation<4; rotation++) {
    tft.setRotation(rotation);
    testText();
    delay(2000);
  }
}

unsigned long testFillScreen() {
  unsigned long start = micros();
  tft.fillScreen(BLACK);
  tft.fillScreen(RED);
  tft.fillScreen(GREEN);
  tft.fillScreen(BLUE);
  tft.fillScreen(BLACK);
  return micros() - start;
}

unsigned long testText() {
  tft.fillScreen(BLACK);
  unsigned long start = micros();
  tft.setCursor(0, 0);
  tft.setTextColor(WHITE);  tft.setTextSize(1);
  tft.println("Hello World!");
  tft.setTextColor(YELLOW); tft.setTextSize(2);
  tft.println(1234.56);
  tft.setTextColor(RED);    tft.setTextSize(3);
  tft.println(0xDEADBEEF, HEX);
  tft.println();
  tft.setTextColor(GREEN);
  tft.setTextSize(5);
  tft.println("Groop");
  tft.setTextSize(2);
  tft.println("I implore thee,");
  tft.setTextSize(1);
  tft.println("my foonting turlingdromes.");
  tft.println("And hooptiously drangle me");
  tft.println("with crinkly bindlewurdles,");
  tft.println("Or I will rend thee");
  tft.println("in the gobberwarts");
  tft.println("with my blurglecruncheon,");
  tft.println("see if I don't!");
  return micros() - start;
}

unsigned long testLines(uint16_t color) {
  unsigned long start, t;
  int           x1, y1, x2, y2,
                w = tft.width(),
                h = tft.height();


//... i was have to short the code
}


But that cant be compiled at all.

david_prentice

#6
Jul 18, 2019, 05:56 pm Last Edit: Jul 18, 2019, 06:04 pm by david_prentice
Thanks for your link to the Banggood display

Unfortunately I can't copy the Blue 2.8 inch pcb photo to this message.
However both Red 2.4 inch and Blue 2.8 inch shields are "Mcufriend" pcbs

The Mcufriend displays "work" but have serious hardware design faults.
They often contain different controllers.   Sometimes these controllers are unknown.

Quote
I use the version that i downloaded 2 days ago. Im using arduino MEGA and this display..
Where did you download it?
It could come from anywhere.   We need to see what you are using.
I would only install a library via the IDE Library Manager.

I suggest that you Install/Upgrade MCUFRIEND_kbv and Adafruit_GFX via the IDE Library Manager.
If it does not work out of the box,   run  Diagnose_TFT_Controller example that comes with the library.
Also LCD_ID_readreg example.
Copy-Paste any messages printed on the Serial Terminal to your message.

When we know which controller is actually mounted on your display we can tell you whether the genuine Adafruit_TFTLCD supports it.

David.


Paul__B

#7
Jul 19, 2019, 12:14 am Last Edit: Jul 19, 2019, 12:17 am by Paul__B
Unfortunately I can't copy the Blue 2.8 inch PCB photo to this message.
They don't make it easy!  Typical mendacious obfuscation!



I had a mind to buy these (it is of course, not a UNO at all but a common Duemilanove "clone" variant) just to play with, but you have put me off now with your advice!  :smiley-eek:

david_prentice

#8
Jul 19, 2019, 10:00 am Last Edit: Jul 19, 2019, 10:01 am by david_prentice
Quote
I had a mind to buy these (it is of course, not a UNO at all but a common Duemilanove "clone" variant) just to play with, but you have put me off now with your advice!  :smiley-eek:
I don't understand.   The "Uno R3 clone" will behave like a Uno R3 i.e. same bootloader.
Ok,  it has a Chinese CH340 USB-Serial chip instead of ATmega16u2.
A Duemilanove has a FTDI USB-Serial chip and a different bootloader.

Neither the Red 2.4 inch nor Blue 2.8 inch shields contain a 3.3V LDO regulator.
The 3.3V regulator on the "Uno clone" has maximum 50mA which is not enough for the shield backlight.

Mcufriend omits the LDO regulator on 2.4, 2.8, 3.5 inch shields.
2.4 inch backlights take 50-100mA
3.5 inch backlights take 100-300mA
This is WRONG.    Uno and Mega 3.3V pin can NOT supply this current.

Mcufriend often mount different controllers.   You don't know which one until you receive the shield.

If you actually receive HX8347 or ILI9341 I would expect the Banggood libraries to "work"
However the Banggood libraries are fairly old.   There might be compilation problems with the modern IDE tools.    If the OP says which specific library(s) he is using I could try it.

David.

Paul__B

I don't understand.   The "Uno R3 clone" will behave like a Uno R3 i.e. same bootloader.
So you consider that the UNO is defined by the bootloader it uses then?

I tend to think of it being defined by the hardware, as you can (and probably would) easily put a UNO bootloader on a Duemilanove.

david_prentice

From a User's point of view it is the "Board" selected in the IDE.

A Uno R3 has the extra SDA, SCL sockets on the digital #8 -#13 header that are not present on a Duemilanove.

But the main difference is that a Uno bootloader runs at 115k baud and give you 31.5kB for Applications.
The Duemilanove bootloader runs at 57k baud and only gives you 28kB for Applications.

Yes,  you can just "Burn the Uno Bootloader" onto Duemilanove hardware and turn it into a Uno.
Likewise,  you can turn Nano hardware into a Uno.

Regarding the "Uno R3 clone" from Banggood.
1.  Genuine Uno or Duemilanove Serial driver has a fixed COM#
the CH340 Serial driver changes "COM#" with physical USB socket on the PC

2.  Genuine Uno has a solder-bridge for debugWIRE hardware debugging.
the "clone" has lots of useful holes for mounting extra headers.

I have major criticisms of the Mcufriend Shields.
But the Chinese "Uno R3 clone" is excellent.   (I prefer the yellow micro-USB socket version)

David.

pert

Hello, I have a problem. The library Adadruit_TFTLCD cant be compiled, but idont know why. Please help.
The 1.5.4 release of the Adafruit_GFX broke compatibility with the Adafruit_TFTLCD library. You'll need to roll back to Adafruit_GFX 1.5.3:
  • Sketch > Include Library > Manage Libraries
  • Wait for the download to finish
  • In the "Filter your search..." box, type "adafruit_gfx".
  • Press Enter.
  • From the search results, click on "Adafruit GFX Library by Adafruit".
  • From the dropdown version menu, select 1.5.3.
  • Click the "Install" button.
  • Wait for the installation to finish.
  • Click the "Close" button.


After that, the sketch should compile.

If you have updatable library notifications enabled in the Arduino IDE, it will occasionally prompt you to update your Adafruit_GFX library to the new version. You will need to refrain from doing so, otherwise you'll be back to the same compilation error again when you use the Adafruit_TFTLCD library.

david_prentice

Yes,   you can revert to old library versions via the IDE Library Manager

Of course  we don't know which version, genuine or hacked,  or where you got  it from.
What does the Library Manager say?

Many displays use Adafruit_GFX.   So it would be painful to change version for other displays.
Much wiser to report what you have actually got.    Then  we can advise you better.

David.

czvikik

The 1.5.4 release of the Adafruit_GFX broke compatibility with the Adafruit_TFTLCD library. You'll need to roll back to Adafruit_GFX 1.5.3:
  • Sketch > Include Library > Manage Libraries
  • Wait for the download to finish
  • In the "Filter your search..." box, type "adafruit_gfx".
  • Press Enter.
  • From the search results, click on "Adafruit GFX Library by Adafruit".
  • From the dropdown version menu, select 1.5.3.
  • Click the "Install" button.
  • Wait for the installation to finish.
  • Click the "Close" button.


After that, the sketch should compile.

If you have updatable library notifications enabled in the Arduino IDE, it will occasionally prompt you to update your Adafruit_GFX library to the new version. You will need to refrain from doing so, otherwise you'll be back to the same compilation error again when you use the Adafruit_TFTLCD library.
Thaks! Now it can be compiled, but the display are not do anything.. it only light white...

david_prentice

I suggest that you Install/Upgrade MCUFRIEND_kbv and Adafruit_GFX via the IDE Library Manager.
If it does not work out of the box,   run  Diagnose_TFT_Controller example that comes with the library.
Also LCD_ID_readreg example.
Copy-Paste any messages printed on the Serial Terminal to your message.

When we know which controller is actually mounted on your display we can tell you whether the genuine Adafruit_TFTLCD supports it.

David.
You would get some practical advice.   i.e. to get a WORKING screen

Go Up