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

◆ setup()

void setup ( )

Definition at line 77 of file RX.ino.

77 {
78 Serial.begin(115200);
79 while (!Serial && millis() < 3000);
80 const char* loop_back_mode = PIN_TX == PIN_RX ? "INTERNAL" : "JUMPER WIRE";
81
82 FL_WARN("\n=== FastLED RX Channel Test ===");
83 FL_WARN("Platform: ESP32");
84 FL_WARN("TX Pin: GPIO " << PIN_TX);
85 FL_WARN("RX Pin: GPIO " << PIN_RX);
86 FL_WARN("RX Backend: " << (RX_BACKEND == fl::RxBackend::RMT ? "RMT" : "ISR"));
87 FL_WARN("LOOP BACK MODE: " << loop_back_mode);
88
89 // Sanity check: Verify jumper wire connection when TX and RX are different pins
90 if (PIN_TX != PIN_RX) {
92 halt.error("Missing jumper wire between TX and RX pins");
93 return;
94 }
95 } else {
96 FL_WARN("TX and RX use same pin (" << PIN_TX << ") - no jumper wire needed");
97 }
98
99 FL_WARN("");
100
101 // Create RX channel for testing
102 // Use 1MHz resolution for better timing accuracy (1us per tick)
103 FL_WARN("Creating RX channel for testing...");
104 fl::RxChannelConfig test_channel_config(PIN_RX, RX_BACKEND);
105 auto rx_test = FastLED.addRx(test_channel_config);
106 if (!rx_test) {
107 halt.error("Failed to create RX channel for testing");
108 return;
109 }
110
111 // Initialize test RX channel with config
113 test_config.edge_capacity = 10;
114 test_config.hz = 1000000; // 1MHz resolution for better timing accuracy
115 test_config.signal_range_min_ns = 100;
116 test_config.signal_range_max_ns = 10000000;
117 test_config.start_low = true;
118
119 if (!rx_test->begin(test_config)) {
120 halt.error("Failed to initialize test RX channel");
121 return;
122 }
123
124 // Test RX channel functionality
125 if (!testRxChannelSanity(rx_test, PIN_TX)) {
126 halt.error("RX channel sanity check failed - RX not working");
127 return;
128 }
129 FL_WARN("");
130
131 // Create main RX channel for the loop
132 // Use 1MHz resolution to allow longer timeouts (40MHz = ~819us max, 1MHz = ~32ms max)
133 FL_WARN("Creating main RX channel...");
134 fl::RxChannelConfig main_channel_config(PIN_RX, RX_BACKEND);
135 rxChannelSingleton() = FastLED.addRx(main_channel_config);
136 if (!rxChannelSingleton()) {
137 halt.error("Failed to create main RX channel");
138 return;
139 }
140 FL_WARN("✓ Main RX channel created\n");
141
142 delay(1000);
143}
#define PIN_TX
const fl::RxBackend RX_BACKEND
#define PIN_RX
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
fl::shared_ptr< fl::RxChannel > & rxChannelSingleton()
Definition RX.ino:66
SketchHalt halt
Definition RX.ino:71
#define FL_WARN(X)
Definition log.h:276
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...
Definition delay.h:98
@ RMT
ESP32-only RMT capture backend.
Definition types.h:10
#define Serial
Definition serial.h:304
bool testRxChannelSanity(fl::shared_ptr< fl::RxChannel > rx, int pin_tx)
Test RX channel functionality with low-frequency pattern.
Definition test.cpp:160
bool verifyJumperWire(int pin_tx, int pin_rx)
Verify jumper wire connection between TX and RX pins.
Definition test.cpp:7

References fl::RxChannelConfig::edge_capacity, FastLED, FL_WARN, halt, fl::RxChannelConfig::hz, PIN_RX, PIN_TX, fl::RMT, RX_BACKEND, rxChannelSingleton(), Serial, fl::RxChannelConfig::signal_range_max_ns, fl::RxChannelConfig::signal_range_min_ns, fl::RxChannelConfig::start_low, testRxChannelSanity(), and verifyJumperWire().

+ Here is the call graph for this function: