FastLED 3.9.15
Loading...
Searching...
No Matches

◆ write()

template<typename... Spans>
WriteResult fl::Spi::write ( Spans &&... lanes)
inline

Write multiple lanes in parallel (variadic template)

Template Parameters
SpansVariadic template parameter pack (all must be convertible to fl::span<const uint8_t>)
Parameters
lanesLane data as spans (1-8 for hardware, up to 32 for software modes)
Returns
WriteResult with ok=true on success, or ok=false with error message
Note
Automatically waits for previous transmission, then starts new one asynchronously
Call wait() to block until transmission completes
Internally unpacks to FixedVector for atomic processing (no heap allocation)
Hardware modes (SPI_HW) support 1-8 lanes, software modes support up to 32 lanes
IMPORTANT: All lanes MUST have identical sizes. Operation fails if sizes differ.
Users must handle chipset-specific padding at application level before calling write()
// All lanes must have the same size!
fl::array<uint8_t, 100> lane1 = {...}; // Same size!
fl::array<uint8_t, 100> lane2 = {...}; // Same size!
fl::array<uint8_t, 100> lane3 = {...}; // Same size!
// Async usage (fire and forget)
auto result = spi.write(lane0, lane1, lane2, lane3);
if (!result.ok) {
FL_WARN("Write failed: " << result.error);
}
// ... do other work while transmission happens in background ...
// Sync usage (wait for completion)
spi.write(lane0, lane1, lane2, lane3);
spi.wait(); // Block until transmission completes
A fixed-size array implementation similar to std::array.
Definition array.h:27
#define FL_WARN(X)
Definition log.h:276
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

Definition at line 119 of file spi.h.

119 {
120 if (!device) {
121 return WriteResult("SPI device not initialized");
122 }
123 return device->write(fl::forward<Spans>(lanes)...);
124 }
fl::unique_ptr< spi::MultiLaneDevice > device
Definition spi.h:142
constexpr T && forward(typename remove_reference< T >::type &t) FL_NOEXCEPT
Definition s16x16x4.h:234

References device, and fl::fl::forward().

+ Here is the call graph for this function: