This example demonstrates FastLED's RX channel API on ESP32 by capturing edge transitions from manual pin toggles.
This example demonstrates FastLED's RX channel API on ESP32 by capturing edge transitions from manual pin toggles. This validates the RX channel can accurately capture timing data.
#include <FastLED.h>
#define EDGE_BUFFER_SIZE 100
#define WAIT_TIMEOUT_MS 100
{true, 1000},
{false, 1000},
{true, 2000},
{false, 2000},
{true, 3000},
{false, 100}
}};
}
const char* loop_back_mode =
PIN_TX ==
PIN_RX ?
"INTERNAL" :
"JUMPER WIRE";
FL_WARN(
"\n=== FastLED RX Channel Test ===");
FL_WARN(
"LOOP BACK MODE: " << loop_back_mode);
halt.error(
"Missing jumper wire between TX and RX pins");
return;
}
} else {
FL_WARN(
"TX and RX use same pin (" <<
PIN_TX <<
") - no jumper wire needed");
}
FL_WARN(
"Creating RX channel for testing...");
auto rx_test =
FastLED.addRx(test_channel_config);
if (!rx_test) {
halt.error(
"Failed to create RX channel for testing");
return;
}
test_config.edge_capacity = 10;
test_config.hz = 1000000;
test_config.signal_range_min_ns = 100;
test_config.signal_range_max_ns = 10000000;
test_config.start_low = true;
if (!rx_test->begin(test_config)) {
halt.error(
"Failed to initialize test RX channel");
return;
}
halt.error(
"RX channel sanity check failed - RX not working");
return;
}
FL_WARN(
"Creating main RX channel...");
halt.error(
"Failed to create main RX channel");
return;
}
FL_WARN(
"✓ Main RX channel created\n");
}
if (
halt.check())
return;
FL_WARN(
"\n╔════════════════════════════════════════════════════════════════╗");
FL_WARN(
"╚════════════════════════════════════════════════════════════════╝\n");
config.hz = 1000000;
config.signal_range_min_ns = 100;
config.signal_range_max_ns = 10000000;
config.start_low = true;
FL_WARN(
"[TEST] Initializing RX channel and executing toggles...");
rx_channel->setConfig(config);
FL_ERROR(
"Buffer overflow during capture");
} else {
FL_WARN(
"[TEST] ✓ Data captured successfully");
size_t edge_count = rx_channel->getRawEdgeTimes(edge_buffer);
}
FL_WARN(
"\n╔════════════════════════════════════════════════════════════════╗");
FL_WARN(
"║ TEST COMPLETE - Waiting 5 seconds...");
FL_WARN(
"╚════════════════════════════════════════════════════════════════╝\n");
}
const fl::RxBackend RX_BACKEND
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
fl::shared_ptr< fl::RxChannel > & rxChannelSingleton()
const fl::array< PinToggle, 6 > TEST_PATTERN
Sketch halting mechanism that prevents watchdog timer resets.
A fixed-size array implementation similar to std::array.
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
void delay(u32 ms, bool run_async=true) FL_NOEXCEPT
Public delay wrapper that keeps bare Arduino delay() preferred after using fl::delay; while still all...
@ RMT
ESP32-only RMT capture backend.
@ TIMEOUT
Operation timed out.
@ BUFFER_OVERFLOW
Buffer overflow.
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.
bool testRxChannelSanity(fl::shared_ptr< fl::RxChannel > rx, int pin_tx)
Test RX channel functionality with low-frequency pattern.
bool validateEdgeTiming(fl::span< const fl::EdgeTime > edges, size_t edge_count, fl::span< const PinToggle > expected_pattern, uint32_t tolerance_percent)
Validate captured edge timings against expected pattern.
bool verifyJumperWire(int pin_tx, int pin_rx)
Verify jumper wire connection between TX and RX pins.