Removal of FastLED output support

Can I ask why support was removed for FastLED as direct means to control the matrix?

While I appreciate their are features that are only possible when using SmartLED directly and it’s not a massive job to migrate projects over (I have done a few), I’m sure I’m not the only one that does small scale tests on things like my 8x8 neopixel matrix before then testing out on my lager setups that needs extra PSUs etc. Being able to update a couple of constants and update the FastLED.addLeds call is really quick and easy vs the alternative.
I have tried writing some designs where I still use the CRGB array then copy over to the SmartLED buffer, but this is a bit clunky in the code, uses more memory and is slower.

Was this just low priority and so decision was taken to drop support and recommend migration or is there some fundamental reason why support was dropped.

While I’m certainly no C wizard, I would be willing to try and at least provide some assistance in getting this feature restored, but don’t want to waste time if it’s ultimately going to be a dead end. Might be better to focus on things like removing the need to wrap CHSV in CRGB to make the transition less painful

I’m confused. Are you trying to move your matrix code from FastLED to SmartMatrix? If so, look at SmarMatrix::GFX and you don’t have to rewrite any code to get it to work on top of SmartMatrix.

If you’re trying to run FastLED strips at the same time than SmartMatrix, that’s not a problem, they both work at the same time without issues.
Have a look at Marc's Blog: arduino - FastLED_SPITFT::GFX on top of Framebuffer::GFX for SPI TFTs like SSD1331 or ILI9341

Daniel did the integration for an early SmartMatrix Library version, and it broke when I changed the API for the next version. I didn’t want the integration to break every time I made a major rev to SmartMatrix Library, and I think there was a change in SmartMatrix Library that made the SmartMatrix Controller in FastLED seriously incompatible in a way I couldn’t fix at the time.

I made a low priority TODO to look at the integration and do a PR to either support it or remove it tied in with the upcoming SmartMatrix Library 4.0 release. Thanks for letting me know that it’s important to you.

Also thanks Marc for providing an alternate solution

1 Like

Hi Marc

Almost all my stuff is just “raw” FastLED using an XY function when on a matrix.

To swap between my small scale test matrix and larger is normally trivial as just different size and possibly different addLEDs call if the larger panel is APA102 say.

While rewriting to use SmartMartix directly isn’t hard, I can’t then easily flip between small and large.

I have achieved in a way for LEDSnakeGame/GameSnake at master · netmindz/LEDSnakeGame · GitHub but is ugly in copying from CRGB to the SmartMartrix buffer, though does give me the option of highDPI mapping given the pitch difference between my 30x30 apa102 and my P2.5 SmartMatrix is extreme

As I also share patterns between sketches, I wouldn’t want to “pollute” all of them to replace FastLED.show with a call to a right method for that platform.

If I’m understanding your proposal correctly it’s just to rewrite any code I want to run on a matrix to use your “generic” API then let the driver handel the details, which in effect the old FastLED support provided, but just at a per pixel rather than matrix based API

Thanks for the info.

One small change that would make migration easier be to remove the need to wrap CHSV with a CRGB

(Doesn’t help docs give example, that doesn’t work, then next paragraph says not to used that example, but shows the fix)

Also removing the need to cast would be nice

Can you point me to where the docs say that, so I can fix it if possible?

@netmindz I remember you from the FastLED group.
Ok, I know I’m pushing my stuff, but seriously, switch to
GitHub - marcmerlin/FastLED_NeoMatrix: Adafruit GFX compatible library for NeoPixel based Matrices using FastLED library :slight_smile:
It supports your XY function if it’s special, or will do the mapping for you otherwise.
You can have a look at
FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos/FastLED at a98cb3e965433a8eebb8893d630735fda12469cb · marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos · GitHub
for example code using XY and direct fastled poking without using GFX and drawpixel.

Once you’ve switched to that, you can substitute for GitHub - marcmerlin/SmartMatrix_GFX: SmartMatrix: Allow using Adafruit::GFX as well as FastLED_NeoMatrix code with SmartMatrix backend, and your same code will just work.

All the magic is in https://github.com/marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos/blob/a98cb3e965433a8eebb8893d630735fda12469cb/neomatrix_config.hhttps://github.com/marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos/blob/a98cb3e965433a8eebb8893d630735fda12469cb/neomatrix_config.h
it’s a big file, but it’s mostly ifdefs that select the right backend.

1 Like

