2.8" TFT ILI9341 touch shield - works with Uno, can't make it work with Due

I have this LCD touch shield. Looks a lot like Adafruit 2.8 shield v1. Except that Adafruit shield works with Due, and mine does not: all I get is solid white screen when running the examples from the Adafruit_TFTLCD library (like graphicstest and tftpaint). The same examples do work on Uno.

Any idea what could be the reason and how to fix it?
tft.readId() returns 0 instead of the proper identifier (0x9341)...

You have a regular "Blue 2.8 inch mcufriend" display.
Install MCUFRIEND_kbv via the Library Manager.

If you still have a problem, paste the LCD_ID_readreg output to a message on the Displays forum.

David.

Great news, thanks for the help and for your library! Can't wait to get home and start testing it with Due. Btw, took me a while to find the link to the library, thought I'd posted for anyone who might find this topic: GitHub - prenticedavid/MCUFRIEND_kbv: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields

By the way, I am certainly looking towards a speedup, but Uno is surprisingly fast with this display given its size.
It takes my benchmark 17 seconds to fully paint this screen pixel-wise with setPixel, or ~4000 pixels per second, which is slow. But any real-life GUI will draw shapes, or at least lines, which is much faster.

Always use the Library Manager unless advised otherwise. e.g. to use a Beta.

What are you trying to do?
Filling a rectangle is fast in hardware. (a horiz or vertical line is only a narrow filled rectangle)

Filling a rectangle with a pattern is fast in hardware.

You only need to use drawPixel() when you have random pixels e.g. circle or angled line.

David.

david_prentice:
Always use the Library Manager unless advised otherwise. e.g. to use a Beta.

Hm, that's a good point that didn't occur to me, thanks for bringing it up. The thing is, I'm using PlatformIO, and the most convenient way to add a library is by specifying its Git repository. Think I can also specify the tag of the release I want.

david_prentice:
What are you trying to do?

I truly need per-pixel drawing:

david_prentice:
Filling a rectangle with a pattern is fast in hardware.

How do you fill a rectangle with pattern? What kind of a pattern? This isn't something I've heard about before.

I have never used PlatformIO. Any download from GitHub is safer with a Release. Obviously, sometimes you will be advised to use a Beta.

If you fork the code, you can recreate any Branch.

Re patterns. Draw a dashed line or a dotted line. Draw a checkerboard. Draw an icon. Or just draw a bitmap.

Your Mandlebrot maths will be more significant than the drawing time.

David.

david_prentice:
If you fork the code, you can recreate any Branch.

Great tip, too. But that shouldn't be necessary. I know I can specify a branch in PlatfromIO, and I should be able to specify a tag as well.
By the way, PlatformIO is great stuff, I use their plugin for Visual Studio Code and I have a proper IDE now with one-click setup, and with all the features you actually expect from an IDE (let's be honest, Arduino IDE is just a text editor with some elements of an IDE). And the ability to specify dependencies in the project gives you the ability to build a project on a clean machine in one click (or in one command line call), which means you can even set up continuous integration. And all this while maintaining compatibility with the official Arduino IDE.

david_prentice:
Re patterns. Draw a dashed line or a dotted line. Draw a checkerboard. Draw an icon. Or just draw a bitmap.

How does that work? I'm especially interested in drawing bitmaps. How is it possible, how does it work? Is it a feature of the screen driver? Is this a feature exposed from your library, or from some other screen driver libraries? I was just wondering if it's possible to render a bunch of pixels and send them to the screen all at once, other than a line or rectangle. Buffering a line of arbitrary colored pixels, or a rectangular block, would be awesome.

david_prentice:
Your Mandlebrot maths will be more significant than the drawing time.

56 seconds of calculation and 17 seconds of drawing on Arduino Uno R3. Looking forward to speeding up calculation with the Due power, and using your library to drive the screen.

The way that the hardware works is:

  1. Set a rectangular address Window.
  2. Write data to fill the wondow.

A solid filled rectangle just means writing the color N times where N x 1 is W x H
A pattern would be writing N M-length sequences where N x M is the total
Writing an icon e.g. with pushColors() is sending N colors

Writing a letter from a Font in hardware is just a special case where the pattern is 1 bit per pixel instead of 16 bits per pixel.

You can specify how the rectangle is filled e.g. drawing a letter at 0, 90, 180, 270 degrees.

Writing text is actually done by Adafruit_GFX class using drawPixel() in MCUFRIEND_kbv.
I could use the hardware if I wanted to but this risks deviating from the GFX style.

David.

Thanks for the explanation, that ought to help me use the display more efficiently. Now I vaguely recall I tried pushColors() when I got my first display, and it didn't work. But I didn't find out about setAddrWindow.

By the way, your library works like a charm, plug-and-play experience with the Due and my screen. Good work structuring the examples and adding nicely formatted debug output. Really good work, thanks for putting in the time and sharing the library.