474 {
476
477
479
480
481
483
484
485
486
487
488
490 remote.bind(
"echo", [](
int v) ->
int {
492 return v;
493 });
494
495#if defined(FL_IS_ARM_LPC_845) && defined(FASTLED_AUTORESEARCH_FAULT_TEST)
496 remote.bind(
"trigger_oom", []() ->
bool {
497
498
499
500 volatile char* const p = new char[16UL * 1024UL * 1024UL];
501 if (p == nullptr) {
502 triggerLowMemoryNullFault();
503 }
504 p[0] = 0x33;
505 triggerLowMemoryNullFault();
506 return false;
507 });
508 remote.bind(
"trigger_stackblow", []() ->
bool {
509 (void)recurseLowMemoryStackBlow(0);
510 triggerLowMemoryNullFault();
511 return false;
512 });
513#endif
514
515#if defined(FL_IS_ESP8266)
516 autoresearch::esp8266::bindEsp8266Benches(
remote);
517#endif
518
519#if defined(FASTLED_AUTORESEARCH_IEEE754_MODE)
525 response.set(
"tests_run",
static_cast<int64_t
>(r.tests_run));
526 response.set(
"tests_failed",
static_cast<int64_t
>(r.tests_failed));
527 response.set(
"first_failure", r.first_failure ? r.first_failure :
"");
528 response.set(
"expected_bits",
static_cast<int64_t
>(r.expected_bits));
529 response.set(
"actual_bits",
static_cast<int64_t
>(r.actual_bits));
531 });
532#endif
533
534#if defined(FL_IS_ARM_LPC) && !defined(FASTLED_AUTORESEARCH_IEEE754_MODE) && \
535 !defined(FASTLED_AUTORESEARCH_FAULT_TEST)
536#if defined(FL_IS_ARM_LPC_845)
537
538
539 remote.bind(
"findConnectedPins",
540 []() ->
fl::string {
return lowMemFindConnectedPins(); });
541#endif
542
543
544
545#if !defined(FASTLED_AUTORESEARCH_LPC_DMA_LOOPBACK)
546
547
548
549 remote.bind(
"pinToggleRx",
550 [](
int tx_pin,
int rx_pin,
int freq_hz,
int duration_ms) ->
fl::string {
551 if (tx_pin < 0 || rx_pin < 0 || freq_hz <= 0 || duration_ms <= 0) {
553 }
554 const fl::u32 expected_edges =
555 2u * static_cast<fl::u32>(freq_hz) *
556 static_cast<fl::u32>(duration_ms) / 1000u;
557
558
559
560
561
562 constexpr fl::u32 kLowMemEdgeBufSize = 64u;
563 fl::u32 cap = expected_edges + (expected_edges / 2u);
564 if (cap < 2u) cap = 2u;
565 if (cap > kLowMemEdgeBufSize) cap = kLowMemEdgeBufSize;
566
567
568
569
570
573
574 auto rx = fl::LpcSctRxChannel::create(rx_pin);
576
580 if (!rx->begin(cfg))
return fl::string(
"0,0,0,0,0,0,0");
581
582 const fl::u32 half_us = 500000u / static_cast<fl::u32>(freq_hz);
583 const fl::u32 cycles = static_cast<fl::u32>(freq_hz) *
584 static_cast<fl::u32>(duration_ms) / 1000u;
585
586
587
588
589
590
591
592
593
594 const fl::u32 ticks_per_us = F_CPU / 1000000u;
595 const fl::u32 half_ticks = half_us * ticks_per_us;
596 const fl::i32 poll_guard = static_cast<fl::i32>(6u * ticks_per_us);
597 LowMemTickClock clock;
598 fl::u32 deadline = clock.now();
599 for (fl::u32 i = 0; i < 2u * cycles; ++i) {
602 rx->pollOnce();
603 deadline += half_ticks;
604 for (;;) {
605 const fl::i32 left = static_cast<fl::i32>(deadline - clock.now());
606 if (left <= 0) break;
607 if (left > poll_guard) rx->pollOnce();
608 }
609 if ((i & 0xFFu) == 0u) {
611 }
612 }
613 rx->wait(1);
614
615
616
617
618
619 auto& edges_buf = autoresearch::low_memory::pinToggleState().edges;
620 const fl::size n_read = rx->getRawEdgeTimes(
622
623 LowMemPinTogglePeriodStats stats = computeLowMemPeriodStats(edges_buf, n_read);
624
626 const bool success = (stats.periods > 0);
627 s << (success ? 1 : 0) << ',' << static_cast<fl::u32>(n_read) << ','
628 << stats.periods << ',' << stats.mean_ns << ',' << stats.sigma_ns << ','
629 << stats.min_ns << ',' << stats.max_ns;
631 });
632#if defined(FL_IS_ARM_LPC_845) && defined(FASTLED_AUTORESEARCH_LPC_CORE_PULL_CHECK)
633
634
635
636
637
638 remote.bind(
"corePullCheck",
639 [](
int pin_a,
int pin_b,
int pin_c,
int pin_d) ->
fl::string {
641 const int pins[] = {pin_a, pin_b, pin_c, pin_d};
642 for (
int pin :
pins) {
643 if (pin >= 0) {
644 lowMemCorePullCheck(pin, out);
645 }
646 }
648 });
649#endif
650#endif
651
652#if defined(FASTLED_AUTORESEARCH_LPC_WS2812)
653
654 remote.bind(
"ws2812SctTest",
655 [](
int test_case,
int tx_pin,
int rx_pin,
int capture_ms) ->
fl::string {
656
657
658
659
660
661
662 if (test_case < 0 || test_case > 4 || tx_pin < 0 || tx_pin > 31 ||
663 rx_pin < 0 || rx_pin > 31 || tx_pin == rx_pin ||
667 }
668 int num_leds = 1;
669 switch (test_case) {
670 case 1: num_leds = 3; break;
671 case 4: num_leds = 100; break;
672 default: num_leds = 1; break;
673 }
674 const int expected_bytes = num_leds * 3;
675
676
679 f << "0," << test_case << ',' << num_leds << ',' << expected_bytes
680 << ",0,0,0,0,0,2";
682 };
683
684
685
687 for (int i = 0; i < num_leds; ++i) {
688 u8 r = 0,
g = 0, b = 0;
689 switch (test_case) {
690 case 0: r = 0xFF; break;
691 case 1: r = (i == 0) ? 0xFF : 0;
g = (i == 1) ? 0xFF : 0;
692 b = (i == 2) ? 0xFF : 0; break;
693 case 3: r =
g = b = 0xFF;
break;
694 case 4: r = (i % 3 == 0) ? 0xFF : 0;
g = (i % 3 == 1) ? 0xFF : 0;
695 b = (i % 3 == 2) ? 0xFF : 0; break;
696 default: break;
697 }
699 grb[i * 3 + 1] = r;
700 grb[i * 3 + 2] = b;
701 }
702 autoresearch::low_memory::Ws2812State& ws_state =
703 autoresearch::low_memory::ws2812State();
704
705
706
707
708
709
710
716 if (!frame || !tx.
canHandle(frame))
return setupFailed();
717
718
719 constexpr fl::u32 kTxDeadlineMs = 100u;
720 if (!tx.
waitForReady(kTxDeadlineMs))
return setupFailed();
721 const u8* expected_buf = frame->getData().data();
722
723 auto rx = fl::LpcSctRxChannel::create(rx_pin);
724 if (!rx) return setupFailed();
726 const fl::u32 expected_edges = (fl::u32)num_leds * 24u * 2u;
727 fl::u32 cap = expected_edges + (expected_edges / 2u);
728
729
730
731
732 constexpr fl::u32 kLowMemWs2812EdgeCapacity = 192u;
733 if (cap < 48u) cap = 48u;
734 if (cap > kLowMemWs2812EdgeCapacity) cap = kLowMemWs2812EdgeCapacity;
737 if (!rx->begin(cfg)) return setupFailed();
738
739
740
741
745 rx->wait(capture_ms);
746
747
748
750 fl::lpc::LpcUartDmaRuntime::releaseTxPin();
751 }
752
753 uint8_t* decoded_buf = ws_state.decoded;
754 for (int i = 0; i < expected_bytes; ++i) decoded_buf[i] = 0;
755
756
757
758
759
760 constexpr fl::u32 kWs2812DecodeToleranceNs = 200u;
764 kWs2812DecodeToleranceNs);
765
766 auto dec = rx->decode(timing,
fl::span<u8>(decoded_buf, expected_bytes));
767 const fl::u32 decoded_bytes =
dec.ok() ?
dec.value() : 0u;
768
769
770
771 fl::u32 matched = 0;
772 fl::u32 mismatched = 0;
773 for (fl::u32 i = 0; i < decoded_bytes && i < (fl::u32)expected_bytes; ++i) {
774 if (decoded_buf[i] == expected_buf[i]) ++matched;
775 else ++mismatched;
776 }
777
778
779
780 constexpr fl::size kLowMemWs2812ProbeSize = 64u;
782 fl::size edges_captured = 0;
783 for (fl::size n; (n = rx->getRawEdgeTimes(probe, edges_captured)) > 0;) {
784 edges_captured += n;
785 }
786
787
788
789
790 fl::u32 need = cap / 16u;
791 if (need > (fl::u32)expected_bytes) need = (fl::u32)expected_bytes;
793 tx_done && mismatched == 0 && need > 0 && matched >= need;
794
796 s << (
success ? 1 : 0) <<
',' << test_case <<
',' << num_leds <<
','
797 << expected_bytes << ',' << decoded_bytes << ','
798 << matched << ',' << mismatched << ','
799 << static_cast<fl::u32>(edges_captured) << ',' << cap << ','
800 << (tx_done ? 1 : 0);
802 });
803#endif
804
805
806
807
808
809
810#if defined(FL_IS_ARM_LPC_845) && defined(FASTLED_LPC_PWM_DMA)
811 autoresearch::pwm_dma_cl::bind(
remote);
812#endif
813
814
815
816
817#if defined(FL_IS_ARM_LPC_845) && defined(FASTLED_LPC_SPI_DMA)
818 autoresearch::dma_spi::bind(
remote);
819#endif
820
821
822
823
824#if defined(FL_IS_ARM_LPC_845) && FASTLED_AUTORESEARCH_LPC_UART_DMA
825 autoresearch::uart_dma::bind(
remote);
826#endif
827
828#endif
829}
fl::unique_ptr< fl::Remote > remote
static ChannelDataPtr create(const ChipsetVariant &chipset, fl::vector_psram< u8 > &&encodedData=fl::vector_psram< u8 >(), ChannelPixelFormat pixelFormat=ChannelPixelFormat::RGB) FL_NO_EXCEPT
Create channel transmission data (modern variant-based API)
virtual bool canHandle(const ChannelDataPtr &data) const FL_NO_EXCEPT=0
Check if this driver can handle the given channel data.
virtual void enqueue(ChannelDataPtr channelData) FL_NO_EXCEPT=0
Enqueue channel data for transmission.
virtual void show() FL_NO_EXCEPT=0
Trigger transmission of enqueued data.
virtual DriverState poll() FL_NO_EXCEPT=0
Query driver state and perform maintenance.
bool waitForReady(u32 timeoutMs=1000) FL_NO_EXCEPT
Wait for driver to become READY.
Minimal interface for LED channel transmission drivers.
JSON-RPC server with scheduling support.
static Watchdog & instance() FL_NO_EXCEPT
void begin(fl::u32 timeout_ms) FL_NO_EXCEPT
static json object() FL_NO_EXCEPT
string str() const FL_NO_EXCEPT
#define FL_WARN_LIT(LITERAL)
RemoteState & remoteState()
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
constexpr ChipsetTiming to_runtime_timing() FL_NO_EXCEPT
Convert enum-based timing type to runtime ChipsetTiming struct.
ChipsetTiming4Phase make4PhaseTiming(const ChipsetTiming &timing_3phase, u32 tolerance_ns) FL_NO_EXCEPT
Create 4-phase RX timing from 3-phase chipset timing with tolerance.
void serial_begin(u32 baudRate) FL_NO_EXCEPT
@ Low
Logic low (0V / GND)
@ High
Logic high (3.3V / 5V, platform-dependent)
fl::variant< ClocklessChipset, SpiChipsetConfig > ChipsetVariant
const char * pinProbeSkipReason(int pin) FL_NO_EXCEPT
Why a probe must not touch pin at all (no pinMode, read or write), or nullptr when it may.
constexpr ClocklessChipset makeClockless(int pin) FL_NO_EXCEPT
Build a ClocklessChipset from a compile-time TIMING trait.
void digitalWrite(int pin, PinValue val) FL_NO_EXCEPT
Write digital value to pin.
@ Output
Digital output (push-pull)
void pinMode(int pin, PinMode mode) FL_NO_EXCEPT
Set pin mode (input, output, pull-up, pull-down)
4-phase RX timing thresholds for chipset detection
Primary template — intentionally undefined.
Value state
Current driver state.
@ READY
Hardware idle; ready to accept new transmissions.
size_t buffer_size
Buffer size in symbols/edges (default: 512)
bool start_low
Pin idle state: true=LOW (WS2812B), false=HIGH (inverted)
Configuration for RX device initialization.