10#if FL_PLATFORM_HAS_LARGE_MEMORY
14#include "platforms/arm/rp/is_rp.h"
15#if defined(FL_IS_RP2040) || defined(FL_IS_RP2350)
18#include "platforms/arm/rp/rpcommon/rx_pio_channel.h"
20#if defined(FL_IS_RP2040) || defined(FL_IS_RP2350)
25#include "platforms/arm/rp/rpcommon/rp_uart_bus_traits.h"
29#include "platforms/arm/teensy/teensy4_common/drivers/objectfled/objectfled_diagnostics.h"
51#define AR_FL_WARN(...) do { \
52 if (fl::getLogLevel() >= static_cast<fl::u8>(fl::LogLevel::FL_LOG_LEVEL_WARN)) { \
53 FL_WARN(__VA_ARGS__); \
67#if defined(FL_IS_RP2040) || defined(FL_IS_RP2350)
68void countRpPioRxRisingEdges(
void* user_data) {
70 if (edges !=
nullptr) {
77#if defined(ESP32) && FASTLED_ESP32_HAS_PARLIO
78#include "platforms/esp/32/drivers/parlio/channel_driver_parlio.h"
89 AR_FL_WARN(
"[RAW EDGE TIMING] ERROR: RX channel is null");
97 size_t buffer_size = range.
count < 256 ? range.
count : 256;
101 size_t edge_count = rx_channel->getRawEdgeTimes(edges, range.
offset);
103 if (edge_count == 0) {
104 AR_FL_WARN(
"[RAW EDGE TIMING] WARNING: No edge data captured at offset " << range.
offset);
109 size_t start_idx = range.
offset;
110 size_t end_idx = range.
offset + edge_count;
119 edge_dump <<
"[RAW EDGES " << start_idx <<
".." << (end_idx - 1) <<
"]";
120 for (
size_t i = 0; i < edge_count; i++) {
121 edge_dump <<
" " << (edges[i].high ?
"H" :
"L") << edges[i].ns;
123 AR_FL_WARN(edge_dump.
str());
127 if (range.
offset == 0 && edge_count >= 16) {
136 bool has_short_high =
false, has_long_high =
false;
137 bool has_short_low =
false, has_long_low =
false;
139 for (
size_t i = 0; i < edge_count; i++) {
142 if (ns >= expected_bit0_high - tolerance && ns <= expected_bit0_high + tolerance)
143 has_short_high =
true;
144 if (ns >= expected_bit1_high - tolerance && ns <= expected_bit1_high + tolerance)
145 has_long_high =
true;
147 if (ns >= expected_bit1_low - tolerance && ns <= expected_bit1_low + tolerance)
148 has_short_low =
true;
149 if (ns >= expected_bit0_low - tolerance && ns <= expected_bit0_low + tolerance)
155 ss <<
"\n[RAW EDGE TIMING] Pattern Analysis:\n";
156 ss <<
" Short HIGH (~" << expected_bit0_high <<
"ns, Bit 0): " << (has_short_high ?
"FOUND ✓" :
"MISSING ✗") <<
"\n";
157 ss <<
" Long HIGH (~" << expected_bit1_high <<
"ns, Bit 1): " << (has_long_high ?
"FOUND ✓" :
"MISSING ✗") <<
"\n";
158 ss <<
" Short LOW (~" << expected_bit1_low <<
"ns, Bit 1): " << (has_short_low ?
"FOUND ✓" :
"MISSING ✗") <<
"\n";
159 ss <<
" Long LOW (~" << expected_bit0_low <<
"ns, Bit 0): " << (has_long_low ?
"FOUND ✓" :
"MISSING ✗");
160 AR_FL_WARN(ss.
str());
162 if (has_short_high && has_long_high && has_short_low && has_long_low) {
163 AR_FL_WARN(
"\n[RAW EDGE TIMING] ✓ Encoder appears to be working correctly (varied timing patterns)");
164 }
else if (!has_short_high && !has_long_high) {
166 ss <<
"[RAW EDGE TIMING] ✗ ENCODER BROKEN: No valid HIGH pulses detected!\n";
167 ss <<
"[RAW EDGE TIMING] Possible causes:\n";
168 ss <<
"[RAW EDGE TIMING] 1. Encoder not reading pixel buffer data\n";
169 ss <<
"[RAW EDGE TIMING] 2. Bytes encoder state machine stuck\n";
170 ss <<
"[RAW EDGE TIMING] 3. Data pointer not passed correctly to encoder";
172 }
else if (!has_short_low && !has_long_low) {
174 AR_FL_WARN(
"[RAW EDGE TIMING] ✗ ENCODER BROKEN: No valid LOW pulses detected!");
176 AR_FL_WARN(
"[RAW EDGE TIMING] ⚠ Partial pattern match - encoder may have issues");
202 leds.data(),
static_cast<int>(
leds.size()),
250 mode, current,
false ,
gamma.get());
263 if (!rx_channel || clock_hz == 0) {
264 AR_FL_WARN(
"[SPI DECODE] Invalid parameters");
268 const uint32_t bit_period_ns =
static_cast<uint32_t>(1000000000ULL / clock_hz);
269 const uint32_t half_bit_ns = bit_period_ns / 2;
270 AR_FL_WARN(
"[SPI DECODE] clock=" << clock_hz <<
" Hz, bit_period=" << bit_period_ns <<
" ns");
273 constexpr size_t MAX_EDGES = 4096;
276 size_t edge_count = rx_channel->getRawEdgeTimes(edge_span, 0);
278 if (edge_count == 0) {
279 AR_FL_WARN(
"[SPI DECODE] No edges captured");
282 AR_FL_WARN(
"[SPI DECODE] Captured " << edge_count <<
" edges");
290 for (
size_t i = 0; i < edge_count; i++) {
292 uint32_t num_bits = (duration + half_bit_ns) / bit_period_ns;
293 if (num_bits == 0) num_bits = 1;
294 uint8_t bit_val = edges[i].high ? 1 : 0;
295 for (uint32_t b = 0; b < num_bits; b++) {
300 AR_FL_WARN(
"[SPI DECODE] Reconstructed " << bits.
size() <<
" bits");
302 if (bits.
size() < 32) {
303 AR_FL_WARN(
"[SPI DECODE] Too few bits for APA102 frame");
308 size_t total_bytes = bits.
size() / 8;
310 for (
size_t i = 0; i < total_bytes; i++) {
312 for (
int bit = 7; bit >= 0; bit--) {
313 size_t bit_idx = i * 8 + (7 - bit);
314 if (bit_idx < bits.
size() && bits[bit_idx]) {
315 byte_val |= (1 << bit);
318 raw_bytes[i] = byte_val;
321 AR_FL_WARN(
"[SPI DECODE] Decoded " << total_bytes <<
" raw bytes");
326 dbg <<
"[SPI DECODE] First bytes:";
327 size_t show = total_bytes < 20 ? total_bytes : 20;
328 for (
size_t i = 0; i <
show; i++) {
330 uint8_t hi = raw_bytes[i] >> 4;
331 uint8_t lo = raw_bytes[i] & 0xF;
332 dbg << (char)(hi < 10 ?
'0' + hi :
'A' + hi - 10);
333 dbg << (char)(lo < 10 ?
'0' + lo :
'A' + lo - 10);
335 AR_FL_WARN(dbg.
str());
342 size_t data_start = 0;
345 if (total_bytes >= 4 && raw_bytes[0] == 0x00 && raw_bytes[1] == 0x00 &&
346 raw_bytes[2] == 0x00 && raw_bytes[3] == 0x00) {
348 AR_FL_WARN(
"[SPI DECODE] Found start frame at offset 0");
352 AR_FL_WARN(
"[SPI DECODE] No start frame (first edge = first LED data)");
362 size_t led_bytes_written = 0;
363 size_t pos = data_start;
365 while (
pos + 4 <= total_bytes) {
369 if ((header & 0xE0) != 0xE0) {
370 AR_FL_WARN(
"[SPI DECODE] End of LED data at byte " <<
pos
371 <<
" (header=0x" << ((header >> 4) < 10 ?
'0' + (header >> 4) :
'A' + (header >> 4) - 10)
372 << ((header & 0xF) < 10 ?
'0' + (header & 0xF) :
'A' + (header & 0xF) - 10) <<
")");
380 if (led_bytes_written + 3 <= rx_buffer.
size()) {
381 rx_buffer[led_bytes_written + 0] = c0;
382 rx_buffer[led_bytes_written + 1] = c1;
383 rx_buffer[led_bytes_written + 2] = c2;
384 led_bytes_written += 3;
386 AR_FL_WARN(
"[SPI DECODE] rx_buffer full at LED " << (led_bytes_written / 3));
392 size_t num_leds = led_bytes_written / 3;
393 AR_FL_WARN(
"[SPI DECODE] Extracted " << num_leds <<
" LEDs (" << led_bytes_written <<
" RGB bytes)");
394 return led_bytes_written;
409 static_cast<int>(rx_channel->getRawEdgeTimes(edges, 0));
413 const size_t sample_count = rx_channel->getRawEdgeTimes(sample_edges, 0);
415 for (
size_t i = 0; i < sample_count; ++i) {
419 sample << (sample_edges[i].high ?
'H' :
'L') << sample_edges[i].ns;
434 const char* driver_name) {
437#if defined(FL_IS_RP2040) || defined(FL_IS_RP2350)
441 }
else if (
fl::strcmp(driver_name,
"UART1") == 0) {
446 if (uart_timing.T1 == 0) {
456 const char* driver_name) {
471 bool is_spi_driver = (
fl::strcmp(driver_name,
"SPI") == 0);
472 bool is_parlio_driver = (
fl::strcmp(driver_name,
"PARLIO") == 0);
473 bool is_i2s_driver = (
fl::strcmp(driver_name,
"I2S") == 0);
477 bool is_lcd_clockless_driver = (
fl::strcmp(driver_name,
"LCD_CLOCKLESS") == 0);
478 bool lcd_clockless_uses_wave3 =
false;
479 if (is_lcd_clockless_driver) {
483 bool uses_wave8 = is_spi_driver || is_parlio_driver || is_i2s_driver
484 || (is_lcd_clockless_driver && !lcd_clockless_uses_wave3);
485 bool uses_wave3 = is_lcd_clockless_driver && lcd_clockless_uses_wave3;
492 const uint32_t tick_ns = is_parlio_driver ? 125 : (period / 8);
495 static_cast<float>(timing.
t1_ns) / period * 8.0f + 0.5f);
497 static_cast<float>(timing.
t1_ns + timing.
t2_ns) / period * 8.0f + 0.5f);
499 const uint32_t actual_t0h = pulses_bit0 * tick_ns;
500 const uint32_t actual_t1h = pulses_bit1 * tick_ns;
501 const uint32_t actual_period = 8 * tick_ns;
502 const char* wave8_name = is_spi_driver ?
"SPI_wave8" :
503 is_parlio_driver ?
"PARLIO_wave8" :
504 is_lcd_clockless_driver ?
"LCD_CLOCKLESS_wave8" :
"I2S_wave8";
507 actual_t1h - actual_t0h,
508 actual_period - actual_t1h,
512 AR_FL_WARN(
"[RX TIMING] " << wave8_name <<
": pulses_bit0=" << pulses_bit0
513 <<
" pulses_bit1=" << pulses_bit1
514 <<
" tick_ns=" << tick_ns
515 <<
" -> T1=" << tx_timing.
T1 <<
" T2=" << tx_timing.
T2
516 <<
" T3=" << tx_timing.
T3);
517 }
else if (uses_wave3) {
520 const uint32_t tick_ns = period / 3;
522 static_cast<float>(timing.
t1_ns) / period * 3.0f + 0.5f);
524 static_cast<float>(timing.
t1_ns + timing.
t2_ns) / period * 3.0f + 0.5f);
525 const uint32_t actual_t0h = ticks_bit0 * tick_ns;
526 const uint32_t actual_t1h = ticks_bit1 * tick_ns;
527 const uint32_t actual_period = 3 * tick_ns;
530 actual_t1h - actual_t0h,
531 actual_period - actual_t1h,
533 "LCD_CLOCKLESS_wave3"
535 AR_FL_WARN(
"[RX TIMING] LCD_CLOCKLESS_wave3: ticks_bit0=" << ticks_bit0
536 <<
" ticks_bit1=" << ticks_bit1
537 <<
" tick_ns=" << tick_ns
538 <<
" -> T1=" << tx_timing.
T1 <<
" T2=" << tx_timing.
T2
539 <<
" T3=" << tx_timing.
T3);
545 const uint32_t tolerance = (uses_wave8 || uses_wave3) ? 200 : 170;
552 rx_timing.gap_tolerance_ns = 100000;
566 size_t expected_data_bytes,
569 const char* driver_name,
594 rx_config.hz = 40000000;
598 bool is_uart_driver = (
fl::strcmp(driver_name,
"UART") == 0)
602 bool is_object_fled_driver = (
fl::strcmp(driver_name,
"OBJECT_FLED") == 0);
604 rx_buffer.
size(), expected_data_bytes, rx_channel->backend());
605#if defined(FL_IS_TEENSY_4X)
614 if (rx_config.edge_capacity == 0) {
615 FL_ERROR(
"[CAPTURE] RX edge-capacity overflow");
618#if defined(FL_IS_RP2040) || defined(FL_IS_RP2350)
622 const bool is_rp_pio_capture =
627 if (is_rp_pio_capture) {
632 constexpr size_t kPioPhasesPerDataByte = 16;
637 constexpr size_t kPioPhaseHeadroomNumerator = 2;
638 constexpr size_t kPioPhasesPerDataByteWithHeadroom =
639 kPioPhasesPerDataByte * kPioPhaseHeadroomNumerator;
640 if (expected_data_bytes >
641 (
static_cast<size_t>(-1) - 1u) / kPioPhasesPerDataByteWithHeadroom) {
642 FL_ERROR(
"[CAPTURE] PIO edge-capacity overflow");
652 expected_data_bytes * kPioPhasesPerDataByteWithHeadroom + 1u;
656 rx_config.edge_capacity = requested;
660 bool is_rmt_driver = (
fl::strcmp(driver_name,
"RMT") == 0);
661 const int rx_pin = rx_channel->getPin();
668 const bool use_rmt_internal_loopback =
670 is_rmt_driver, tx_pin, rx_pin);
671 rx_config.io_loop_back = use_rmt_internal_loopback;
679 rx_config.use_dma = !is_rmt_driver;
685 rx_config.backend = rx_channel->backend();
696 if (is_uart_driver) {
701 uart_timing = resolveUartWireTiming(timing, driver_name);
702 if (uart_timing.T1 == 0 && uart_timing.T2 == 0) {
705 AR_FL_WARN(
"[CAPTURE] UART: no representable wave geometry for "
712 uart_rx_timing.gap_tolerance_ns = 100000;
715 is_uart_driver ? uart_rx_timing : buildRxDecodeTiming(timing, driver_name);
716 rx_config.stream_timing = rx_timing;
717 if (use_rmt_internal_loopback) {
718 AR_FL_WARN(
"[CAPTURE] RMT TX -> RMT RX: Same-pin internal loopback enabled");
726 AR_FL_WARN(
"[CAPTURE] " << driver_name
727 <<
" TX GPIO " << tx_pin <<
" -> RX GPIO " << rx_pin
728 <<
": External jumper "
729 <<
"(io_loop_back=false, use_dma="
730 << (rx_config.use_dma ?
"true" :
"false") <<
")");
740 const uint32_t TX_WAIT_TIMEOUT_MS = 1000;
746 AR_FL_WARN(
"[CAPTURE] RMT: Two-TX approach (ESP32-S3 workaround)");
749 if (!
FastLED.wait(TX_WAIT_TIMEOUT_MS)) {
750 FL_ERROR(
"[CAPTURE] TX wait timeout (pre-arm) - driver may be stalled");
755 if (!rx_channel->begin(rx_config)) {
756 if (diagnostics) diagnostics->
rxBeginError = rx_channel->lastBeginError();
757 FL_ERROR(
"Failed to arm RX receiver");
762 if (!
FastLED.wait(TX_WAIT_TIMEOUT_MS)) {
763 FL_ERROR(
"[CAPTURE] TX wait timeout (capture) - driver may be stalled");
768 if (!rx_channel->begin(rx_config)) {
769 if (diagnostics) diagnostics->
rxBeginError = rx_channel->lastBeginError();
770 AR_FL_WARN(
"[CAPTURE] RX begin() failed for pin " << rx_channel->getPin());
774 AR_FL_WARN(
"[CAPTURE] RX armed, calling FastLED.show()...");
777#if defined(FL_IS_RP2040) || defined(FL_IS_RP2350)
780 bool edge_counter_attached =
false;
781 const bool measure_rp_pio =
784 diagnostics !=
nullptr;
785 if (measure_rp_pio) {
794 edge_config.
handler = countRpPioRxRisingEdges;
798 static_cast<fl::u8>(rx_channel->getPin()), edge_config, &edge_counter) == 0;
803 AR_FL_WARN(
"[CAPTURE] FastLED.show() returned, calling wait...");
805#if defined(FL_IS_RP2040) || defined(FL_IS_RP2350)
806 if (edge_counter_attached && edge_counter.
is_valid()) {
811 diagnostics !=
nullptr) {
815 if (!
FastLED.wait(TX_WAIT_TIMEOUT_MS)) {
816 if (is_object_fled_driver) {
817 fl::objectFledDiagnosticsRecord(
"afterFastLedWaitTimeout");
819 AR_FL_WARN(
"[CAPTURE] FastLED.wait() timed out");
822 if (is_object_fled_driver) {
823 fl::objectFledDiagnosticsRecord(
"afterFastLedWait");
826 AR_FL_WARN(
"[CAPTURE] FastLED.wait() done");
836 const uint32_t rx_wait_ms = is_uart_driver ? 500 : 150;
838 AR_FL_WARN(
"[CAPTURE] Waiting for RX completion (" << rx_wait_ms
839 <<
"ms timeout)...");
841 auto wait_result = rx_channel->wait(rx_wait_ms);
846 collectRawEdgeDiagnostics(rx_channel, diagnostics);
850 AR_FL_WARN(
"[CAPTURE] RX wait returned: "
851 <<
static_cast<int>(wait_result));
855 AR_FL_WARN(
"RX wait failed (timeout or no data received)");
857 ss <<
"\n⚠️ TROUBLESHOOTING:\n";
858 ss <<
" 1. Connect physical jumper wire from TX GPIO to RX GPIO " << rx_channel->getPin() <<
"\n";
859 ss <<
" 2. Check that both TX and RX pins are correctly configured\n";
860 ss <<
" 3. Verify the GPIO connection is working (GPIO baseline test should pass)\n";
861 ss <<
" 4. RMT internal loopback requires TX and RX to use the same GPIO";
862 AR_FL_WARN(ss.
str());
863 if (!is_uart_driver) {
867 AR_FL_WARN(
"[CAPTURE] UART: attempting decode with captured edges despite timeout");
880 if (is_uart_driver) {
881 AR_FL_WARN(
"[CAPTURE] UART (inverted TX): using standard WS2812 decoder with UART timing...");
886 AR_FL_WARN(
"[CAPTURE] UART RX timing: T0H=" << uart_timing.T1
887 <<
" T1H=" << (uart_timing.T1 + uart_timing.T2)
888 <<
" T0L=" << (uart_timing.T2 + uart_timing.T3)
889 <<
" T1L=" << uart_timing.T3);
891 auto decode_result = rx_channel->decode(uart_rx_timing, rx_buffer);
892 if (!decode_result.ok()) {
893 AR_FL_WARN(
"[CAPTURE] UART decode failed (error: " <<
static_cast<int>(decode_result.error()) <<
")");
901 AR_FL_WARN(
"[CAPTURE] UART decoded " << decode_result.value() <<
" LED bytes");
902 return decode_result.value();
908 bool is_lcd_spi_driver = (
fl::strcmp(driver_name,
"LCD_SPI") == 0);
909 bool is_i2s_spi_driver = (
fl::strcmp(driver_name,
"I2S_SPI") == 0);
910 bool is_spi_unified_driver = (
fl::strcmp(driver_name,
"SPI_UNIFIED") == 0);
911 if (is_lcd_spi_driver || is_i2s_spi_driver || is_spi_unified_driver) {
913 const uint32_t spi_clock_hz = 2400000;
914 AR_FL_WARN(
"[CAPTURE] SPI chipset decode: clock=" << spi_clock_hz <<
" Hz");
915 size_t decoded = decodeSpiEdges(rx_channel, rx_buffer, spi_clock_hz);
917 AR_FL_WARN(
"[CAPTURE] SPI decode failed");
929 AR_FL_WARN(
"[CAPTURE] Decoding...");
930 auto decode_result = rx_channel->decode(rx_timing, rx_buffer);
932 diagnostics->
decodeOk = decode_result.ok() ? 1 : 0;
934 decode_result.ok() ? -1 :
static_cast<int>(decode_result.error());
936 decode_result.ok() ?
static_cast<int>(decode_result.value()) : 0;
939 if (!decode_result.ok()) {
942 AR_FL_WARN(
"Decode failed (error code: " <<
static_cast<int>(decode_result.error()) <<
")");
952 AR_FL_WARN(
"[CAPTURE] Decoded " << decode_result.value() <<
" bytes");
953 return decode_result.value();
958void runTest(
const char* test_name,
960 int& total,
int& passed) {
966 AR_FL_WARN(
"\n[MULTI-LANE] Testing " << config.
tx_configs.
size() <<
" lanes, testing Lane 0 only (hardware limitation)");
970 for (
size_t config_idx = 0; config_idx < channels_to_test; config_idx++) {
975 size_t num_leds =
leds.size();
976 const bool lane_uses_rgbw =
977 legacyLaneUsesRgbw(config, config_idx);
982 const bool lane_uses_ucs7604 = isUCS7604(config.
encoder);
984 if (lane_uses_ucs7604) {
985 expected_encoded = buildExpectedUCS7604(
988 const size_t expected_data_bytes =
989 lane_uses_ucs7604 ? expected_encoded.
size()
990 : num_leds * (lane_uses_rgbw ? 4u : 3u);
998 static_cast<int>(config_idx),
1000 static_cast<int>(num_leds),
1004 AR_FL_WARN(
"\n=== " << test_name <<
" [Lane " << config_idx <<
"/" << config.
tx_configs.
size()
1005 <<
", Pin " << config.
tx_configs[config_idx].getDataPin()
1006 <<
", LEDs " << config.
tx_configs[config_idx].mLeds.
size() <<
"] ===");
1010 FL_ERROR(
"[" << ctx.driver_name <<
"/" << ctx.timing_name <<
"/" << ctx.pattern_name
1011 <<
" | Lane " << ctx.lane_index <<
"/" << ctx.lane_count
1012 <<
" (Pin " << ctx.pin_number <<
", " << ctx.num_leds <<
" LEDs) | RX:" << ctx.rx_type_name <<
"] "
1013 <<
"RX channel is null - must be created in .ino and passed via AutoResearchConfig");
1014 FL_ERROR(
"Result: FAIL ✗ (RX channel not provided)");
1019 expected_data_bytes,
1023 if (bytes_captured == 0) {
1024 FL_ERROR(
"[" << ctx.driver_name <<
"/" << ctx.timing_name <<
"/" << ctx.pattern_name
1025 <<
" | Lane " << ctx.lane_index <<
"/" << ctx.lane_count
1026 <<
" (Pin " << ctx.pin_number <<
", " << ctx.num_leds <<
" LEDs) | RX:" << ctx.rx_type_name <<
"] "
1027 <<
"Result: FAIL ✗ (capture failed)");
1033 if (lane_uses_ucs7604) {
1035 size_t expected_len = expected_encoded.
size();
1037 AR_FL_WARN(
"UCS7604 encoded comparison: expected " << expected_len <<
" bytes, captured " << bytes_captured);
1039 size_t compare_len = (bytes_captured < expected_len) ? bytes_captured : expected_len;
1040 for (
size_t i = 0; i < compare_len; i++) {
1041 if (expected_encoded[i] != config.
rx_buffer[i]) {
1046 if (bytes_captured < expected_len) {
1047 mismatches +=
static_cast<int>(expected_len - bytes_captured);
1050 AR_FL_WARN(
"Bytes Captured: " << bytes_captured <<
" (expected: " << expected_len <<
")");
1051 int total_bytes =
static_cast<int>(expected_len);
1052 AR_FL_WARN(
"Accuracy: " << (100.0 * (total_bytes - mismatches) / total_bytes) <<
"% ("
1053 << (total_bytes - mismatches) <<
"/" << total_bytes <<
" bytes match)");
1054 }
else if (lane_uses_rgbw) {
1056 buildExpectedClockless(
1058 const size_t expected_len = expected.
size();
1059 const size_t compare_len =
1060 bytes_captured < expected_len ? bytes_captured : expected_len;
1061 for (
size_t i = 0; i < compare_len; ++i) {
1062 if (expected[i] != config.
rx_buffer[i]) {
1066 if (bytes_captured < expected_len) {
1068 static_cast<int>(expected_len - bytes_captured);
1071 AR_FL_WARN(
"RGBW bytes captured: " << bytes_captured
1072 <<
" (expected: " << expected_len <<
")");
1073 AR_FL_WARN(
"Accuracy: "
1074 << (100.0 * (expected_len - mismatches) / expected_len)
1075 <<
"% (" << (expected_len - mismatches) <<
"/"
1076 << expected_len <<
" bytes match)");
1079 size_t bytes_expected = num_leds * 3;
1082 const size_t front_padding_bytes = 0;
1083 const size_t rx_buffer_offset = front_padding_bytes;
1085 if (bytes_captured > bytes_expected + front_padding_bytes) {
1086 AR_FL_WARN(
"Info: Captured " << bytes_captured <<
" bytes ("
1087 << front_padding_bytes <<
" front pad + "
1088 << bytes_expected <<
" LED data + "
1089 << (bytes_captured - bytes_expected - front_padding_bytes) <<
" back pad/RESET)");
1093 size_t bytes_to_check = (bytes_captured < bytes_expected + rx_buffer_offset) ?
1094 (bytes_captured > rx_buffer_offset ? bytes_captured - rx_buffer_offset : 0) :
1096 (void)bytes_to_check;
1098 for (
size_t i = 0; i < num_leds; i++) {
1099 size_t byte_offset = rx_buffer_offset + i * 3;
1100 if (byte_offset + 2 >= bytes_captured) {
1101 FL_ERROR(
"[" << ctx.driver_name <<
"/" << ctx.timing_name <<
"/" << ctx.pattern_name
1102 <<
" | Lane " << ctx.lane_index <<
"/" << ctx.lane_count
1103 <<
" (Pin " << ctx.pin_number <<
", " << ctx.num_leds <<
" LEDs) | RX:" << ctx.rx_type_name <<
"] "
1104 <<
"Incomplete data for LED[" <<
static_cast<int>(i)
1105 <<
"] (only " << bytes_captured <<
" bytes captured)");
1117 if (expected_r != actual_r || expected_g != actual_g || expected_b != actual_b) {
1122 AR_FL_WARN(
"Bytes Captured: " << bytes_captured <<
" (expected: " << bytes_expected <<
")");
1123 AR_FL_WARN(
"Accuracy: " << (100.0 * (num_leds - mismatches) / num_leds) <<
"% ("
1124 << (num_leds - mismatches) <<
"/" << num_leds <<
" LEDs match)");
1127 if (mismatches == 0) {
1128 AR_FL_WARN(
"Result: PASS ✓");
1131 FL_ERROR(
"[" << ctx.driver_name <<
"/" << ctx.timing_name <<
"/" << ctx.pattern_name
1132 <<
" | Lane " << ctx.lane_index <<
"/" << ctx.lane_count
1133 <<
" (Pin " << ctx.pin_number <<
", " << ctx.num_leds <<
" LEDs) | RX:" << ctx.rx_type_name <<
"] "
1134 <<
"Result: FAIL ✗");
1144 int& total,
int& passed,
1164 ss <<
"\n╔════════════════════════════════════════════════════════════════╗\n";
1165 ss <<
"║ MULTI-RUN TEST: " << test_name <<
"\n";
1166 ss <<
"║ Runs: " << multi_config.
num_runs <<
" | Print Mode: "
1167 << (multi_config.
print_all_runs ?
"All" :
"Errors ONLY") <<
"\n";
1168 ss <<
"╚════════════════════════════════════════════════════════════════╝";
1169 AR_FL_WARN(ss.
str());
1173 int total_passed = 0;
1174 int total_failed = 0;
1175 bool retained_success =
false;
1181 AR_FL_WARN(
"[MULTI-LANE] Testing " << config.
tx_configs.
size() <<
" lanes, testing Lane 0 only");
1188 if (channels_to_test > 0 && legacyLaneUsesRgbw(config, 0)) {
1190 buildExpectedClockless(config.
tx_configs[0].mLeds,
true);
1197 const bool lane_uses_ucs7604 = isUCS7604(config.
encoder);
1199 if (channels_to_test > 0 && lane_uses_ucs7604) {
1214 if (kLogsEnabled && (run % 3 == 1 || multi_config.
num_runs <= 5)) {
1215 AR_FL_WARN(
"[Run " << run <<
"/" << multi_config.
num_runs <<
"] Testing...");
1222 for (
size_t config_idx = 0; config_idx < channels_to_test; config_idx++) {
1224 size_t num_leds =
leds.size();
1225 const bool lane_uses_rgbw =
1226 legacyLaneUsesRgbw(config, config_idx);
1227 const size_t expected_data_bytes =
1228 lane_uses_ucs7604 ? expected_ucs7604.
size()
1229 : num_leds * (lane_uses_rgbw ? 4u : 3u);
1230 result.total_leds = num_leds;
1231 result.totalBytes =
static_cast<int>(expected_data_bytes);
1245 result.baselineMw = fl::framePowerMCUBaselineMilliwatts() +
1246 dark_per_led *
static_cast<uint32_t>(num_leds);
1247 result.fullDemandMw = fl::framePowerMCUBaselineMilliwatts() +
1255 size_t bytes_captured =
1257 expected_data_bytes,
1261 result.capturedBytes =
static_cast<int>(bytes_captured);
1263 if (bytes_captured == 0) {
1264 AR_FL_WARN(
"[Run " << run <<
"] Capture failed");
1265 result.mismatches =
static_cast<int>(num_leds);
1266 result.mismatchedBytes =
static_cast<int>(
result.totalBytes);
1267 result.captureFailed =
true;
1272 collectRawEdgeDiagnostics(config.
rx_channel, &result);
1288 size_t dump_count = (bytes_captured < 24) ? bytes_captured : 24;
1289 for (
size_t i = 0; i < dump_count; i++) {
1290 if (i > 0) hex_dump <<
" ";
1293 AR_FL_WARN(
"[RUN " << run <<
"] Driver=" << config.
driver_name
1294 <<
" bytes_captured=" << bytes_captured
1295 <<
" first" <<
static_cast<int>(dump_count) <<
"=" << hex_dump.
str());
1298 if (lane_uses_ucs7604) {
1301 size_t expected_len = expected_encoded.
size();
1302 result.totalBytes =
static_cast<int>(expected_len);
1304 size_t compare_len = (bytes_captured < expected_len) ? bytes_captured : expected_len;
1305 for (
size_t i = 0; i < compare_len; i++) {
1306 if (expected_encoded[i] != config.
rx_buffer[i]) {
1307 result.mismatchedBytes++;
1308 if ((expected_encoded[i] ^ config.
rx_buffer[i]) == 0x01) {
1314 if (mismatches == 1) {
1315 AR_FL_WARN(
"\n[CORRUPTION @ byte " <<
static_cast<int>(i) <<
", Run " << run
1316 <<
"] expected=0x" <<
fl::hex <<
static_cast<int>(expected_encoded[i])
1323 static_cast<int>(i), expected_encoded[i], 0, 0,
1330 if (bytes_captured < expected_len) {
1331 mismatches +=
static_cast<int>(expected_len - bytes_captured);
1333 }
else if (lane_uses_rgbw) {
1335 size_t verified_leds = 0;
1336 for (
size_t i = 0; i < num_leds; ++i) {
1337 const size_t byte_offset = i * 4;
1338 if (byte_offset + 3 >= bytes_captured) {
1341 verified_leds = i + 1;
1343 bool led_mismatch =
false;
1344 for (
size_t channel = 0; channel < 4; ++channel) {
1346 expected[byte_offset + channel];
1348 config.
rx_buffer[byte_offset + channel];
1349 if (expected_byte != actual_byte) {
1350 ++
result.mismatchedBytes;
1351 if ((expected_byte ^ actual_byte) == 0x01) {
1354 led_mismatch =
true;
1359 if (mismatches == 0) {
1360 AR_FL_WARN(
"\n[RGBW CORRUPTION @ LED "
1361 <<
static_cast<int>(i) <<
", Run "
1363 const size_t corruption_edge_index = i * 64;
1365 corruption_edge_index > 4
1366 ? corruption_edge_index - 4
1374 if (
result.errors.size() <
1375 static_cast<size_t>(
1378 static_cast<int>(i),
1379 expected[byte_offset + 0],
1380 expected[byte_offset + 1],
1381 expected[byte_offset + 2],
1382 expected[byte_offset + 3],
1391 if (verified_leds < num_leds) {
1392 const size_t unchecked = num_leds - verified_leds;
1393 mismatches +=
static_cast<int>(unchecked);
1394 result.mismatchedBytes +=
1395 static_cast<int>(unchecked * 4);
1396 AR_FL_WARN(
"[TRUNCATED RGBW CAPTURE] Only verified "
1397 << verified_leds <<
"/" << num_leds
1398 <<
" LEDs (" << bytes_captured
1399 <<
" bytes captured, needed "
1400 << expected_data_bytes <<
"). Marking "
1402 <<
" unchecked LEDs as mismatches.");
1406 size_t bytes_expected = num_leds * 3;
1409 const size_t rx_buffer_offset = 0;
1411 size_t bytes_to_check = (bytes_captured < bytes_expected + rx_buffer_offset) ?
1412 (bytes_captured > rx_buffer_offset ? bytes_captured - rx_buffer_offset : 0) :
1414 (void)bytes_to_check;
1416 size_t verified_leds = 0;
1417 for (
size_t i = 0; i < num_leds; i++) {
1418 size_t byte_offset = rx_buffer_offset + i * 3;
1419 if (byte_offset + 2 >= bytes_captured) {
1422 verified_leds = i + 1;
1437 result.sumRaw +=
static_cast<uint32_t>(expected_r) + expected_g + expected_b;
1438 result.sumWire +=
static_cast<uint32_t>(actual_r) + actual_g + actual_b;
1440 expected_r = scale8(expected_r, s);
1441 expected_g = scale8(expected_g, s);
1442 expected_b = scale8(expected_b, s);
1447 uint8_t exp_bytes[3] = {expected_r, expected_g, expected_b};
1448 uint8_t act_bytes[3] = {actual_r, actual_g, actual_b};
1449 bool led_mismatch =
false;
1450 for (
int ch = 0; ch < 3; ch++) {
1451 const int diff =
static_cast<int>(exp_bytes[ch]) - act_bytes[ch];
1452 if (diff > tolerance || diff < -tolerance) {
1453 result.mismatchedBytes++;
1454 if ((exp_bytes[ch] ^ act_bytes[ch]) == 0x01) {
1457 led_mismatch =
true;
1463 if (mismatches == 0) {
1464 AR_FL_WARN(
"\n[CORRUPTION @ LED " <<
static_cast<int>(i) <<
", Run " << run <<
"]");
1467 size_t corruption_edge_index = i * 48;
1468 size_t offset = corruption_edge_index > 4 ? corruption_edge_index - 4 : 0;
1479 i, expected_r, expected_g, expected_b,
1480 actual_r, actual_g, actual_b
1491 if (verified_leds < num_leds) {
1492 size_t unchecked = num_leds - verified_leds;
1493 mismatches +=
static_cast<int>(unchecked);
1494 result.mismatchedBytes +=
static_cast<int>(unchecked * 3);
1495 AR_FL_WARN(
"[TRUNCATED CAPTURE] Only verified " << verified_leds
1496 <<
"/" << num_leds <<
" LEDs (" << bytes_captured
1497 <<
" bytes captured, needed " << (num_leds * 3)
1498 <<
"). Marking " << unchecked
1499 <<
" unchecked LEDs as mismatches.");
1503 result.mismatches = mismatches;
1504 result.passed = (mismatches == 0);
1506 collectRawEdgeDiagnostics(config.
rx_channel, &result);
1513 AR_FL_WARN(
"[Run " << run <<
"/" << multi_config.
num_runs <<
"] "
1514 << (
result.passed ?
"PASS" :
"FAIL")
1515 <<
" | Errors: " <<
result.mismatches <<
"/" <<
result.total_leds
1516 <<
" (" << (100.0 * (
result.total_leds -
result.mismatches) /
result.total_leds) <<
"%)");
1520 AR_FL_WARN(
" First " <<
result.errors.size() <<
" error(s):");
1521 for (
size_t i = 0; i <
result.errors.size(); i++) {
1522 const auto& err =
result.errors[i];
1523 AR_FL_WARN(
" LED[" << err.led_index <<
"]: expected RGB("
1524 <<
static_cast<int>(err.expected_r) <<
","
1525 <<
static_cast<int>(err.expected_g) <<
","
1526 <<
static_cast<int>(err.expected_b) <<
") got RGB("
1527 <<
static_cast<int>(err.actual_r) <<
","
1528 <<
static_cast<int>(err.actual_g) <<
","
1529 <<
static_cast<int>(err.actual_b) <<
")");
1545 if (!
result.passed || !retained_success || multi_config.
num_runs == 1) {
1547 retained_success =
true;
1559 ss <<
"\n╔════════════════════════════════════════════════════════════════╗\n";
1560 ss <<
"║ MULTI-RUN SUMMARY\n";
1561 ss <<
"╚════════════════════════════════════════════════════════════════╝\n";
1562 ss <<
"Total Runs: " << multi_config.
num_runs <<
"\n";
1563 ss <<
"Passed: " << total_passed <<
" (" << (100.0 * total_passed / multi_config.
num_runs) <<
"%)\n";
1564 ss <<
"Failed: " << total_failed <<
" (" << (100.0 * total_failed / multi_config.
num_runs) <<
"%)";
1565 AR_FL_WARN(ss.
str());
1567 if (total_failed > 0) {
1569 ss <<
"\nFailed Run Numbers:\n";
1570 for (
const auto& r : run_results) {
1572 ss <<
" Run #" << r.run_number <<
" - " << r.mismatches <<
" errors\n";
1573 if (!r.errors.empty()) {
1574 ss <<
" First error at LED[" << r.errors[0].led_index <<
"]: "
1575 <<
"expected RGB(" <<
static_cast<int>(r.errors[0].expected_r) <<
","
1576 <<
static_cast<int>(r.errors[0].expected_g) <<
","
1577 <<
static_cast<int>(r.errors[0].expected_b) <<
") got RGB("
1578 <<
static_cast<int>(r.errors[0].actual_r) <<
","
1579 <<
static_cast<int>(r.errors[0].actual_g) <<
","
1580 <<
static_cast<int>(r.errors[0].actual_b) <<
")\n";
1584 AR_FL_WARN(ss.
str());
1590 for (
const auto& r : run_results) {
1597 if (total_failed == 0) {
1600 AR_FL_WARN(
"\n[OVERALL] PASS ✓ - All " << multi_config.
num_runs <<
" runs succeeded");
1604 AR_FL_WARN(
"\n[OVERALL] FAIL ✗ - " << total_failed <<
"/" << multi_config.
num_runs <<
" runs failed");
1614class ScopedAutoResearchPowerLimit {
1616 explicit ScopedAutoResearchPowerLimit(uint32_t max_power_mw)
FL_NO_EXCEPT
1617 : mActive(max_power_mw != 0) {
1637 int& driver_total,
int& driver_passed,
1638 uint32_t& out_show_duration_ms,
1640 int num_runs_per_pattern) {
1642 ss <<
"\n========================================\n";
1645 if (has_spi_config) {
1646 const auto* spi_cfg = config.
tx_configs[0].getSpiChipset();
1647 ss <<
" Protocol: SPI (APA102)\n";
1648 ss <<
" Clock: " << (spi_cfg ? spi_cfg->timing.clock_hz : 0) <<
" Hz\n";
1656 ss <<
"========================================";
1657 AR_FL_WARN(ss.
str());
1679 channel =
FastLED.add(channel_config);
1682 FL_ERROR(
"Failed to create channel " << i <<
" (pin " << config.
tx_configs[i].getDataPin() <<
") - platform not supported");
1684 for (
auto& ch : channels) {
1689 channels.push_back(channel);
1693 ScopedAutoResearchPowerLimit power_limit(config.
max_power_mw);
1701 FL_ERROR(
"[PREINIT] TX wait timeout - driver may be stalled on this platform");
1721 multi_config.
num_runs = (num_runs_per_pattern > 0) ? num_runs_per_pattern : 1;
1730 for (
int pattern_id = 0; pattern_id < 4; pattern_id++) {
1742 out_show_duration_ms +=
fl::millis() - show_start_ms;
1747 driver_total += total;
1748 driver_passed += passed;
1755 fl::objectFledDiagnosticsRecord(
"afterFastLedClear");
1765 int& driver_total,
int& driver_passed,
1766 uint32_t& out_show_duration_ms,
1768 int num_runs_per_pattern) {
1770 ss <<
"\n========================================\n";
1771 ss <<
"Testing (LEGACY API): " << config.
timing_name <<
"\n";
1778 ss <<
" Lane " << i <<
": pin=" << config.
tx_configs[i].getDataPin()
1781 ss <<
"========================================";
1782 AR_FL_WARN(ss.
str());
1801 if (!proxy->valid()) {
1802 FL_ERROR(
"Legacy proxy invalid for lane " << i <<
" (pin " << pin
1804 <<
" not in supported set)");
1811 ScopedAutoResearchPowerLimit power_limit(config.
max_power_mw);
1819 FL_ERROR(
"[LEGACY] TX wait timeout - driver may be stalled");
1830 multi_config.
num_runs = (num_runs_per_pattern > 0) ? num_runs_per_pattern : 1;
1838 const bool ws2814_visual_validation =
1841 const int pattern_count = ws2814_visual_validation ? 8 : 4;
1842 for (
int pattern_id = 0; pattern_id < pattern_count; pattern_id++) {
1852 if (ws2814_visual_validation && pattern_id >= 4) {
1860 out_show_duration_ms +=
fl::millis() - show_start_ms;
1862 driver_total += total;
1863 driver_passed += passed;
1870 switch (pattern_id) {
1874 for (
size_t i = 0; i < count; i++) {
1882 for (
size_t i = 0; i < count; i++) {
1890 for (
size_t i = 0; i < count; i++) {
1898 for (
size_t i = 0; i < count; i++) {
1899 int color_index = i % 3;
1900 if (color_index == 0) {
1902 }
else if (color_index == 1) {
1935 switch (pattern_id) {
1936 case 0:
return "Pattern A (R=0xF0, G=0x0F, B=0xAA)";
1937 case 1:
return "Pattern B (R=0x55, G=0xFF, B=0x00)";
1938 case 2:
return "Pattern C (R=0x0F, G=0xAA, B=0xF0)";
1939 case 3:
return "Pattern D (RGB Solid Alternating)";
1940 case 4:
return "Pattern E (Isolated Red)";
1941 case 5:
return "Pattern F (Isolated Green)";
1942 case 6:
return "Pattern G (Isolated Blue)";
1943 case 7:
return "Pattern H (Isolated White)";
1944 default:
return "Unknown Pattern";
size_t capture(fl::shared_ptr< fl::RxChannel > rx_channel, fl::span< uint8_t > rx_buffer, size_t expected_data_bytes, int tx_pin, const fl::ChipsetTimingConfig &timing, const char *driver_name, fl::RunResult *diagnostics=nullptr)
void runMultiTest(const char *test_name, fl::AutoResearchConfig &config, const fl::MultiRunConfig &multi_config, int &total, int &passed, fl::vector< fl::RunResult > *out_results=nullptr)
void autoResearchChipsetTimingLegacy(fl::AutoResearchConfig &config, int &total, int &passed, uint32_t &out_show_duration_ms, fl::vector< fl::RunResult > *out_results=nullptr, int num_runs_per_pattern=1)
const char * getBitPatternName(int pattern_id)
void runTest(const char *test_name, fl::AutoResearchConfig &config, int &total, int &passed)
void autoResearchChipsetTiming(fl::AutoResearchConfig &config, int &total, int &passed, uint32_t &out_show_duration_ms, fl::vector< fl::RunResult > *out_results=nullptr, int num_runs_per_pattern=1)
void setMixedBitPattern(CRGB *leds, size_t count, int pattern_id)
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
@ CHANNELS
Remove all channels from controller list.
@ POWER_SETTINGS
Reset power management (setMaxPowerInMilliWatts)
const char * legacyClocklessChipsetName(LegacyClocklessChipset chipset)
bool legacyClocklessChipsetHasAutomaticRgbw(LegacyClocklessChipset chipset)
Runtime chipset timing configuration for clockless LED drivers.
FastLED chrono implementation - duration types for time measurements.
void clear(bool writeData=false) FL_NO_EXCEPT
Clear the leds, wiping the local array of data.
void setMaxPowerInMilliWatts(fl::u32 milliwatts) FL_NO_EXCEPT
Set the maximum power to be used, given in milliwatts.
void setDither(fl::u8 ditherMode=BINARY_DITHER) FL_NO_EXCEPT
Set the dithering mode.
static fl::shared_ptr< const Gamma8 > getOrCreate(float gamma) FL_NO_EXCEPT
void writeWS2812(CONTAINER_UIN8_T *out) FL_NO_EXCEPT
void clear(bool freeMemory=false) FL_NO_EXCEPT
bool empty() const FL_NO_EXCEPT
constexpr bool empty() const FL_NO_EXCEPT
const T * data() const FL_NO_EXCEPT
constexpr fl::size size() const FL_NO_EXCEPT
void clear() FL_NO_EXCEPT
string str() const FL_NO_EXCEPT
fl::size size() const FL_NO_EXCEPT
void reserve(fl::size n) FL_NO_EXCEPT
void resize(fl::size n) FL_NO_EXCEPT
void push_back(const T &value) FL_NO_EXCEPT
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NO_EXCEPT
Fill a range of LEDs with a solid color.
Delay utilities for FastLED Includes nanosecond-precision delays, cycle counting, and microsecond del...
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
#define BINARY_DITHER
Enable dithering using binary dithering (only option)
#define DISABLE_DITHER
Disable dithering.
UCS7604 LED chipset encoder implementation.
Non-templated low level pixel data writing class.
fl::u32 calculate_unscaled_power_mW(fl::span< const CRGB > leds) FL_NO_EXCEPT
fl::u8 calculate_max_brightness_for_power_mW(const CRGB *ledbuffer, fl::u16 numLeds, fl::u8 target_brightness, fl::u32 max_power_mW) FL_NO_EXCEPT
Determines the highest brightness level you can use and still stay under the specified power budget f...
Umbrella header for ISR subsystem.
Centralized LED chipset timing definitions with nanosecond precision.
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
fl::enable_if<!fl::is_array< T >::value, unique_ptr< T > >::type make_unique(Args &&... args) FL_NO_EXCEPT
constexpr u32 ISR_FLAG_EDGE_RISING
int attach_external_handler(u8 pin, const config &cfg, handle *out_handle) FL_NO_EXCEPT
Attach an external interrupt handler (GPIO-based).
int detach_handler(handle &h) FL_NO_EXCEPT
Detach an ISR handler.
bool useRmtInternalLoopback(bool is_rmt_driver, int tx_pin, int rx_pin) FL_NO_EXCEPT
Whether an RMT validation capture should use ESP-IDF loopback.
size_t captureEdgeCapacity(size_t shared_buffer_bytes, size_t expected_data_bytes, RxBackend backend) FL_NO_EXCEPT
Compute the RX edge-buffer capacity for a validation frame.
back_insert_iterator< Container > back_inserter(Container &c) FL_NO_EXCEPT
Helper function to create a back_insert_iterator.
u8 getLogLevel() FL_NO_EXCEPT
Get the current global log level.
ClocklessEncoder
Identifies which encoder to use for clockless chipsets in the Channel API.
@ CLOCKLESS_ENCODER_UCS7604_8BIT
UCS7604 8-bit 800KHz.
@ CLOCKLESS_ENCODER_UCS7604_16BIT
UCS7604 16-bit 800KHz.
@ CLOCKLESS_ENCODER_UCS7604_16BIT_1600
UCS7604 16-bit 1600KHz.
void delay(u32 ms, bool run_async=true) FL_NO_EXCEPT
Public delay wrapper that keeps bare Arduino delay() preferred after using fl::delay; while still all...
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode) FL_NO_EXCEPT
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
constexpr u32 gamma(float g) FL_NO_EXCEPT
FASTLED_FORCE_INLINE int strcmp(const char *s1, const char *s2) FL_NO_EXCEPT
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.
ChipsetTiming4Phase make4PhaseTiming(const ChipsetTiming &timing_3phase, u32 tolerance_ns) FL_NO_EXCEPT
Create 4-phase RX timing from 3-phase chipset timing with tolerance.
constexpr u32 kMaxUartBaudRate
Maximum UART baud rate supported by ESP32 variants.
FASTLED_FORCE_INLINE void * memset(void *s, int c, size_t n) FL_NO_EXCEPT
@ PIO
RP2040/RP2350 PIO receive backend.
@ FLEXIO
Teensy 4.x-only FlexIO capture backend (FLEXIO1 — FLEXIO2 is owned by the WS2812 TX driver)....
@ PLATFORM_DEFAULT
Use the recommended backend for the active platform (RMT on ESP32; FlexPWM on Teensy 4....
@ ISR
Platform-neutral interrupt-driven edge capture backend when available.
constexpr size_t kRpPioRxEdgeCapacity
Phase slots in the shared capture pool.
@ FL_LOG_LEVEL_WARN
Errors and warnings.
expected< T, E > result
Alias for expected (Rust-style naming)
const char * toString(RxBackend backend) FL_NO_EXCEPT
UCS7604Mode
UCS7604 protocol configuration modes.
@ UCS7604_MODE_8BIT_800KHZ
@ UCS7604_MODE_16BIT_1600KHZ
@ UCS7604_MODE_16BIT_800KHZ
FL_OPTIMIZE_FUNCTION bool canUseWave3(const ChipsetTiming &timing) FL_NO_EXCEPT
Check if a chipset timing is eligible for wave3 encoding.
void encodeUCS7604(PixelIterator &pixel_iter, size_t num_leds, OutputIterator out, UCS7604Mode mode, const UCS7604CurrentControl ¤t, bool is_rgbw, const Gamma8 *gamma=nullptr, bool wide_source=false) FL_NO_EXCEPT
Encode complete UCS7604 frame (preamble + padding + pixel data)
@ SUCCESS
Operation completed successfully.
ChipsetTiming uartWireTiming(const ChipsetTimingConfig &timing, u32 max_baud_rate) FL_NO_EXCEPT
The wire timing the UART encoder actually produces for a chipset.
u32 T2
Additional high time for bit 1 (nanoseconds)
u32 T3
Low tail duration (nanoseconds)
u32 T1
High time for bit 0 (nanoseconds)
4-phase RX timing thresholds for chipset detection
Test context for detailed error reporting Aggregates all test configuration parameters for error mess...
Primary template — intentionally undefined.
Generic chipset timing entry Provides T1, T2, T3 timing parameters in nanoseconds for any LED protoco...
Low level pixel data writing class.
fl::PixelIterator PixelIterator
static ColorAdjustment noAdjustment() FL_NO_EXCEPT
the per-channel scale values premixed with brightness.
static Rgbw value() FL_NO_EXCEPT
static Rgbw value() FL_NO_EXCEPT
const fl::ChipsetTimingConfig & timing
Chipset timing configuration to test.
fl::RxDeviceType rx_type
RX device type (RMT or ISR)
const char * timing_name
Timing name for logging (e.g., "WS2812B-V5")
const char * driver_name
Driver name for logging (e.g., "RMT", "SPI", "PARLIO")
int base_strip_size
Base strip size (10 or 300 LEDs)
bool legacy_rgbw
Enable RGBW on legacy controllers.
fl::span< fl::ChannelConfig > tx_configs
TX channel configurations to test (mutable for LED manipulation)
fl::ClocklessEncoder encoder
Encoder selector (peer of timing; see issue #2467)
fl::shared_ptr< fl::RxChannel > rx_channel
RX channel for loopback capture (created in .ino, passed in)
fl::span< uint8_t > rx_buffer
Buffer to store received bytes.
uint32_t max_power_mw
Power budget for FastLED.setMaxPowerInMilliWatts(); 0 = unlimited.
fl::span< const LegacyClocklessChipset > legacy_chipsets
Optional per-lane legacy templates.
Configuration for driver-agnostic autoresearch testing Contains all input parameters needed for autor...
@ Green
<div style='background:#008000;width:4em;height:4em;'></div>
@ Red
<div style='background:#FF0000;width:4em;height:4em;'></div>
@ Blue
<div style='background:#0000FF;width:4em;height:4em;'></div>
@ White
<div style='background:#FFFFFF;width:4em;height:4em;'></div>
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Configuration for a single LED channel.
u32 t1_ns
T0H: High time for bit 0 (nanoseconds)
u32 t2_ns
T1H-T0H: Additional high time for bit 1 (nanoseconds)
u32 reset_us
Reset/latch time (microseconds)
const char * name
Human-readable chipset name.
u32 t3_ns
T0L: Low tail duration (nanoseconds)
Runtime bit-period timing for a clockless chipset.
Clockless chipset configuration (single data pin)
size_t offset
Starting edge index.
size_t count
Number of edges to extract.
Edge range specification for getRawEdgeTimes() debugging.
LED error information for a single run.
bool print_per_led_errors
Print every LED error (default: false)
int max_errors_per_run
Max errors to store per run (default: 5)
bool print_all_runs
Print all run results (default: only errors)
int num_runs
Number of runs to execute.
Multi-run test configuration.
int captureWaitResult
RxWaitResult value, or -1 before wait.
int decodeOutputCapacity
Output span size passed to decode()
int rawEdgesAfterWait
Raw edges visible after RX wait/decode.
int decodeError
DecodeError value, or -1 when decode succeeded/not run.
fl::string rawEdgeSample
Compact first-edge sample for failures.
fl::string rxBeginError
Machine-readable reason when RX begin() fails.
int decodeBytes
Bytes reported directly by decode()
int rpPioGpioTransitions
CPU-observed RX-pin transitions during RP PIO TX.
int decodeOk
1 if RX decode returned success, 0 on error, -1 before decode
Single run result with error tracking.
UCS7604 current control structure with 4-bit fields for each channel.
Configuration for ISR attachment.
bool is_valid() const FL_NO_EXCEPT
Opaque handle to an attached ISR.
Platform-neutral UART wave4/wave5 encoder API.