Marc's Public Blog - Arduino Hacking

All | Aquariums | Arduino | Btrfs | Cars | Cats | Clubbing | Dining | Diving | Electronics | Exercising | Flying | Hiking | Linux | Linuxha | Monuments | Museums | Public | Rc | Sciencemuseums | Snow | Solar | Trips

>>> Back to post index <<<

2019/05/26 FastLED_SPITFT::GFX on top of Framebuffer::GFX for SPI TFTs like SSD1331 or ILI9341
π 2019-05-26 01:01 in Arduino
Show me the code! Sure:
  • (SSD1331 or ILI9341 on top of FastLED CRGB 2D Matrix)
  • Framebuffer::GFX

    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:

    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:

  • (SSD1331 and ILI9341 TFTs)
  • 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
  • For ST7735 and ILI9341, try this:
  • 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);
    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
    rotating 3D cube with temporal fade

    Table from Mark Estes Video Demo:

    Then, some demos showing 128x128 and 128x160 on multiple size screens (for physical size comparison):

    More pages: May 2019 April 2019 March 2019 January 2019 July 2018 May 2018 April 2018 January 2018 June 2017 April 2017 January 2017 February 2016 January 2015 September 2013 January 2012 December 2011 May 2011 January 2011

    >>> Back to post index <<<