14#if !defined(FASTLED_AUTORESEARCH_LOW_MEMORY) && !FL_PLATFORM_HAS_LARGE_MEMORY
15 #define FASTLED_AUTORESEARCH_LOW_MEMORY 1
18#if defined(FASTLED_AUTORESEARCH_LOW_MEMORY) && FASTLED_AUTORESEARCH_LOW_MEMORY
148#define FASTLED_LOG_PARLIO_ASYNC_ENABLED
238#if defined(FL_IS_ESP_32S3) || defined(FL_IS_ESP_32C3) || defined(FL_IS_ESP_32C6) || defined(FL_IS_ESP_32H2) || defined(CONFIG_IDF_TARGET_ESP32P4)
261#define PIN_TX g_autoresearch_state->pin_tx
262#define PIN_RX g_autoresearch_state->pin_rx
264#define CHIPSET WS2812B
265#define COLOR_ORDER RGB
270#if defined(FL_IS_TEENSY_4X) || defined(FL_IS_ESP_32C6) || defined(FL_IS_ESP_32H2) || defined(FL_IS_ESP_32C5)
295#if defined(FL_IS_ESP32) && !defined(FL_IS_ESP_32S2)
296 Serial.setTxBufferSize(4096);
317#if defined(FL_IS_TEENSY_4X) && defined(__IMXRT1062__)
335extern "C" FLASHMEM
void startup_early_hook(
void) {
339 CCM_CCGR5 |= CCM_CCGR5_WDOG3(3);
342 __asm__
volatile (
"dsb" :::
"memory");
343 __asm__
volatile (
"isb" :::
"memory");
346 WDOG3_CNT = 0xD928C520u;
352 volatile uint32_t spin = 0;
353 while (!(WDOG3_CS & WDOG_CS_ULK)) {
354 if (++spin > 200000u)
break;
361 WDOG3_TOVAL = 0xFFFFu;
363 WDOG3_CS = WDOG_CS_CMD32EN | WDOG_CS_UPDATE | WDOG_CS_CLK(1);
367 volatile uint32_t spin = 0;
368 while (!(WDOG3_CS & WDOG_CS_RCS)) {
369 if (++spin > 200000u)
break;
380#if defined(ARDUINO_USB_CDC_ON_BOOT) && ARDUINO_USB_CDC_ON_BOOT
389 uint32_t serial_wait_start = millis();
392 FL_WARN(
"[SETUP] AutoResearch sketch starting - serial output active");
414 const char* loop_back_mode =
PIN_TX ==
PIN_RX ?
"INTERNAL" :
"JUMPER WIRE";
418 ss <<
"\n╔════════════════════════════════════════════════════════════════╗\n";
419 ss <<
"║ FastLED AutoResearch - Test Matrix Configuration ║\n";
420 ss <<
"╚════════════════════════════════════════════════════════════════╝\n";
423 ss <<
"\n[PLATFORM]\n";
427 ss <<
"\n[HARDWARE]\n";
428 ss <<
" TX Pin: " <<
PIN_TX <<
"\n";
429 ss <<
" RX Pin: " <<
PIN_RX <<
"\n";
431 ss <<
" Loopback Mode: " << loop_back_mode <<
"\n";
432 ss <<
" Color Order: RGB\n";
447 ss <<
"\n[RX SETUP] Creating RX channel for LED autoresearch\n";
448 ss <<
"[RX CREATE] Creating RX channel on PIN " <<
PIN_RX
449 <<
" (" << (40000000 / 1000000) <<
"MHz, " <<
RX_BUFFER_SIZE <<
" symbols)";
456 ss <<
"[RX SETUP]: Failed to create RX channel\n";
457 ss <<
"[RX SETUP]: Check that RMT peripheral is available and not in use";
459 FL_ERROR(
"Sanity check failed - RX channel creation failed");
464 ss <<
"[RX CREATE] ✓ RX channel created successfully (will be initialized with config in begin())\n";
465 ss <<
"[RX SETUP] ✓ RX channel ready for LED autoresearch";
479 ss <<
"\n[REMOTE RPC] Registering JSON RPC functions for dynamic control";
485 FL_PRINT(
"[REMOTE RPC] ✓ RPC system initialized (testGpioConnection available)");
490 FL_PRINT(
"[ASYNC] Setting up JSON-RPC async task (10ms interval)");
492 FL_PRINT(
"[ASYNC] ✓ JSON-RPC task registered with scheduler");
502 ss <<
"\n[GPIO BASELINE TEST] Testing GPIO " <<
PIN_TX <<
" → GPIO " <<
PIN_RX <<
" connectivity";
507 FL_WARN(
"[GPIO BASELINE TEST] Deferred to loop() - waiting for RPC start signal");
517 ss <<
"\n[DRIVER DISCOVERY]\n";
522 <<
", enabled: " << (
g_autoresearch_state->drivers_available[i].enabled ?
"yes" :
"no") <<
")\n";
531 readyData.
set(
"ready",
true);
532 readyData.
set(
"setupTimeMs",
static_cast<int64_t
>(millis()));
534 readyData.
set(
"pinTx",
static_cast<int64_t
>(
PIN_TX));
535 readyData.
set(
"pinRx",
static_cast<int64_t
>(
PIN_RX));
539 FL_PRINT(
"\n[SETUP COMPLETE] AutoResearch ready - awaiting JSON-RPC commands");
566 for (
int i = 0; i < 100; i++) {
580 FL_WARN(
"[deliberateHang] entering forced-hang loop NOW");
586#if !defined(FL_IS_STUB) && !defined(FL_IS_WASM)
597 FastLED.watchdog().markCleanShutdown();
603 if (millis() > 500) {
606 FL_PRINT(
"\n[GPIO BASELINE TEST] Testing GPIO " <<
PIN_TX <<
" → GPIO " <<
PIN_RX <<
" connectivity");
612 FL_WARN(
"[GPIO BASELINE TEST] FAILED - RX did not capture manual GPIO toggles");
613 FL_WARN(
"[GPIO BASELINE TEST] Possible causes:");
614 FL_WARN(
" 1. GPIO " <<
PIN_TX <<
" and GPIO " <<
PIN_RX <<
" are not physically connected");
615 FL_WARN(
" 2. RX channel initialization failed");
616 FL_WARN(
" 3. GPIO conflict with other peripherals (USB Serial JTAG on C6 uses certain GPIOs)");
617 FL_WARN(
"[GPIO BASELINE TEST] Continuing - JSON-RPC pin discovery/testing available");
619 FL_WARN(
"\n[GPIO BASELINE TEST] ✓ PASSED - GPIO path confirmed working");
620 FL_WARN(
"[GPIO BASELINE TEST] ✓ RX successfully captured manual GPIO toggles");
621 FL_WARN(
"[GPIO BASELINE TEST] ✓ Hardware connectivity verified (GPIO " <<
PIN_TX <<
" → GPIO " <<
PIN_RX <<
")");
627 static uint32_t last_status_ms = 0;
628 uint32_t now = millis();
629 if (now - last_status_ms >= 5000) {
631 status.
set(
"ready",
true);
632 status.
set(
"uptimeMs",
static_cast<int64_t
>(now));
634 last_status_ms = now;
fl::shared_ptr< AutoResearchState > g_autoresearch_state
constexpr int DEFAULT_PIN_RX
static constexpr uint32_t SERIAL_TIMEOUT_MS
constexpr int RX_BUFFER_SIZE
fl::Singleton< AutoResearchRemoteControl > RemoteControlSingleton
const fl::RxBackend RX_BACKEND
static constexpr uint32_t AUTORESEARCH_WATCHDOG_TIMEOUT_MS
constexpr int DEFAULT_PIN_TX
fl::vector_psram< uint8_t > g_rx_buffer_storage
void init_serial_buffers()
static constexpr uint32_t AUTORESEARCH_SERIAL_WAIT_MS
fl::shared_ptr< fl::RxChannel > createRxDevice(int pin)
bool testRxChannel(fl::shared_ptr< fl::RxChannel > rx_channel, int pin_tx, int pin_rx, uint32_t hz, size_t buffer_size)
Test RX channel with manual GPIO toggle.
void autoResearchExpectedEngines()
AutoResearch that expected engines are available for this platform Prints ERROR if any expected engin...
void autoResearchLowMemoryLoop()
void autoResearchLowMemorySetup()
Full PARLIO encode bench for ESP32-P4 (post-byte-LUT, #2526 landed).
PARLIO ISR-streaming functional validation (#2548 deep-dive follow-up).
void printStreamRaw(const char *messageType, const fl::json &data)
Print JSONL stream message directly to Serial, bypassing fl::println.
Wave8 expansion micro-benchmark for #2526.
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Declaration of fl::enableAllDrivers() — enrolls every channel driver available on the current platfor...
void registerFunctions(fl::shared_ptr< AutoResearchState > state)
Register all RPC functions with shared autoresearch state.
static AutoResearchRemoteControl & instance() FL_NOEXCEPT
void set(const fl::string &key, const json &value) FL_NOEXCEPT
static json object() FL_NOEXCEPT
string str() const FL_NOEXCEPT
#define FL_PRINT(X)
Print without prefix (like FL_WARN but without "WARN: " prefix) Uses sstream for dynamic formatting (...
fl::task::Handle setupRpcAsyncTask(AutoResearchRemoteControl &remote_control, int interval_ms=10)
Setup async task for JSON-RPC processing.
constexpr int defaultTxPin()
void maybeRegisterStubAutorun(AutoResearchRemoteControl &, fl::shared_ptr< AutoResearchState > state)
On FL_IS_STUB: register a one-shot async task that drives autoresearch.
constexpr int defaultRxPin()
constexpr const char * chipName()
void run(fl::u32 microseconds, ExecFlags flags)
Run selected task subsystems.
void serial_begin(u32 baudRate)
@ PLATFORM_DEFAULT
Use the recommended backend for the active platform (RMT on ESP32; FlexPWM on Teensy 4....
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
const char * toString(RxDeviceType type) FL_NOEXCEPT
Convert RxDeviceType to human-readable string.
#define FL_WATCHDOG_AUTO(...)
Unified cross-platform Watchdog Timer API for FastLED.