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

◆ executeToggles()

void executeToggles ( fl::RxChannel & rx,
fl::span< const PinToggle > toggles,
int pin_tx,
uint32_t wait_ms )

Execute pin toggles and initialize RX channel for capture.

Reads the current config from the RX channel, sets the TX pin to the initial state, begins capture, and executes the sequence of pin toggles.

Parameters
rxRX channel to initialize and use for capture
togglesSequence of pin state changes to execute
pin_txTX pin number to toggle
wait_msUnused parameter (kept for API compatibility)
Examples
RX.ino.

Definition at line 36 of file test.cpp.

39 {
40 const fl::RxChannelConfig& config = rx.config();
41
42 // Set pin to initial state before begin()
43 pinMode(pin_tx, OUTPUT);
44 digitalWrite(pin_tx, config.start_low ? LOW : HIGH);
45 fl::delayMicroseconds(100); // Allow pin to settle
46
47 // Initialize RX channel
48 if (!rx.begin(config)) {
49 FL_ERROR("Failed to initialize RX channel");
50 return;
51 }
52
53 // Execute pin toggles
54 for (size_t i = 0; i < toggles.size(); i++) {
55 digitalWrite(pin_tx, toggles[i].is_high ? HIGH : LOW);
56 fl::delayMicroseconds(toggles[i].delay_us);
57 }
58}
bool begin(const RxChannelConfig &config) FL_NOEXCEPT
const RxChannelConfig & config() const FL_NOEXCEPT
Definition channel.h:37
constexpr fl::size size() const FL_NOEXCEPT
Definition span.h:458
#define FL_ERROR(X)
Definition log.h:219
void pinMode(int pin, PinMode mode)
Set pin mode (input, output, pull-up, pull-down)
Definition pin.cpp.hpp:378
void digitalWrite(int pin, PinValue val)
Write digital value to pin.
Definition pin.cpp.hpp:51
void delayMicroseconds(u32 us)
Delay for a given number of microseconds.

References fl::RxChannel::begin(), fl::RxChannel::config(), fl::delayMicroseconds(), FL_ERROR, fl::span< T, Extent >::size(), and fl::RxChannelConfig::start_low.

Referenced by loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: