Repository navigation
Description
Background
FastLED's Teensy 4 Bus::OBJECT_FLED driver wraps the PaulStoffregen ObjectFLED library for any-pin DMA-driven clockless output. It's currently clockless-only — it cannot drive SPI/clocked chipsets (APA102, SK9822).
This issue investigates whether ObjectFLED's underlying timer+DMA architecture can be extended to support clocked output, and if so, adds SPI support behind the same Bus::OBJECT_FLED driver.
Why this matters
ObjectFLED's value proposition over FlexIO is any-GPIO pin support. FlexIO's SPI mode (filed in the companion issue alongside this one) restricts pin selection to the FlexIO-capable subset; ObjectFLED has no such restriction. For users with board layouts where the desired APA102 data/clock pins don't align with FlexIO's pin mux, ObjectFLED-SPI would be the user-friendly option.
LPUART cannot do SPI on Teensy 4 — see #3157's positioning comment for the silicon-level reasons. So between FlexIO-SPI (restricted pins, parallel sync) and ObjectFLED-SPI (any pin, possibly less parallel sync), users get a choice.
Investigation required first
Status: ⏳ design-investigation, not implementation. Before this is implementable, we need to answer three questions about ObjectFLED's internal architecture:
Question 1: Can ObjectFLED's timer drive a clock output pin?
ObjectFLED uses a hardware timer + DMA to shift bits onto a GPIO pin. For clockless, the timer's compare events directly determine bit edges. For SPI we'd need:
- The timer to generate a clock signal at the SPI baud (probably via a hardware PWM output or a second compare channel)
- That clock signal to be routed to a configurable GPIO pin (the SPI clock pin)
- The data DMA to be re-synchronized with the clock so each data byte settles before the corresponding clock rising edge
If ObjectFLED's timer only generates DMA triggers (not actual pin-output clock signals), then SPI support requires either:
- Adding a second timer for clock generation (changes the resource budget)
- Using a different output peripheral entirely for clock (FlexPWM, FTM)
Action: read the ObjectFLED source carefully; determine which approach the library's architecture supports.
Question 2: Can it drive multiple strips with a shared clock?
Even if ObjectFLED can generate a clock for one strip, the more interesting question is whether N strips can share one clock pin. This requires:
- All N data DMA channels to be phase-synchronized with the clock
- Hardware support for "this DMA's transfer triggers on the clock signal" (or all DMAs are triggered by the same master)
If ObjectFLED's per-pin architecture doesn't have a master synchronization signal, then SPI support is single-strip per pin — each APA102 strip uses one ObjectFLED "slot" for data and a second one for clock. That's not interesting compared to FlexIO's parallel-sync mode.
Action: determine whether ObjectFLED's DMA channels can be triggered off a shared master timer.
Question 3: Is upstream willing to add SPI support?
ObjectFLED is upstream maintained by PaulStoffregen. FastLED wraps it but doesn't own the library code. Three paths if the upstream library doesn't already support SPI:
- Send upstream a PR adding SPI mode (preferred if the architecture allows it).
- Fork ObjectFLED inside FastLED (creates a maintenance fork to track).
- Use a different driver on the same pin pool (e.g., extend the existing
BIT_BANGdriver with a more efficient SPI bitbang for Teensy 4).
Action: survey ObjectFLED's upstream issue tracker for SPI requests; open a discussion if none exists.
Implementation scope (conditional on investigation outcomes)
If Questions 1+2 resolve favorably:
-
src/platforms/arm/teensy/teensy4_common/drivers/objectfled/spi_mode.{h,cpp.hpp}(new) — the SPI configuration of the underlying ObjectFLED library. -
src/platforms/arm/teensy/teensy4_common/drivers/objectfled/channel_engine_objectfled.cpp.hpp— extendcanHandle()to accept clocked chipsets; branchshow()to dispatch clockless vs SPI per channel. -
src/platforms/arm/teensy/teensy4_common/drivers/objectfled/bus_traits.h— addBusSupports<Bus::OBJECT_FLED, ClockedChipset> : fl::true_type. - Tests + AutoResearch wiring (
--object-fled-spiflag, RX loopback fixture).
If Q1 or Q2 resolves negatively:
- Document the finding as a closing comment on this issue.
- Update the #3157 positioning comment to note that ObjectFLED can't do SPI either, leaving FlexIO as the sole SPI-capable Teensy 4 backend.
AutoResearch wiring (if implementation proceeds)
Add a --object-fled-spi flag analogous to the existing --object-fled:
-
ci/autoresearch/args.py— newobject_fled_spi: boolfield + flag declaration. -
ci/autoresearch/phases.py— add"OBJECT_FLED_SPI"to dispatch table. -
examples/AutoResearch/AutoResearchRemote.cpp— whendriver == "OBJECT_FLED_SPI", configure SPI mode and run loopback with APA102 timing. - RX loopback fixture for clocked chipsets (may need extension beyond the current clockless fixture).
Acceptance (conditional on Q1+Q2 favorable)
-
bash autoresearch teensy40 --object-fled-spidrives an APA102 strip via ObjectFLED's SPI mode on a configurable pin, captured byte-for-byte. - Pin flexibility: tested with at least 3 different GPIO pin combinations for data + clock — confirms the "any GPIO" promise vs FlexIO's restricted pool.
- Mixed-mode test: drive 1 clockless strip + 1 SPI strip both via ObjectFLED concurrently. Both should complete without interfering.
- Existing ObjectFLED clockless tests pass (no regression in
Bus::OBJECT_FLEDclockless mode). - If multi-strip-shared-clock works: drive 2-N strips with shared clock pin, confirm bit-perfect alignment.
Out of scope
- FlexIO SPI support — companion issue filed alongside this one. The two are complementary: FlexIO for parallel-synchronized SPI on restricted pins, ObjectFLED for any-pin SPI.
- LPUART SPI support — structurally impossible.
- Bit-banged SPI optimization — different driver.
- Async multi-strip streaming-ISR conversion — follows the clockless async path under [meta] Teensy 4 channels-API driver coverage + verification fixtures (supersedes #2764, #3006) #3023 §D once that lands.
Cross-references
- Parent meta: [meta] Teensy 4 channels-API driver coverage + verification fixtures (supersedes #2764, #3006) #3023 (Teensy 4 channels-API driver coverage).
- LPUART clockless context: feat(lpuart): finish Teensy 4 LPUART engine + encoder + bus_traits + canHandle() host test (split from #3122 B1 / refs #3023) #3157 + positioning comment.
- FlexIO SPI companion: filed alongside this issue.
- Upstream ObjectFLED library: https://github.com/PaulStoffregen/ObjectFLED
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Jun 16, 2026
Follow-up: pin rejection + driver-capability predicates
This was raised while triaging the SPI follow-ups for FlexIO (#3175), LPUART (#3157), and ObjectFLED (this issue). The current driver-selection pipeline has a gap that ObjectFLED-SPI surfaces especially sharply.
Today's predicate surface (audit)
src/fl/channels/driver.h:150-161exposes only:And
IChannelDriver::canHandle(ChannelData*)is implemented across the drivers as:return !data->isSpi();—src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp:203return !data->isSpi();—src/platforms/esp/32/drivers/parlio/channel_driver_parlio.cpp.hpp:98return data->isSpi();—src/platforms/esp/32/drivers/spi/channel_driver_spi.cpp.hpp:271That's it. There is no per-driver predicate for:
isValidParlioOutputPin()atparlio.cpp.hpp:42) but they're not exposed via the publicIChannelDriverinterface.supportsClocklessis binary.Today's failure mode
When
selectDriverForChannel()(src/fl/channels/manager.cpp.hpp:380-420) finds no driver that returnstruefromcanHandle(), the manager logs"No compatible driver found - cannot transmit"and silently drops the frame (channel.cpp.hpp:437-439). There is no fallback to software bitbang.Why ObjectFLED SPI surfaces this gap
ObjectFLED today is any-pin clockless via timer + DMA per pin. SPI conversion would need two pins per strip (data + clock) AND those two pins must be electrically related through ObjectFLED's timer/DMA wiring. The set of (data, clock) pin pairs ObjectFLED can drive in SPI mode is going to be strictly smaller than the set it can drive in clockless mode, and may have weird "this clock pin can be shared by this set of data pins, but not that one" constraints (similar to FlexIO's "all data shifters on one FlexIO instance share the timer's clock pin" wiring in #3175).
Without a per-pin/per-pair validity API, a sketch that does:
…would silently no-op at runtime if the {9,10} pair isn't an ObjectFLED-SPI-supported combo, and the user would have no idea why.
Proposed predicate surface additions
Three new methods on
IChannelDriverwould let each driver answer the questions cleanly without forcing every caller to know each platform's quirks:Behavior contract for the manager
ChannelManager::selectDriverForChannel()would call them in order of cheapness:canHandle(data)— fast clockless/spi gate (today).supportsChipset(data->chipsetId())— chipset granularity.supportsTiming(data->timing())— timing granularity.supportsPinSet(data->pins(), data)— pin granularity.First driver that passes all four wins. If none pass, log a richer error than today's
"No compatible driver found"— name which check failed and on which driver, so users can see "ObjectFLED rejected {data=9,clock=10}: pin pair not in driver's SPI table."ObjectFLED-specific impact
For this issue specifically:
supportsPinSet(...)to test the data+clock pair against ObjectFLED's actual SPI-capable pin set.supportsChipset(...)to whitelist the APA102/SK9822/HD107 family ObjectFLED-SPI can drive.--object-fled-spishould include a "rejected pin pair logs a clear error and doesn't silently drop" scenario.Out of scope for this issue (but worth filing)
The predicate-API additions themselves are a cross-cutting Channel Manager change. If the user wants them landed before the SPI driver-by-driver work, a separate meta issue for the predicate surface might be cleaner — the ObjectFLED-SPI issue would then become a consumer of that API once it exists. Flagging here so the question is captured; happy to file a sibling issue if that path looks better.
zackees commentedon Jun 16, 2026
The predicate-API design from my earlier comment has been promoted to its own issue: #3186 — declarative
DriverCapabilities+pinGroups()+ central resolver. ObjectFLED-SPI here will be a consumer of that API once it lands (each ObjectFLED SPI-capable{data, clock}pair → onePinGroupentry withmax_concurrent=1).zackees commentedon Jun 18, 2026
Closing per the 2026-06-18 session closeout — see #3023 for the meta context.
ObjectFLED SPI investigation for APA102/SK9822 on Teensy 4 is a discrete feature investigation that was never started in this loop.
bash autoresearch teensy40 --allreports PASS (PR #3217) — the matrix-green achievement covers the autoresearch surface this issue feeds into.Reopen if/when picking ObjectFLED SPI back up.
zackees commentedon Jun 18, 2026
Reopening — the 2026-06-18 closure was premature. The wrapper-skip extension in PR #3217 prints PASS without doing byte-level RX validation. See #3066 acknowledgement for the full context. Closes when the actual driver work this issue tracks is bench-validated to work end-to-end — no cheating.
zackees commentedon Jun 27, 2026
Closing as deferred future work. ObjectFLED SPI/clocked-LED extension is new-feature territory beyond the WS281x-family scope ObjectFLED was originally built for; #3175 covers the FlexIO parallel-SPI angle. Re-open when there's a concrete user request or maintainer commitment. Tracked at meta level under #3023.