FastLED 3.10.8
Loading...
Searching...
No Matches
parallel_device.h
Go to the documentation of this file.
1#pragma once
2
5
6#include "fl/stl/stdint.h"
7#include "fl/stl/vector.h"
8#include "fl/stl/unique_ptr.h"
9#include "fl/stl/optional.h"
10#include "fl/task/promise.h" // for fl::task::Error
12// IWYU pragma: begin_keep
13#include "platforms/shared/spi_types.h" // ok platform headers
14#include "fl/stl/noexcept.h"
15// IWYU pragma: end_keep // ok platform headers
16
17// Forward declarations for backends
18namespace fl {
19 class SpiIsr1;
20 class SpiIsr2;
21 class SpiIsr4;
22 class SpiIsr8;
23 class SpiIsr16;
24 class SpiIsr32;
25 class SpiBlock1;
26 class SpiBlock2;
27 class SpiBlock4;
28 class SpiBlock8;
29 class SpiBlock16;
30 class SpiBlock32;
31}
32
33namespace fl {
34namespace spi {
35
36// ============================================================================
37// ParallelDevice - 1-32 GPIO pins (single stream → LUT → parallel output)
38// ============================================================================
39
66public:
68 struct Config {
73
74 Config() FL_NO_EXCEPT; // Implemented in .cpp to avoid circular dependency
75 };
76
79 explicit ParallelDevice(const Config& config) FL_NO_EXCEPT;
80
83
84 // Disable copy/move
86 ParallelDevice& operator=(const ParallelDevice&) FL_NO_EXCEPT = delete;
89
90 // ========== Initialization ==========
91
96
98 void end() FL_NO_EXCEPT;
99
102 bool isReady() const FL_NO_EXCEPT;
103
104 // ========== Transmission ==========
105
111 Result<Transaction> write(const u8* data, size_t size) FL_NO_EXCEPT;
112
116 // Use (max)() to prevent macro expansion by Arduino.h's max macro
117 bool waitComplete(u32 timeout_ms = (fl::numeric_limits<u32>::max)()) FL_NO_EXCEPT;
118
121 bool isBusy() const FL_NO_EXCEPT;
122
123 // ========== Configuration ==========
124
130 void configureLUT(const u32* set_masks, const u32* clear_masks) FL_NO_EXCEPT;
131
134 const Config& getConfig() const FL_NO_EXCEPT;
135
136private:
137 struct Impl;
139};
140
141} // namespace spi
142} // namespace fl
bool isBusy() const FL_NO_EXCEPT
Check if transmission is in progress.
void configureLUT(const u32 *set_masks, const u32 *clear_masks) FL_NO_EXCEPT
Configure custom LUT (advanced)
bool isReady() const FL_NO_EXCEPT
Check if device is initialized.
void end() FL_NO_EXCEPT
Shutdown hardware and release resources.
fl::optional< fl::task::Error > begin() FL_NO_EXCEPT
Initialize hardware and setup LUT.
Result< Transaction > write(const u8 *data, size_t size) FL_NO_EXCEPT
Write data (single stream drives all pins via LUT)
const Config & getConfig() const FL_NO_EXCEPT
Get current configuration.
ParallelDevice(const Config &config) FL_NO_EXCEPT
Construct parallel device.
bool waitComplete(u32 timeout_ms=(fl::numeric_limits< u32 >::max)()) FL_NO_EXCEPT
Wait for pending transmission to complete.
fl::unique_ptr< Impl > pImpl
Handle for asynchronous SPI operations.
Definition transaction.h:38
fl::result< T, SPIError > Result
Definition transaction.h:29
unsigned char u8
Definition stdint.h:131
constexpr common_type_t< T, U > max(T a, U b) FL_NO_EXCEPT
Definition math.h:75
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
Optional< T > optional
Definition optional.h:16
SpiParallelMode
Parallel device execution modes.
Definition config.h:33
Base definition for an LED controller.
Promise-based fluent API for FastLED - standalone async primitives.
u32 timer_hz
Timer frequency for ISR mode.
fl::vector< u8 > gpio_pins
GPIO pins (1-32 pins)
SpiParallelMode mode
Execution mode (ISR vs bit-bang)
Configuration for parallel GPIO SPI.
Transaction class for asynchronous SPI operations.