Now buffer can be used like the leds array. For example:

      leds[XY(i,j)] = CHSV(noise[j][i],255,

I looked into the FastLED SmartMatrix controller, and it was written for back when SmartMatrix Library could only support a 32x32 panel (I think). When using the controller, the SmartMatrix configuration part of the sketch is encapsulated inside FastLED. Configuration is a lot more complicated now, so I’m not sure how to pass all the parameters into FastLED to be used by the controller, and it seems like a lot of work to figure it out.

Compare this:

// uncomment one line to select your MatrixHardware configuration - configuration header needs to be included before <SmartMatrix3.h>
//#include <MatrixHardware_Teensy3_ShieldV4.h>        // SmartLED Shield for Teensy 3 (V4)
//#include <MatrixHardware_Teensy4_ShieldV5.h>        // SmartLED Shield for Teensy 4 (V5)
//#include <MatrixHardware_Teensy3_ShieldV1toV3.h>    // SmartMatrix Shield for Teensy 3 V1-V3
//#include <MatrixHardware_Teensy4_ShieldV4Adapter.h> // Teensy 4 Adapter attached to SmartLED Shield for Teensy 3 (V4)
//#include <MatrixHardware_ESP32_V0.h>                // This file contains multiple ESP32 hardware configurations, edit the file to define GPIOPINOUT (or add #define GPIOPINOUT with a hardcoded number before this #include)
//#include "MatrixHardware_Custom.h"                  // Copy an existing MatrixHardware file to your Sketch directory, rename, customize, and you can include it like this
#include <SmartMatrix3.h>
#include <FastLED.h>

#define COLOR_DEPTH 24                  // This sketch and FastLED uses type `rgb24` directly, COLOR_DEPTH must be 24
const uint16_t kMatrixWidth = 32;        // known working: 32, 64, 96, 128, 256
const uint16_t kMatrixHeight = 32;       // known working: 16, 32, 48, 64, 128
const uint8_t kRefreshDepth = 36;       // known working: 24, 36, 48 (on Teensy 4.x: 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48)
const uint8_t kDmaBufferRows = 4;       // known working: 2-4, use 2 to save memory, more to keep from dropping frames and automatically lowering refresh rate
const uint8_t kPanelType = SMARTMATRIX_HUB75_32ROW_MOD16SCAN;   // use SMARTMATRIX_HUB75_16ROW_MOD8SCAN for common 16x32 panels
const uint32_t kMatrixOptions = (SMARTMATRIX_OPTIONS_NONE);      // see http://docs.pixelmatix.com/SmartMatrix for options
const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE);
const uint8_t kScrollingLayerOptions = (SM_SCROLLING_OPTIONS_NONE);

SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);
SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);

void setup() {
  // uncomment the following lines if you want to see FPS count information
  // Serial.println("resetting!");
  Serial.begin(115200);
  delay(3000);

  matrix.addLayer(&backgroundLayer); 
  matrix.addLayer(&scrollingLayer); 
  matrix.begin();
...

to this:

Sorry, but I’m not going to try to get the FastLED SmartMatrix controller working again.

Yeah, I totally appreciate that it’s a load of work to ultimately “dumb down” the far more sophisticated smartmatrix api to that of simple pixel type definition.

The saving grace here is that trying to swap easily between small scale tests with WS28xx and larger setups is often a necessity, whereas a single matrix panel is fine to use for small scale, you don’t need to switch to an 8x8 neopixel.

For anything trying to do on 4 tile matrix, I can test with single tile

I might still have a bash at trying to update if it’s just hard rather than impossible as would be nice to proto on a 32x32 smartmatrix panel. Then run on my 30x30 apa102 matrix

You may be able to modify the SmartMatrix FastLED controller so it just writes to the buffer and does a swap, and then keep the configuration and buffer allocation in your sketch where you can optionally comment it out when you want to drive your APA102 matrix. It doesn’t seem easy though.

I think you’re probably better off using Marc’s library.

Also, SmartMatrix Library 4.0 is really close to being ready for release, and it has an APA102 driver for Teensy 3 and Teensy 4. That’s not going to help you with a WS2812 project though.

https://github.com/pixelmatix/SmartMatrix/blob/teensy4/examples/FastLED_Panel_Plus_APA/FastLED_Panel_Plus_APA.ino

1 Like

I updated MIGRATION, thank you @netmindz

Thanks, that might work. Quite a bit of code there, so need to have a proper read and compare with my current work around. As for ws2812, I wouldn’t need that any more. Would be using the smartmatrix as the small scale test, then move to the larger, more fragile apa102 matrix

I’ll be honest that I never even looked at the FastLED support in the SmartMatrix library :slight_smile:
By the time you’re using FastLED and matrices, unless you go through the pain of laying them out by hand (been there, done that, it’s stupid in amount of time spent, use pre-made matrices and connect them), Neomatrix becomes needed, so it’s better to start there today.
And of course, you can still switch your code back to SmartMatrix without any rewrite, later if you use my compat layer.

Yeah I saw one of your examples is actually one of my designs. Would you mind popping a quick credit at the top of the example?

Oh my, I assume you mean
FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos/FastLED/Vortex at master · marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos · GitHub ?

If so, I copied your README.md, but now I see that it didn’t have anything (name, license, etc) except for a link to our google photos.
You can go in github, click on edit without having to fork, add anything appropriate and I’ll merge that right away.
Sorry for missing this.

Yeah it’s a bit a minimal readme! :rofl:

No offence taken or anything, was just looking at the examples and had a funny moment of being this looks a bit like something I wrote, then saw it even had the same issue of some somewhat random naming where one set of code had been mashed about to create something else and I’m like - yes this is totally based off my code :rofl:

@netmindz I don’t know if this helps you, but if you’re using a tiled APA102 matrix - it looks like you are at least using APA102s as that’s the default in your sketch - then you can now add a mapping to the APA102 controller. You’ll be able to easily switch between APA102s and HUB75 panels, and you get the gamma correction and APA102 GBC control built into SmartMatrix Library.

There’s no WS2812 support, or support to run on a non-Teensy platform so it’s not a perfect solution, but thought I’d let you know as this is new

1 Like

Thanks for the heads up @Louis

As I have a single matrix in serpentine then I think the existing support should be sufficient. I’ve not tried it yet as I’ve been working on audio responsive stuff with WLED but I will give the SmartMatrix APA support a try

That’s cool, I’ve been taking a look at the Soundreactive fork of WLED. I have an ESP32 board that receives APA102 input to drive HUB75 panels and once I have that ready to share I want to play with WLED a lot more.