After writing my 3rd backend glue driver (SSD1331 SPI TFTs) that supports Adafruit::GFX, FastLED CRGB's primitives (nblend, dim, etc...) and matrix mapping via XY() function, and LEDMatrix which is another GFX like API on top of FastLED, I realized that I had to factor that out into a new base class I called Framebuffer::GFX: https://github.com/marcmerlin/Framebuffer_GFX
That new base class takes all the GFX glue and color support I mixed (GFX RGB565, FastLED CRGB structs (RGB888 24bit), and uint32_t backed 24bit RGB888 colors, and creates a virtual framebuffer compatible with FastLED and SmartMatrix (which thankfully can use the same 3 byte per pixel array type).
Framebuffer::GFX in itself is only a framebuffer storage and method holder, but it contains so much common code that my 3 drivers that use it are only a few dozen lines of code after inheriting from it.
Here is the list of drivers I've written against Framebuffer::GFX:
Here is an example of code ultimately running on top of Framebuffer::GFX with FastLED::NeoMatrix on ESP8266 (24x32 and 32x32) and SmartMatrix::GFX on ESP32 (64x96):
Below is the same code again now running on top of FastLED_SPITFT::GFX on an SSD1331 96x64 TFT screen:
FastLED_SPITFT_GFX, the last driver I wrote, takes any Adafruit SPI TFT object (like SSD1331 and ILI9341), and a FastLED CRGB array. You then tell it the size of each (it's up to you not to make mistakes or you can create buffer overruns), and the overloaded show() method will send the framebuffer to the TFT (it is done line by line with an SPI copy method):
FastLED_SPITFT_GFX(fb, 96, 64, 96, 64, ssd1331, 0) for unrotated
FastLED_SPITFT_GFX(fb, 64, 96, 96, 64, ssd1331, 1) for a 90 degree rotation
Here is the end result, an ESP8266 running LEDMatrix code rendered in Framebuffer_GFX, downsampled from 24bit color to 16bit color, rotated and copied line by line to a SSD1331
Here is a video of Jason Coon's Aurora in 64x96 rotated to the SSD1331 96x64 resolution:
It's ironic that normally Neopixel matrices look like they have huge pixels compared to RGBPanes, but here my 64x96 RGBPanel looks huge compared to the same resolution on SSD1331:
rotating 3D cube with temporal fade
Table from Mark Estes Video Demo:
ST7735 or ILI9341
Thankfully Adafruit wrote other TFT drivers like ST7735 and ILI9341 against the same Adafruit_SPITFT object from Adafruit-GFX, so I was able to target that tft object in FastLED_SPITFT::GFX and get the same code to work with other TFTs without any modifications.
As a result, all you need to do is to pass the different tft object, display size, and everything else works.
Adafruit_ILI9341 *tft = new Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
Adafruit_ST7735 *tft = new Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
FastLED_SPITFT_GFX *matrix = new FastLED_SPITFT_GFX(matrixleds, mw, mh, mw, mh, tft, 0);
For comparison, SSD1331 vs ST7735 128x128, ST7735 128x160 from 2 different vendors and slightly different chips, and ILI9341 with a full 320x240 which stretches the limit of this library since it requires 225KB for that many pixels and that only fits on a teensy 3.5/3.6:
the SSD1331 screen is off as it's not compatible and requires different code to turn on
ST7735R vs ST7735S chip revisions show a few differences
brightness is also different
code for the 128x128 ST7735 doesn't mis-display the same on the two 128x160 displays
Some demos showing 128x128 and 128x160 on multiple size screens (for physical size comparison):
Hopefully this is useful to you and by using the FastLED_SPITFT::GFX API, you can re-use your code on TFTs, FastLED::NeoMatrix and SmartMatrix::GFX.