read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
#ADAFRUIT_ST7789 LIBRARY
#ARDUINO
#CODING
#ESP32-S3
#HARDWARE SPI
#SOFTWARE SPI
#SPI
#TROUBLESHOOTING
A few people commented on my Arduino Nano ESP32 video around the speed of the display updates. A kind commenter pointed out the issue - the default constructor of the Adafruit_ST7789 library uses software SPI when you use custom pins.
With the ESP32-S3 we can use any pins for hardware SPI - but the library assumes that it needs to use software SPI which makes things really slow.
The fix is to use the hardware SPI constructor of the library. This doesn’t seem to be documented particularly well - at least I can’t find any good references. But for future me, here’s the code:
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h> // Arduino SPI library
// ST7789 TFT module connections
#define TFT_CS 10
#define TFT_DC 9
#define TFT_SCLK 13
#define TFT_MOSI 11
#define TFT_RST 8
Adafruit_ST7789 *_tft = NULL;
void setup(void) {
Serial.begin(115200);
Serial.print(F("Hello! ST77xx TFT Test"));
SPIClass *spi = new SPIClass(HSPI);
spi->begin(TFT_SCLK, -1, TFT_MOSI, TFT_CS);
tft = new Adafruit_ST7789(spi, TFT_CS, TFT_DC, TFT_RST);
// 80MHz should work, but you may need lower speeds
_tft->setSPISpeed(80000000);
// this will vary depending on your display
_tft->init(240, 280, SPI_MODE0);
Have a look at the video to see the difference in action - it’s pretty mind blowing!
#ADAFRUIT_ST7789 LIBRARY
#ARDUINO
#CODING
#ESP32-S3
#HARDWARE SPI
#SOFTWARE SPI
#SPI
#TROUBLESHOOTING
Related Posts
Related Videos
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter