TFT Display with Custom Fonts

Using GFXcanvas16 helps and makes it usable for my application.

I still can’t get the SPI clk to go over 8MHz though. Changing the setting in Adafruit_ST77xx.cpp does nothing.

#define SPI_DEFAULT_FREQ 24000000

I also tried changing _freq, freq and using initSPI(24000000)

What am I missing?

Are you using Workbench or web IDE? If workbench then you can do a thorough search of all the places it is declared and set. I think the issue may be that the default frequency is overwritten and hence it is forced back to be 8MHz. There are a lot of conditional compile statements.

GFXcanvas16 is a neat solution for quick updates but in any case with these TFTs you are writing to the screen memory.

Workbench

I have other changes in the library, had to flip the red and blue 565 colors, and that works.

I changed every _freq, freq, initSPI(freq) and hard coded the change as well, but it always outputs 8MHz. Can’t find where it is forced back to 8MHz.

It could be that the SPI speed setting function isn’t working?

Funny that you’re running into the SPI setting issue as well, I cannot for the life of me get the SPI clock to go faster than 8MHz either (and I’m working with the TFT). I changed the values in the library up AND down, and the clock speed stayed the same.

I am pretty certain that the SPI speed setting function is working because I tried changing the speed with the touch screen controller and it does work any faster than 1MHz - thus with a Adafruit 3.5" screen with touch the whole SPI bus has to be run at 1MHz hence why it is so slow. I need to get out the screen and try it without the touch display controller.

hm that’s a clue. I’m not using it with the touch controller right now and seeing the same behavior. Maybe the clock speed is changing but the effect is negligible? I didn’t see any way to read the actual SPI clock speed, how are you doing that?

The problem is with SPITFT.h/.cpp this implementation of a multi-device SPI interface by Adafruit as used by Adafruit_GFX. I believe that every SPI begin transmission has the SPISettings in it and there is no DMA which is definitely not what was in the previous iteration of Adafruit_mfGFX. This must however be something to do with the Particle implementation of SPI for the Gen3 devices because I have moved my Gen2 devices to use the Adafruit_GFX library and I am not seeing this throttling issue. @rickkas7 could you help give us the benefit of your knowledge here? Thanks

Yes, changing the manipulation of the CS and DC lines from digitalWrite to pinSetFast/pinResetFast should dramatically improve performance. Switching to SPI DMA would also help.

However, using the offscreen bitmap is a really good way to improve performance in general. The problem is that each pixel write is a separate SPI transaction when directly writing to the display.

Super fast response! I can change the SPITFTMacros.h file and try the pinSetFast/pinResetFast.
Do you happen to know if the SPI DMA implementation works - it is surrounded by warnings of being highly experimental!

I haven’t tried the SPI DMA. I didn’t try the pinSetFast/pinResetFast either, but I know someone who did and it made a big difference on Gen 3.

I have gone back to my test sketch to use pinSetFast and pinResetFast and I am now finding it impossible to get the following to build. There are all sorts of ARDUINO not defined issues, then SPISettings then…

The includes in my sketch look like this

#include <Adafruit_HX8357_RK.h>
#include <Adafruit_STMPE610_RK.h>
#include <SdFat.h>
#include "Adafruit_ImageReader.h"
#include "FreeMono18pt7b.h"
#include "FreeMono9pt7b.h"

There seem to have been some changes in these libraries, so I deleted and reinstalled:

dependencies.Adafruit_HX8357_RK=1.0.8
dependencies.Adafruit_STMPE610_RK=1.0.1
dependencies.SdFat=1.0.16
dependencies.Adafruit_ImageReader=1.0.9
dependencies.Adafruit_GFX_RK=1.5.6

The errors suggest there is some mismatch -

In file included from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_GFX_RK/src/Adafruit_SPITFT.h:26:0,
                 from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_HX8357_RK/src/Adafruit_HX8357.h:36,
                 from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_HX8357_RK/src/Adafruit_HX8357_RK.h:4,
                 from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/src/zioxi_locker_ui.ino:8:
/Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_GFX_RK/src/Adafruit_GFX.h:6:0: warning: "ARDUINO" redefined
  #define ARDUINO 157
 ^
In file included from ./inc/SPI.h:1:0,
                 from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_GFX_RK/src/Adafruit_SPITFT.h:25,
                 from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_HX8357_RK/src/Adafruit_HX8357.h:36,
                 from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_HX8357_RK/src/Adafruit_HX8357_RK.h:4,
                 from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/src/zioxi_locker_ui.ino:8:
./inc/Arduino.h:16:0: note: this is the location of the previous definition
 #define ARDUINO 10800
 ^
/Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/src/zioxi_locker_ui.ino:73:62: error: use of deleted function 'Adafruit_HX8357::Adafruit_HX8357(const Adafruit_HX8357&)'
 Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC, TFT_RST);
                                                              ^
In file included from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_HX8357_RK/src/Adafruit_HX8357_RK.h:4:0,
                 from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/src/zioxi_locker_ui.ino:8:
/Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_HX8357_RK/src/Adafruit_HX8357.h:127:7: note: 'Adafruit_HX8357::Adafruit_HX8357(const Adafruit_HX8357&)' is implicitly deleted because the default definition would be ill-formed:
 class Adafruit_HX8357 : public Adafruit_SPITFT {
       ^
/Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_HX8357_RK/src/Adafruit_HX8357.h:127:7: error: use of deleted function 'Adafruit_SPITFT::Adafruit_SPITFT(const Adafruit_SPITFT&)'
In file included from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_HX8357_RK/src/Adafruit_HX8357.h:36:0,
                 from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_HX8357_RK/src/Adafruit_HX8357_RK.h:4,
                 from /Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/src/zioxi_locker_ui.ino:8:
/Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_GFX_RK/src/Adafruit_SPITFT.h:118:7: note: 'Adafruit_SPITFT::Adafruit_SPITFT(const Adafruit_SPITFT&)' is implicitly deleted because the default definition would be ill-formed:
 class Adafruit_SPITFT : public Adafruit_GFX {
       ^
/Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/lib/Adafruit_GFX_RK/src/Adafruit_SPITFT.h:404:9: error: union member 'Adafruit_SPITFT::<anonymous union>::hwspi' with non-trivial 'constexpr Adafruit_SPITFT::<anonymous union>::<anonymous struct>::<constructor>(const Adafruit_SPITFT::<anonymous union>::<anonymous struct>&)'
       } hwspi;                     ///< Hardware SPI values
         ^
/Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/src/zioxi_locker_ui.ino: In function 'void setup()':
/Users/wjsteen/Documents/Intelligent_Furniture_Project/VSC_Projects/zioxi_locker_ui/src/zioxi_locker_ui.ino:85:19: warning: unused variable 'stat' [-Wunused-variable]
   ImageReturnCode stat;       // Status from image-reading functions

ARDUINO issues I can fix but the use of deleted function I really can’t see the problem.

Try rewriting it this way

Adafruit_HX8357 tft(TFT_CS, TFT_DC, TFT_RST);

Thanks. I think the reason it worked before was that I compiled it with Device OS 1.4.4 - I just tried it again and I got a load of warnings but it works. I can fix the warnings. With OS 1.5.0-rc.2 a pile of odd errors.

I tried the pinSetFast / pinResetFast in SPITFTMacros.h and SPITFT.h and it didn’t seem to change anything. Still scratching my head.

Me too. The SPITFT.h/SPITFT.cpp are a real ‘rats nest’ IMHO. Could it be that the performance is so slow because of the abstraction that SPITFT introduces into the use of SPI for these devices?

Well, after trying every tip I could find here and elsewhere on the internet, I’ve given up on this. Clearly I’m going to have to dig deeper than I have time for right now, and a complete revamp of Adafruit GFX library isn’t really on my radar. For future reference for anyone interested, here are the benchmark results:

image

@aklein24 Thanks for sharing this - if I get some time I will have a go at a radical rewrite of the SPITFT and see if I can cure this issue with the HX8357!

1 Like

I fully support this effort :slight_smile:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.