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
SSD1331
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);
or
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):
7 months later, I was also able to make Framebuffer::GFX working on ESP32 after adding PSRAM support as the fragmented ESP32 memory didn't have the 224KB of required contiguous RAM. It was barely working on teensy 3.6 which didn't have this problem, but it was still very low on RAM to run anything while storing such a big framebuffer. The other issue is that it's slow to push a framebuffer of that size over SPI at 24Mhz, in real life I'm only seeing 5fps or so on ESP32 due to the delays of reading from PSRAM. With more optimizations, it could maybe reach 12fps or more (the actual TFT can do 25fps at 40Mhz and maybe 40fps if wiring allows for 80Mhz):
ILI9341 is slightly compatible with the ST7735 screens, shown for scale here
ESP32 Pro with PSRAM needed to store the ILI9341 framebuffer. Display not too compatible with ST7735
zoomed in ILI9341 is very nice resolution
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.