Any TFT SPI library that is usable with ESP8266, e.g. Wemos D1 R2 ?

I would like to use TFTs with my ESP6266 "Arduinos", e.g. Wemos D1 R2, Wemos D1 mini, NodeMCU. The only SPI TFT that has arrived yet is a LinkSprite 2.8 Seedstudio compatible. But the libraries I currently use for Arduino Due do not compile for ESP8266.

Any help or link to useful information is highly welcome. Thank you.

David will tell me to use Google! :)

I found a link to GitHub and will try this:

https://github.com/Sermus/ESP8266_Adafruit_ILI9341

Unfortunately this is not an Arduino library, therefore the question is still open.

Maybe I will try to port this later.

Have you tried https://github.com/adafruit/Adafruit_ILI9341?

Found Adafruit_ILI9341, compiles for ESP8266, seems to run, but white screen so far.

https://github.com/adafruit/Adafruit_ILI9341

I tried with the following constructor:

//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 6, /*cs=*/ 5, /*reset=*/ 0);
Adafruit_ILI9341 tft = Adafruit_ILI9341(D5, 0);

The "cd=6" for Ucglib is unclear to me, because the tft does not connect to A6 on MEGA and Due. Maybe not important, as long as only output needed, no touch input.

The debug output I get is:

ILI9341 Test!
Display Power Mode: 0xFF
MADCTL Mode: 0xFF
Pixel Format: 0xFF
Image Format: 0xFF
Self Diagnostic: 0xFF
Benchmark                Time (microseconds)
Screen fill              2247427
Text                     162348
Lines                    1617535
Horiz/Vert Lines         184080
Rectangles (outline)     119162
Rectangles (filled)      4646975
Circles (filled)         765539
Circles (outline)        705677
Triangles (outline)      512371
Triangles (filled)       1570837
Rounded rects (outline)  293590
Rounded rects (filled)   5105912
Done!

Going to look at details, maybe SPI speed needs to be reduced.

Needs some wiring. This shield can’t be used directly on Wemos D1, because two pins are duplicated to the Arduino connectors: D5 is SCK and digital 5, D6 is MISO and digital 6.

Same reason as why parallel connection TFTs can’t be used, ESP8266 has not enough free IO pins.

MarekB: Have you tried https://github.com/adafruit/Adafruit_ILI9341?

Thank you very much for your answer! I had just found it myself and tried it. Will try it again with modified wiring.

I like the ILI9341_due on my Arduino Due for its excellent speed!

It would be welcome if we could get a ILI9341_esp8266.

Thank you very much.

Jean-Marc

MarekB: Have you tried https://github.com/adafruit/Adafruit_ILI9341?

Can it work with this TFT? http://www.lelong.com.my/2-8-inch-tft-lcd-display-touch-screen-module-sd-slot-arduino-ubitronix-X484832-2007-01-Sale-I.htm

@tommie93,

Your link shows a regular Blue 2.8" Mcufriend Shield. It has an 8-bit parallel interface. It should work with MCUFRIEND_kbv library. Obviously it has too many pins for the Wemos D1. If it contains an ILI9341, there are several other libraries that will work.

@ZinggJM,

There are several ILI9341 libraries that work with SPI interface. e.g. ILI9341_due, Adafruit_ILI9341, ... The Wemos has got 3.3V logic. 5V Arduinos must have level shifters. i.e. 5V to 3.3V Note that they all have constructors that accept a RESET pin. I suggest that you wire up the Reset pin to GPIO and use it.

David.

david_prentice: @tommie93,

Your link shows a regular Blue 2.8" Mcufriend Shield. It has an 8-bit parallel interface. It should work with MCUFRIEND_kbv library. Obviously it has too many pins for the Wemos D1. If it contains an ILI9341, there are several other libraries that will work.

Hi David, I tried one of the examples from the link, which is grahicstest_featherwing.ino The .ino file cannot be compiled, giving this statement instead: 'TFT_CS' was not declared in this scope

I reviewed the code and found that TFT_CS is already declared There's something that I missed?

ZinggJM:
Needs some wiring. This shield can’t be used directly on Wemos D1, because two pins are duplicated to the Arduino connectors: D5 is SCK and digital 5, D6 is MISO and digital 6.

Same reason as why parallel connection TFTs can’t be used, ESP8266 has not enough free IO pins.

… and then there is the ISCP connector missing on Wemos D1.

The pins to use for cs and dc on Wemos D1 are D3 and D4.

// This example uses the either the Bodmer's library here with a ST7735 based TFT display:
// https://github.com/Bodmer/TFT_ST7735
// (don't forget to edit the User_Setup.h file inside that library to define pins etc)

// OR you can use the standard Adafruit_GFX library, see line 15 below
// When using the Adafruit_GFX library update line 61 to suit your display and lines
// 32-34 to define the pins used. Use of hardware SPI lines is assumed.

// Other TFT_xxxxx libraries that could be used can be found here:
// https://github.com/Bodmer?tab=repositories
//

// changed for Wemos D1, configuration part from Bodmers source removed

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

//Adafruit_ILI9341(int8_t _CS, int8_t _DC, int8_t _RST = -1);
//Adafruit_ILI9341 tft = Adafruit_ILI9341(5, 6); // on UNO
Adafruit_ILI9341 tft = Adafruit_ILI9341(D3, D4); // on Wemos D1

int x[6][3];
int y[6][3];

//====================================================================================
// Setup
//====================================================================================

void setup()
{
  Serial.begin(115200);
  tft.begin();
  tft.setRotation(0); // portrait
}

//====================================================================================
// Loop
//====================================================================================

void loop()
{

  tft.fillScreen(ILI9341_BLACK);

  int w = tft.width();
  int h = tft.height();

  for (int n = 2; n < 8; n++) {
    int layer = n - 2;
    x[layer][0] = w / 2;
    y[layer][0] = n * h / 8 - h / 6;
    x[layer][1] = w / 2 - n * w / 16;
    y[layer][1] = n * h / 8;
    x[layer][2] = w / 2 + (n * w / 16);
    y[layer][2] = n * h / 8;
  }

  tft.fillRect(w / 2 - w / 20, h - h / 6, w / 10, h / 6, ILI9341_DARKGREY);

  for (int layer = 0; layer < 6; layer++) {
    tft.fillTriangle(x[layer][0], y[layer][0], x[layer][1], y[layer][1], x[layer][2], y[layer][2], ILI9341_DARKGREEN);
  }

  while (1) {
    for (int layer = 0; layer < 6; layer++) {
      for (int corner = 0; corner < 3; corner++) {
        tft.fillCircle(x[layer][corner], y[layer][corner], w / 40, rainbow(random(128)));
        delay(10);
      }
    }
    tft.fillCircle(x[5][0], y[5][1], w / 40, rainbow(random(128))); // Last light
  }
}

//====================================================================================
// Produce a rainbow colour
//====================================================================================

unsigned int rainbow(int value)
{
  // Value is expected to be in range 0-127
  // The value is converted to a spectrum colour from 0 = blue through to red = 127

  byte red = 0; // Red is the top 5 bits of a 16 bit colour value
  byte green = 0;// Green is the middle 6 bits
  byte blue = 0; // Blue is the bottom 5 bits

  byte quadrant = value / 32;

  if (quadrant == 0) {
    blue = 31;
    green = 2 * (value % 32);
    red = 0;
  }
  if (quadrant == 1) {
    blue = 31 - (value % 32);
    green = 63;
    red = 0;
  }
  if (quadrant == 2) {
    blue = 0;
    green = 63;
    red = value % 32;
  }
  if (quadrant == 3) {
    blue = 0;
    green = 63 - 2 * (value % 32);
    red = 31;
  }
  return (red << 11) + (green << 5) + blue;
}

@ZinggJM,

Look at the schematic for your display. If it has a hard-wired pullup resistor on the Reset line, you can use the shortform constructor i.e. omit the Reset pin.

Many displays do NOT have a pullup on the Reset pin. So you MUST connect Reset to a GPIO pin and specify it in the constructor.

Adafruit examples all seem to omit the Reset pin. This may be fine for Adafruit displays. It certainly causes problems with most Chinese displays.

i.e. you should always put the Reset pin under program control. (by using the full constructor)

David.

Thank you, David, for pointing to this issue, it may be important for the TFTs I should receive soon. The LinkSprite TFT has a reset button switch, that also resets the Arduino; so I may safely assume it is connected to the reset pin on the ISCP connector, and also resets the display. I'm going to look for the schematics from LinkSprite, they have good documentation on their wiki pages.

Jean-Marc

https://s3.amazonaws.com/linksprite/Shields/touch_LCD_shield/TFT+Touch.pdf

This was really a good suggestion, to look at the schematics. There are open solder bridges for the SPI connection for the Arduino header, so there is no need to use the ISCP connector, just need to close the bridges!

The hacked version of the Adafruit_ILI9341 library here is much faster on a ESP8266. I use it with a NodeMCU board.

bodmer:
The hacked version of the Adafruit_ILI9341 library here is much faster on a ESP8266. I use it with a NodeMCU board.

Thank you very much. I tried it with my Buffered_GFX template class.

Thank you! I could not run my tft screen, now I know why.