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.
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 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…
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.
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.
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:
@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!