FastLED 3.10.8
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)

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}
const RxChannelConfig & config() const FL_NO_EXCEPT
Definition channel.h:46
bool begin(const RxChannelConfig &config) FL_NO_EXCEPT
constexpr fl::size size() const FL_NO_EXCEPT
Definition span.h:483
#define FL_ERROR(...)
Definition log.h:373
void digitalWrite(int pin, PinValue val) FL_NO_EXCEPT
Write digital value to pin.
Definition pin.cpp.hpp:51
void pinMode(int pin, PinMode mode) FL_NO_EXCEPT
Set pin mode (input, output, pull-up, pull-down)
Definition pin.cpp.hpp:394
void delayMicroseconds(u32 us) FL_NO_EXCEPT
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: