Speeding up the ILI9488 SPI display (esp32)

Use this section to discuss your embedded Flowcode projects.
mnfisher
Valued Contributor
Posts: 955
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 508 times

Flowcode v10 Speeding up the ILI9488 SPI display (esp32)

Post by mnfisher »

The ILI9488 is a very nice display - decent size, and if you pick correctly capacitive touch.

Unfortunately the SPI interface and the 'high' resolution (320 * 480) and the SPI interface working in 24 bit mode (only) means that there is a lot of data to transfer. (Using the HSPI bus at 80MHz is obviously a good idea here)

I hit on a snag using the component - I got no clock signal on the SPI bus (on A23) looking at the data on a logic analyser - the SCLK pin did nothing (I've maybe damaged my esp32 board?)
After a fair bit of fiddling (!) starting with the component - I finally got the display to work by changing the clock pin - now I'm using A18 this is on the other side of the board so messes with my neat wiring :-(

By then - I'd rewritten some of the component to use a display buffer and transactions instead of individual bytes for the SPI. The display would use 153000 bytes for 256 colour - so I went for a 16 colour (4 bit) compromise. This limits me to an esp32 or other MCU with a decent chunk of RAM.
I rewrote Initialise (see above) and Plot (here called plot_copy) I added a Display macro - to output the data - and also a Display_Copy - this only outputs data if the line has been modified (so for displays with few changes is a lot quicker...)

I also added a SetColour - and a lookup table for the 16 colours.

After all the work - is it quicker? I did a couple of demos (here printing Hello World and drawing 10 random circles) and yes it is. The speed improvements depend on how much is displayed and how much is drawn before Display_copy is called. It is noticeably faster than the component (using the esp32 'fast' mode) It's never going to allow animation though :-( The parallel interface is much quicker and also allows different colour modes...

It still needs a bit of work - Plot_copy (needs changing to plot) maybe could take a colour index (0..15) rather than setting FG and BG colours. I use colour[0] as BG and 1 as FG here. Plot can also handle display rotations.

If anyone would like to play -
ILIComp.fcfx
(13.52 KiB) Downloaded 198 times
ILI9488_SPI.fcfx
(225.91 KiB) Downloaded 202 times

mnfisher
Valued Contributor
Posts: 955
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 508 times

Re: Speeding up the ILI9488 SPI display (esp32)

Post by mnfisher »

A little bit of modification - now supports orientation where 0 is 'normal' and then 1..3 are rotations of 90, 180 and 270 degrees.

And some tidying - Display_copy is now Display, Plot_copy is now Plot (and takes a colour index value)

Here it does a 'count' on 5 rows in orientation '3'
ILI9488_SPI.fcfx
(196.85 KiB) Downloaded 188 times

Martin

mnfisher
Valued Contributor
Posts: 955
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 508 times

Re: Speeding up the ILI9488 SPI display (esp32)

Post by mnfisher »

Got a 'rotating cube' demo working - needed to modify Clear to only mark a line as modified if it wasn't empty before. Changing the background colour also needs to mark everything as needing a refresh (although not doing so allows you to see which areas of the screen are being redrawn)

I also tried to get the touch sensor to work - with no joy at all. Has anyone any experience with this display (https://uk-m.banggood.com/search/ili948 ... splay.html - I have the capacitive touch version) . I tried the Gtp911 component (it 'should' be the i2c interface) - but nothing (the interrupt pin is pulled low on a touch)
I also tested with external pull ups- I couldn't find much info on the board :-( Have emailled banggood for further info.

Tried the i2c scanner - but no device is reported either.

Managed to crack the display (oops) which maybe doesn't help....

Martin

medelec35
Matrix Staff
Posts: 1451
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: Speeding up the ILI9488 SPI display (esp32)

Post by medelec35 »

Hi Martin.
I have attached a basic IlI9488 display demo with touch that works on hardware and simulation mode.
I would recommend using that first to conform the touch is working.
Attachments
CapTouchTFTDisplayDemo v1.fcfx
(19.06 KiB) Downloaded 184 times
Martin

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: Speeding up the ILI9488 SPI display (esp32)

Post by BenR »

Hello,

I've been playing with a 16-bit parallel version using the esp32 s3 and annoyingly it's not much faster then the spi version as the hus is bit banged out. I'm having another go at spinning my own board with the data bus in order so I can write the full bus in fewer commands. Fingers crossed this gets me somewhere.

I've also tried the 911 touch interface with mo joy thought it was my hardware but maybe not if you're also struggling.

mnfisher
Valued Contributor
Posts: 955
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 508 times

Re: Speeding up the ILI9488 SPI display (esp32)

Post by mnfisher »

Thanks Ben,

I tried the FT6X06 component as well - no joy.
I also tried using the HSPI channel - things worked at upto 60MHz after which the the display was 'alive' but jumbled. This might be the result of some interference in my 'breadboard' wiring?
To do the cube - the DrawLine of the component didn't work - so added my own, here called DrawLine2.

It does 2 rotating cubes - once in rotation 0 and once with rotation 3 - the background colour is changed for each draw (in cubedemo - by writing to the colour table) so the background is changed in areas that are redrawn. SetColour - marks the display as modified if the index is 0.
ILI9488_SPI_Cube.fcfx
(237.66 KiB) Downloaded 210 times
Manages a reasonable framerate :-) - look forward to seeing what the parallel interface can do....

Martin

mnfisher
Valued Contributor
Posts: 955
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 508 times

Re: Speeding up the ILI9488 SPI display (esp32)

Post by mnfisher »

Solved the mystery of the touch - took a look with a magnifier and the touch chip is actually a xpt2046. This is for resistive touch and SPI interface. Wiring up to the SPI interface does indeed give touch readings.
Another email to banggood - this wasn't what was ordered :-(

Martin

mnfisher
Valued Contributor
Posts: 955
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 508 times

Re: Speeding up the ILI9488 SPI display (esp32)

Post by mnfisher »

Also - after only redrawing whole rows that were modified - I thought I could also do this for 'blocks' rather than full rows.

So - using a 2 x 480 byte tables of the maximum and minimum altered pixels in a row (each byte is 2 pixels - so I just save byte position to economise on RAM) - it now just redraws modified 'blocks'. (Note it would be possible to do this using a table of bits like the modified table - but looking through would be slower?)

Performance - if I say so myself - is pretty good. It takes about 28ms to redraw the two cubes in either orientation.

There a few changes - ClearDisplay now takes a bool 'force' - to force a redraw of the entire display.
CubeDemo - now also takes a bool - to show redraw areas if set.

I've also added a copy bitmap - tested with a 1 bit bitmap so far (see supplementary code - include 'dat' files) - it's disabled here though.

The display redraw toggles pin 4 (high while drawing) to allow timing.

It ends by outputting touch data to the screen - my display has an xpt2046 (see above) :-(

Could probably do with a good tidy now - and simulation will no longer work.
ILI9488_SPI_MinMax.fcfx
(253.77 KiB) Downloaded 189 times
Martin

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: Speeding up the ILI9488 SPI display (esp32)

Post by BenR »

Hi Martin,

Your modifications sound very interesting, I'll have a look at your code and see how you've got such a speed boost.

I've managed to get my ESP32-S3 16-bit version of the ILI9488 display up and running now and I've put some modifications into the component to allow it to write to the display using only a couple of commands by bypassing the IO functions (Flowcode and IDF) and allow the data to be clocked out in a couple of direct register writes. You can find them here if you're interested, it's the Enhanced ESP32-S3 version. Currently on with creating the examples and other documentation.

https://www.ebay.co.uk/itm/285173803237

mnfisher
Valued Contributor
Posts: 955
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 508 times

Re: Speeding up the ILI9488 SPI display (esp32)

Post by mnfisher »

Thanks Ben,

Three macros do the hard work - plot and clear Display which mark a row as modified and also update a minimum and maximum for column. Display (or Display_Copy?) Looks for modified rows and then finds the bounding rectangle of the area needing redrawing.
The cost is RAM use and reduction in colours available (though I skip slightly by drawing bitmaps of 8 or more bits depth direct to the display)
I've hit snags - touch doesn't seem to work well and I can't get any response at all from the SD card 😞

All the data output is localised so hopefully easy to merge the two approaches - so looking forward to seeing your code!!

Martin

Post Reply