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

◆ write()

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

Convenience method - 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 (can be 1-8 lanes)
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
IMPORTANT: All lanes MUST have identical sizes. Operation fails if sizes differ.
Users must handle chipset-specific padding at application level before calling write()
fl::array<uint8_t, 16> lane0 = {...};
fl::array<uint8_t, 16> lane1 = {...}; // Same size as lane0!
fl::array<uint8_t, 16> lane2 = {...}; // Same size as lane0!
fl::array<uint8_t, 16> lane3 = {...}; // Same size as lane0!
// Async usage - transmission happens in background
auto result = spi->write(lane0, lane1, lane2, lane3);
if (!result.ok) {
FL_WARN("Write failed: " << result.error);
}
// ... do other work ...
// Sync usage - wait for completion
spi->write(lane0, lane1, lane2, lane3);
spi->wait(); // Block until done
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 169 of file multi_lane_device.h.

169 {
170 // Unpack variadic template into stack-allocated FixedVector
171 fl::span<const u8> lane_spans[] = {fl::forward<Spans>(lanes)...};
172 fl::FixedVector<fl::span<const u8>, MAX_SPI_LANES> lane_vec;
173
174 // Copy spans into vector
175 for (size_t i = 0; i < sizeof...(lanes); i++) {
176 lane_vec.push_back(lane_spans[i]);
177 }
178
179 // Single atomic write operation
180 return writeImpl(lane_vec);
181 }
void push_back(const T &value) FL_NOEXCEPT
Definition vector.h:191
WriteResult writeImpl(fl::span< const fl::span< const u8 > > lane_data)
Internal implementation - write all lanes atomically.
constexpr T && forward(typename remove_reference< T >::type &t) FL_NOEXCEPT
Definition s16x16x4.h:234
constexpr size_t MAX_SPI_LANES
Maximum number of SPI lanes supported (hardware: 1-8, software: up to 32)
Definition config.h:18

References fl::fl::forward(), fl::MAX_SPI_LANES, fl::FixedVector< T, N >::push_back(), and writeImpl().

+ Here is the call graph for this function: