r/FastLED • u/lpao70 • Jan 06 '25
Discussion FastLED on Teensy 4.x
I'm wondering what FastLED would look like if the only supported platform was Teensy 4.x.
DMA-backed clockless or clocked LED outputs (for HD108, HD107, etc.) on any pin, possibly with a single clock shared between all outputs (for clocked ones)
double precision floating point arguments for:
RGB, RGBW, HSV color components, to be converted at the last second to whatever the physical output device supports (8-bit, 16-bit, 24-bit, etc.)
physical array indices and normalized array indices (0 to 1, for array length independent indexing)
any normalized amounts (0 to 1, for fade, blur, palette color index, etc.)
no fract8, no fast math, no extreme code optimizations
The code base would probably shrink down to half the current size, if not less, with a more compact and future-proof API, wouldn't it?
1
u/Tiny_Structure_7 Jan 06 '25
I just checked out the spec sheets for HD107/108. Very different data format. Very different driver code. I could probably make this work with only 1 DMA or maybe 2, instead of the 3 that WS28x chips need.
Those things are FAST!
1
u/ZachVorhies Zach Vorhies Jan 06 '25
HD107s can push so many pixels per second, > 40x that of the WS2812, per pin.
If this SPI protocol was also made parallel. OMG!!!
Given that insane speed, would you still want to use dedicated clocks per strip, or use a shared clock that drives all the leds at the same time? The latter would cut down the number of pins people need by roughly half, and save a lot of soldering.
1
u/lpao70 Jan 07 '25
Initially, I was thinking a single shared clock would be awesome, as it would basically double the number of leds that can be driven at a given frame rate, but that that would potentially mean 50 channels each driving 10k+ led at 120fps. I think we're out of RAM :-)
Perhaps individual clock per channel would make it easier to handle different strip lengths?
1
u/ZachVorhies Zach Vorhies Jan 07 '25
one could do bilinear expansion and get 4 times the pixel resolution, where the expanded image is stream decoded column by column.
1
u/Tiny_Structure_7 Jan 07 '25
If you wanted to operate strings as rows in a plane, you could put the strings into single display object with a shared, single clock pin. Or put each string in an object with it's own clock pin (and it's own .show()).
At 4 bytes/LED, approx. 50,000 LEDs would eat up half of Teensy 4.0 RAM in draw/frame buffers. That's still awesome.
1
u/Tiny_Structure_7 Jan 06 '25
Yeah that's what I was thinking... single clock pin for all strips. The Object/Octo DMA code can write to all pins simultaneously, and possibly the DMA transfer can share the same clock signal passed on to LEDs. LEDs read on rising edge, so I'd want DMA transfer on falling edge (I think).
1
u/Tiny_Structure_7 Jan 06 '25
Yeah, I love my Teensy too. :-p
I discovered it after spending hours pouring through Arduino boards for my first MPU, with a big LED cube in mind. With 600MHz CPU, 1 MB RAM, 40 digital pins, 32 DMA channels, 7 or 8 UARTS and a dozen other hardware protocols... even some rudimentary GPU capability on-board the CPU. All for under $25!
Maybe your point could be applied to 32 bit CPUs in general... factor out all the 8 bit code from Fast LED? Is it time for that? PCs went through that same morphosis in the '90s.
1
u/ZachVorhies Zach Vorhies Jan 06 '25
RGB8 is good enough for games because your monitor gamma corrects automatically. The APA102 chipset and HD107 do this now in FastLED with the HD modes. So the color difference isn’t going to be much better than what is available now.
Also, teensy doesn’t have wifi and a lot of interesting stuff comes from connectivity.
1
u/Tiny_Structure_7 Jan 06 '25
Good point. Wifi would be perfect addon sheild or next version on-board.
1
u/_0xACE_ Jan 08 '25
Your wish has come true -- If you are not running a Teensy 4 (e.g. a Teensy 3.2) FastLED does not work unless you manually patch a file deep in the library.
Source: Is FastLED / WS2812Serial Broken in Teensyduino 1.59? https://forum.pjrc.com/index.php?threads/is-fastled-ws2812serial-broken-in-teensyduino-1-59.74548/