5#if FL_PLATFORM_HAS_LARGE_MEMORY
8#define DEBUG_PRINT(x) do {} while(0)
9#define DEBUG_PRINTLN(x) do {} while(0)
39#include "platforms/arm/teensy/teensy4_common/drivers/objectfled/objectfled_diagnostics.h"
40#include "platforms/arm/rp/is_rp.h"
41#if defined(FL_IS_TEENSY_4X)
42#include "platforms/arm/teensy/teensy4_common/rx_flexpwm_channel.h"
43#include "platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.h"
47#if defined(FL_IS_RP2040) || defined(FL_IS_RP2350)
48#include "platforms/arm/rp/rpcommon/rp_pio_tx_bus_traits.h"
49#include "platforms/arm/rp/rpcommon/rp_uart_bus_traits.h"
50#include "platforms/arm/rp/rpcommon/rx_pio_channel.h"
74 fl::shared_ptr<State> mState;
75 fl::task::Handle mTask;
76 bool mStarted =
false;
81 if (!mState) {
return false; }
82 fl::task::CoroutineConfig task;
83 task.
name =
"fl-core-load";
87 const auto state = mState;
96 state->passes.fetch_add(1);
115 fl::u32 passes() const
FL_NO_EXCEPT {
return mState ? mState->passes.load() : 0; }
116 fl::u32 maxPassUs() const
FL_NO_EXCEPT {
return mState ? mState->maxPassUs.load() : 0; }
129class StandingRxChannelSwap {
131 explicit StandingRxChannelSwap(AutoResearchState*
state)
132 : mState(
state), mReleased(false) {}
137 void release(fl::shared_ptr<fl::RxChannel>* alias) {
138 if (mReleased || mState ==
nullptr) {
141 if (alias !=
nullptr) {
144 mState->rx_channel.
reset();
148 ~StandingRxChannelSwap() {
149 if (!mReleased || mState ==
nullptr || mState->rx_factory ==
nullptr) {
155 mState->rx_channel = mState->rx_factory(mState->pin_rx);
158 StandingRxChannelSwap(
const StandingRxChannelSwap&) =
delete;
159 StandingRxChannelSwap& operator=(
const StandingRxChannelSwap&) =
delete;
162 AutoResearchState* mState;
166#if defined(FL_IS_RP2040) || defined(FL_IS_RP2350)
206 if (ucs7604ModeForEncoder(encoder, &mode)) {
216fl::size rpPioMaxLedsForWireBytes(fl::size wire_bytes,
219 if (ucs7604ModeForEncoder(encoder, &mode)) {
220 constexpr fl::size kPreambleLen = 15;
221 if (wire_bytes <= kPreambleLen) {
226 return wire_bytes / (
rgbw ? 4u : 3u);
234 const uint64_t payload_ns =
235 static_cast<uint64_t
>(max_leds) * 24ULL * bit_period_ns;
236 return static_cast<uint32_t>((payload_ns + 999ULL) / 1000ULL) +
242 for (fl::size i = 0; i < tx_configs.
size(); i++) {
245 if (count > max_leds) {
252class ScopedFastLedBrightness {
267bool contaminateTxMuxWithPwm(
int pin) {
268#if defined(FL_IS_TEENSY_4X)
269 analogWriteFrequency(pin, 1000.0f);
284fl::json probeStandardGpioPad(
int tx_pin,
int rx_pin) {
286 probe.
set(
"supported",
false);
287 probe.
set(
"txPin",
static_cast<int64_t
>(tx_pin));
288 probe.
set(
"rxPin",
static_cast<int64_t
>(rx_pin));
289#if !defined(FL_IS_TEENSY_4X)
290 probe.
set(
"message",
"Teensy 4.x only");
293 probe.
set(
"supported",
true);
294 if (tx_pin < 0 || tx_pin >= NUM_DIGITAL_PINS ||
295 rx_pin < 0 || rx_pin >= NUM_DIGITAL_PINS) {
296 probe.
set(
"success",
false);
297 probe.
set(
"error",
"InvalidPin");
301 volatile uint32_t* fast_output = portOutputRegister(tx_pin);
303 reinterpret_cast<uintptr_t>(fast_output) - 0x01E48000u);
304 volatile uint32_t* fast_mode = portModeRegister(tx_pin);
306 reinterpret_cast<uintptr_t>(fast_mode) - 0x01E48000u);
307 volatile uint32_t* tx_mux = portConfigRegister(tx_pin);
308 volatile uint32_t* tx_pad = portControlRegister(tx_pin);
309 volatile uint32_t* rx_mux = portConfigRegister(rx_pin);
310 volatile uint32_t* rx_pad = portControlRegister(rx_pin);
317 static_cast<uint8_t>((output_addr - gpio6_base) >> 14);
318 const uint8_t bit = digitalPinToBit(tx_pin);
320 probe.
set(
"txBit",
static_cast<int64_t
>(bit));
321 probe.
set(
"txMask",
static_cast<int64_t
>(mask));
322 probe.
set(
"txOffset",
static_cast<int64_t
>(
offset));
324 probe.
set(
"success",
false);
325 probe.
set(
"error",
"UnsupportedGpioBank");
332 const uint32_t saved_tx_mux = *tx_mux;
333 const uint32_t saved_tx_pad = *tx_pad;
334 const uint32_t saved_rx_mux = *rx_mux;
335 const uint32_t saved_rx_pad = *rx_pad;
336 const uint32_t saved_fast_mode = *fast_mode;
337 const uint32_t saved_standard_mode = *standard_mode;
338 const uint32_t saved_fast_out = *fast_output;
339 const uint32_t saved_standard_out = *standard_output;
344 CCM_CCGR1 |= CCM_CCGR1_GPIO1(CCM_CCGR_ON);
345 CCM_CCGR0 |= CCM_CCGR0_GPIO2(CCM_CCGR_ON);
346 CCM_CCGR2 |= CCM_CCGR2_GPIO3(CCM_CCGR_ON);
347 CCM_CCGR3 |= CCM_CCGR3_GPIO4(CCM_CCGR_ON);
351 *rx_pad = (5u << 3) | (3u << 6);
356 *tx_pad = (3u << 3) | (3u << 6);
358 *standard_mode |= mask;
360 *
reinterpret_cast<volatile uint32_t*
>(
361 reinterpret_cast<uintptr_t>(standard_output) + 0x88u) = mask;
363 const int rx_initial = digitalReadFast(rx_pin);
365 int rx_high_count = 0;
366 int rx_low_count = 0;
367 for (
int i = 0; i < 5; ++i) {
368 *
reinterpret_cast<volatile uint32_t*
>(
369 reinterpret_cast<uintptr_t>(standard_output) + 0x84u) = mask;
371 if (digitalReadFast(rx_pin) == HIGH) {
374 *
reinterpret_cast<volatile uint32_t*
>(
375 reinterpret_cast<uintptr_t>(standard_output) + 0x88u) = mask;
377 if (digitalReadFast(rx_pin) == LOW) {
382 probe.
set(
"standardGpioRxInitial",
383 rx_initial == HIGH ?
"HIGH" :
"LOW");
384 probe.
set(
"standardGpioRxHighCount",
static_cast<int64_t
>(rx_high_count));
385 probe.
set(
"standardGpioRxLowCount",
static_cast<int64_t
>(rx_low_count));
386 probe.
set(
"standardGpioConnected",
387 (rx_high_count == 5) && (rx_low_count == 5));
393 int fast_high_count = 0;
394 int fast_low_count = 0;
395 int fast_high_zero_delay = 0;
396 int fast_low_zero_delay = 0;
397 constexpr int kFastIters = 50;
398 for (
int i = 0; i < kFastIters; ++i) {
399 *
reinterpret_cast<volatile uint32_t*
>(
400 reinterpret_cast<uintptr_t>(standard_output) + 0x84u) = mask;
401 if (digitalReadFast(rx_pin) == HIGH) {
402 ++fast_high_zero_delay;
405 if (digitalReadFast(rx_pin) == HIGH) {
408 *
reinterpret_cast<volatile uint32_t*
>(
409 reinterpret_cast<uintptr_t>(standard_output) + 0x88u) = mask;
410 if (digitalReadFast(rx_pin) == LOW) {
411 ++fast_low_zero_delay;
414 if (digitalReadFast(rx_pin) == LOW) {
418 probe.
set(
"fastToggleHighSettled",
static_cast<int64_t
>(fast_high_count));
419 probe.
set(
"fastToggleLowSettled",
static_cast<int64_t
>(fast_low_count));
420 probe.
set(
"fastToggleHighZeroDelay",
421 static_cast<int64_t
>(fast_high_zero_delay));
422 probe.
set(
"fastToggleLowZeroDelay",
423 static_cast<int64_t
>(fast_low_zero_delay));
424 probe.
set(
"fastToggleIterations",
static_cast<int64_t
>(kFastIters));
427 if ((saved_fast_out & mask) != 0) {
428 *
reinterpret_cast<volatile uint32_t*
>(
429 reinterpret_cast<uintptr_t>(fast_output) + 0x84u) = mask;
431 *
reinterpret_cast<volatile uint32_t*
>(
432 reinterpret_cast<uintptr_t>(fast_output) + 0x88u) = mask;
434 if ((saved_standard_out & mask) != 0) {
435 *
reinterpret_cast<volatile uint32_t*
>(
436 reinterpret_cast<uintptr_t>(standard_output) + 0x84u) = mask;
438 *
reinterpret_cast<volatile uint32_t*
>(
439 reinterpret_cast<uintptr_t>(standard_output) + 0x88u) = mask;
441 *fast_mode = saved_fast_mode;
442 *standard_mode = saved_standard_mode;
444 *tx_pad = saved_tx_pad;
445 *tx_mux = saved_tx_mux;
446 *rx_pad = saved_rx_pad;
447 *rx_mux = saved_rx_mux;
449 probe.
set(
"success",
true);
458 uint32_t max_allowed_overhead_us,
463 metric.
set(
"requested",
true);
464 metric.
set(
"supported",
false);
465 metric.
set(
"driver", driver_name.
c_str());
467 if (iterations < 1) {
468 metric.
set(
"message",
"iterations must be >= 1");
471 if (tx_configs.
empty()) {
472 metric.
set(
"message",
"no channel configs");
475 for (fl::size i = 0; i < tx_configs.
size(); i++) {
476 if (tx_configs[i].isSpi()) {
477 metric.
set(
"message",
"clocked SPI timing metric is not supported");
484 for (fl::size i = 0; i < sample_configs.
size(); i++) {
486 sample_configs[i].getDataPin(),
488 sample_configs[i].mLeds,
489 sample_configs[i].rgb_order);
493 metric.
set(
"message",
"failed to create channel");
499 ScopedFastLedBrightness scoped_brightness(255);
500 for (fl::size lane = 0; lane < sample_configs.
size(); lane++) {
502 sample_configs[lane].mLeds.size(),
508 metric.
set(
"message",
"warmup wait timeout");
514 expectedClocklessWireUs(timing, maxLaneLeds(sample_configs));
519 uint32_t min_total_us = 0xFFFFFFFFu;
521 uint32_t min_overhead_us = 0xFFFFFFFFu;
523 uint64_t sum_show_us = 0;
524 uint64_t sum_wait_us = 0;
525 uint64_t sum_total_us = 0;
526 uint64_t sum_overhead_us = 0;
531 for (fl::size lane = 0; lane < sample_configs.
size(); lane++) {
536 sample_configs[lane].mLeds.size(),
543 const bool ok =
FastLED.wait(1000);
554 total_us > expected_wire_us ? total_us - expected_wire_us : 0;
556 if (show_us < min_show_us) min_show_us = show_us;
557 if (show_us > max_show_us) max_show_us = show_us;
558 if (wait_us < min_wait_us) min_wait_us = wait_us;
559 if (wait_us > max_wait_us) max_wait_us = wait_us;
560 if (total_us < min_total_us) min_total_us = total_us;
561 if (total_us > max_total_us) max_total_us = total_us;
562 if (overhead_us < min_overhead_us) min_overhead_us = overhead_us;
563 if (overhead_us > max_overhead_us) max_overhead_us = overhead_us;
565 sum_show_us += show_us;
566 sum_wait_us += wait_us;
567 sum_total_us += total_us;
568 sum_overhead_us += overhead_us;
574 metric.
set(
"supported",
true);
575 metric.
set(
"samples",
static_cast<int64_t
>(samples));
576 metric.
set(
"iterations",
static_cast<int64_t
>(iterations));
577 metric.
set(
"expected_wire_us",
static_cast<int64_t
>(expected_wire_us));
578 metric.
set(
"max_allowed_overhead_us",
579 static_cast<int64_t
>(max_allowed_overhead_us));
582 metric.
set(
"passed",
false);
583 metric.
set(
"message", timed_out ?
"timing wait timeout" :
"no samples");
587 metric.
set(
"min_show_us",
static_cast<int64_t
>(min_show_us));
588 metric.
set(
"max_show_us",
static_cast<int64_t
>(max_show_us));
589 metric.
set(
"avg_show_us",
590 static_cast<int64_t
>(sum_show_us /
static_cast<uint64_t
>(samples)));
591 metric.
set(
"min_wait_us",
static_cast<int64_t
>(min_wait_us));
592 metric.
set(
"max_wait_us",
static_cast<int64_t
>(max_wait_us));
593 metric.
set(
"avg_wait_us",
594 static_cast<int64_t
>(sum_wait_us /
static_cast<uint64_t
>(samples)));
595 metric.
set(
"min_total_us",
static_cast<int64_t
>(min_total_us));
596 metric.
set(
"max_total_us",
static_cast<int64_t
>(max_total_us));
597 metric.
set(
"avg_total_us",
598 static_cast<int64_t
>(sum_total_us /
static_cast<uint64_t
>(samples)));
599 metric.
set(
"min_overhead_us",
static_cast<int64_t
>(min_overhead_us));
600 metric.
set(
"max_overhead_us",
static_cast<int64_t
>(max_overhead_us));
601 metric.
set(
"avg_overhead_us",
602 static_cast<int64_t
>(sum_overhead_us /
static_cast<uint64_t
>(samples)));
604 out_passed = !
timed_out && max_overhead_us <= max_allowed_overhead_us;
605 metric.
set(
"passed", out_passed);
607 metric.
set(
"message",
"timing wait timeout");
609 metric.
set(
"message", out_passed ?
"tight timing within budget"
610 :
"tight timing exceeded budget");
625 if (!
args.is_object()) {
627 response.set(
"error",
"InvalidArgs");
628 response.set(
"message",
"Expected {driver, laneSizes, pattern?, iterations?, pinTx?, pinRx?, timing?}");
632 fl::json config =
args;
637 if (!config.
contains(
"driver") || !config[
"driver"].is_string()) {
639 response.set(
"error",
"MissingDriver");
640 response.set(
"message",
"Required field 'driver' (string) missing");
643 fl::string driver_name = config[
"driver"].
as_string().value();
644 const bool is_object_fled_driver = (driver_name ==
"OBJECT_FLED");
647 bool driver_found =
false;
648 for (fl::size i = 0; i <
mState->drivers_available.size(); i++) {
649 if (
mState->drivers_available[i].name == driver_name) {
656 response.set(
"error",
"UnknownDriver");
658 msg <<
"Driver '" << driver_name.
c_str() <<
"' not available";
664 if (!config.
contains(
"laneSizes") || !config[
"laneSizes"].is_array()) {
666 response.set(
"error",
"MissingLaneSizes");
667 response.set(
"message",
"Required field 'laneSizes' (array) missing");
671 fl::json lane_sizes_json = config[
"laneSizes"];
672 if (lane_sizes_json.
size() == 0 || lane_sizes_json.
size() > 16) {
674 response.set(
"error",
"InvalidLaneCount");
675 response.set(
"message",
"laneSizes must have 1-16 elements");
679 fl::vector<int> lane_sizes;
685 const int max_leds_per_lane =
mState->rx_buffer.size() / 32;
686 for (fl::size i = 0; i < lane_sizes_json.
size(); i++) {
687 if (!lane_sizes_json[i].is_int()) {
689 response.set(
"error",
"InvalidLaneSizeType");
691 msg <<
"laneSizes[" << i <<
"] must be integer";
695 int size =
static_cast<int>(lane_sizes_json[i].
as_int().value());
698 response.set(
"error",
"InvalidLaneSize");
700 msg <<
"laneSizes[" << i <<
"] = " << size <<
" must be > 0";
704 if (size > max_leds_per_lane) {
706 response.set(
"error",
"LaneSizeTooLarge");
708 msg <<
"laneSizes[" << i <<
"] = " << size <<
" exceeds max " << max_leds_per_lane;
718 fl::string pattern =
"MSB_LSB_A";
719 if (config.
contains(
"pattern") && config[
"pattern"].is_string()) {
720 pattern = config[
"pattern"].
as_string().value();
725 if (config.
contains(
"iterations") && config[
"iterations"].is_int()) {
726 iterations =
static_cast<int>(config[
"iterations"].
as_int().value());
727 if (iterations < 1) {
729 response.set(
"error",
"InvalidIterations");
730 response.set(
"message",
"iterations must be >= 1");
741 if (config.
contains(
"frameCount") && config[
"frameCount"].is_int()) {
742 frame_count =
static_cast<int>(config[
"frameCount"].
as_int().value());
743 if (frame_count < 1 || frame_count > 16) {
745 response.set(
"error",
"InvalidFrameCount");
746 response.set(
"message",
"frameCount must be in [1, 16]");
756 if (config.
contains(
"maxPowerMw")) {
757 if (!config[
"maxPowerMw"].is_int() ||
758 config[
"maxPowerMw"].as_int().value() < 0 ||
759 config[
"maxPowerMw"].as_int().value() > 10000000) {
761 response.set(
"error",
"InvalidMaxPowerMw");
762 response.set(
"message",
"maxPowerMw must be an integer in [0, 10000000]");
765 max_power_mw =
static_cast<uint32_t>(config[
"maxPowerMw"].
as_int().value());
769 int pin_tx =
mState->pin_tx;
770 if (config.
contains(
"pinTx") && config[
"pinTx"].is_int()) {
771 pin_tx =
static_cast<int>(config[
"pinTx"].
as_int().value());
772 if (pin_tx < 0 || pin_tx > 48) {
774 response.set(
"error",
"InvalidPinTx");
775 response.set(
"message",
"pinTx must be 0-48");
781 int pin_rx =
mState->pin_rx;
782 if (config.
contains(
"pinRx") && config[
"pinRx"].is_int()) {
783 pin_rx =
static_cast<int>(config[
"pinRx"].
as_int().value());
784 if (pin_rx < 0 || pin_rx > 48) {
786 response.set(
"error",
"InvalidPinRx");
787 response.set(
"message",
"pinRx must be 0-48");
792 fl::vector<int> lane_pins;
793 const bool explicit_lane_pins = config.
contains(
"lanePins");
794 if (explicit_lane_pins && (!config[
"lanePins"].is_array() ||
795 config[
"lanePins"].size() != lane_sizes.
size())) {
797 response.set(
"error",
"InvalidLanePins");
798 response.set(
"message",
"lanePins must contain one GPIO per lane");
801 for (fl::size i = 0; i < lane_sizes.
size(); ++i) {
802 const auto pin_value = explicit_lane_pins ? config[
"lanePins"][i] : fl::json(pin_tx +
static_cast<int>(i));
803 if (!pin_value.is_int()) {
805 response.set(
"error",
"InvalidLanePins");
808 const auto raw_pin = pin_value.as_int().value();
809 if (explicit_lane_pins && (raw_pin < 0 || raw_pin > 48)) {
811 response.set(
"error",
"InvalidLanePins");
814 const int pin =
static_cast<int>(raw_pin);
815 bool duplicate =
false;
816 for (
const int previous : lane_pins) { duplicate = duplicate || previous == pin; }
817 if (explicit_lane_pins && (pin == pin_rx ||
818 duplicate || (i == 0 && pin != pin_tx))) {
820 response.set(
"error",
"InvalidLanePins");
821 response.set(
"message",
"lanePins must be unique GPIOs 0-48 excluding RX, with lane 0 matching TX");
824 lane_pins.push_back(pin);
828 fl::string timing_name =
"WS2812B-V5";
829 if (config.
contains(
"timing") && config[
"timing"].is_string()) {
830 timing_name = config[
"timing"].
as_string().value();
834 bool use_legacy_api =
false;
835 if (config.
contains(
"useLegacyApi") && config[
"useLegacyApi"].is_bool()) {
836 use_legacy_api = config[
"useLegacyApi"].
as_bool().value();
839 bool legacy_rgbw =
false;
840 if (config.
contains(
"legacyRgbw")) {
841 if (!use_legacy_api) {
843 response.set(
"error",
"LegacyRgbwRequiresLegacyApi");
844 response.set(
"message",
"legacyRgbw requires useLegacyApi=true");
847 if (!config[
"legacyRgbw"].is_bool()) {
849 response.set(
"error",
"InvalidLegacyRgbw");
850 response.set(
"message",
"legacyRgbw must be a boolean");
853 legacy_rgbw = config[
"legacyRgbw"].
as_bool().value();
856 fl::vector<LegacyClocklessChipset> legacy_chipsets;
857 if (config.
contains(
"legacyChipsets") && !use_legacy_api) {
859 response.set(
"error",
"LegacyChipsetsRequireLegacyApi");
860 response.set(
"message",
"legacyChipsets requires useLegacyApi=true");
863 if (use_legacy_api) {
864 for (fl::size i = 0; i < lane_sizes.
size(); i++) {
867 if (config.
contains(
"legacyChipsets")) {
868 if (!config[
"legacyChipsets"].is_array()) {
870 response.set(
"error",
"InvalidLegacyChipsets");
871 response.set(
"message",
"legacyChipsets must be an array");
874 fl::json legacy_chipsets_json = config[
"legacyChipsets"];
875 if (legacy_chipsets_json.
size() != lane_sizes.
size()) {
877 response.set(
"error",
"InvalidLegacyChipsetCount");
878 response.set(
"message",
"legacyChipsets length must match laneSizes");
881 for (fl::size i = 0; i < legacy_chipsets_json.
size(); i++) {
882 if (!legacy_chipsets_json[i].is_string()) {
884 response.set(
"error",
"InvalidLegacyChipsetType");
885 response.set(
"message",
"legacyChipsets entries must be strings");
888 fl::string chipset_name =
889 legacy_chipsets_json[i].
as_string().value();
893 response.set(
"error",
"UnsupportedLegacyChipset");
896 "supported legacyChipsets: WS2812B, WS2814, WS2818, SK6812");
899 legacy_chipsets[i] = chipset;
905 const bool worker_core_test = config.
contains(
"workerCore");
906 if (worker_core_test) {
907 const fl::string requested = config[
"workerCore"] | fl::string(
"");
908 if (driver_name !=
"LCD_CLOCKLESS" ||
909 (requested !=
"auto" && requested !=
"0" && requested !=
"1" &&
910 requested !=
"any" && requested !=
"calling")) {
912 response.set(
"error",
"InvalidWorkerCore");
913 response.set(
"message",
"workerCore requires LCD_CLOCKLESS and auto, 0, 1, any or calling");
922 response.set(
"error",
"UnsupportedWorkerCoreLegacyApi");
923 response.set(
"message",
"Explicit worker core selection requires the Channels API");
926 bool plain_ws2812b = !legacy_rgbw;
927 for (
const auto chipset : legacy_chipsets) {
928 plain_ws2812b = plain_ws2812b &&
931 if (use_legacy_api && !plain_ws2812b) {
933 response.set(
"error",
"UnsupportedWorkerCoreLegacyChipset");
934 response.set(
"message",
"workerCore legacy validation supports plain WS2812B only");
939 response.set(
"error",
"WorkerCoreUnsupportedPlatform");
944 const char* legacy_driver_name =
nullptr;
945 if (use_legacy_api) {
947 if (legacy_driver_name !=
nullptr &&
948 driver_name != legacy_driver_name) {
950 response.set(
"error",
"LegacyDriverMismatch");
952 msg <<
"Legacy templates are compile-time bound to "
953 << legacy_driver_name <<
", but the request selected "
954 << driver_name.
c_str();
961 bool contaminate_tx_mux =
false;
962 if (config.
contains(
"contaminateTxMux") &&
963 config[
"contaminateTxMux"].is_bool()) {
964 contaminate_tx_mux = config[
"contaminateTxMux"].
as_bool().value();
968 bool measure_tight_timing =
false;
969 if (config.
contains(
"tightTiming") && config[
"tightTiming"].is_bool()) {
970 measure_tight_timing = config[
"tightTiming"].
as_bool().value();
973 int tight_timing_iterations = 8;
974 if (config.
contains(
"tightTimingIterations") &&
975 config[
"tightTimingIterations"].is_int()) {
976 tight_timing_iterations =
977 static_cast<int>(config[
"tightTimingIterations"].
as_int().value());
978 if (tight_timing_iterations < 1 || tight_timing_iterations > 64) {
980 response.set(
"error",
"InvalidTightTimingIterations");
981 response.set(
"message",
"tightTimingIterations must be in [1, 64]");
986 uint32_t tight_timing_max_overhead_us = 2000;
987 if (config.
contains(
"tightTimingMaxOverheadUs") &&
988 config[
"tightTimingMaxOverheadUs"].is_int()) {
989 const int max_overhead =
990 static_cast<int>(config[
"tightTimingMaxOverheadUs"].
as_int().value());
991 if (max_overhead < 1) {
993 response.set(
"error",
"InvalidTightTimingMaxOverheadUs");
994 response.set(
"message",
"tightTimingMaxOverheadUs must be >= 1");
997 tight_timing_max_overhead_us =
static_cast<uint32_t>(max_overhead);
1004 if (use_legacy_api) {
1005 int max_pin = pin_tx;
1006 for (
const int pin : lane_pins) {
if (pin > max_pin) { max_pin = pin; } }
1007 const bool historical_pin_range = pin_tx >= 0 && max_pin <= 8;
1008#if AUTORESEARCH_LEGACY_SUPPORTS_PIN_22
1009 const bool current_loopback_pin =
1010 lane_sizes.
size() == 1 && pin_tx == 22;
1012 const bool current_loopback_pin =
false;
1014 if (!historical_pin_range && !current_loopback_pin) {
1016 response.set(
"error",
"LegacyApiPinRange");
1018 msg <<
"Legacy template API supports pins 0-8";
1019#if AUTORESEARCH_LEGACY_SUPPORTS_PIN_22
1020 msg <<
", plus single-lane pin 22 for current ObjectFLED loopback";
1022 msg <<
", got pins " << pin_tx <<
"-" << max_pin;
1033 fl::json standard_gpio_pad_probe;
1034 if (is_object_fled_driver) {
1035 standard_gpio_pad_probe = probeStandardGpioPad(pin_tx, pin_rx);
1038 if (contaminate_tx_mux) {
1039 if (!is_object_fled_driver) {
1041 response.set(
"error",
"MuxContaminationDriverUnsupported");
1042 response.set(
"message",
"contaminateTxMux is only supported for OBJECT_FLED");
1045 if (!contaminateTxMuxWithPwm(pin_tx)) {
1047 response.set(
"error",
"MuxContaminationUnsupported");
1048 response.set(
"message",
"contaminateTxMux requires Teensy 4.x analogWriteFrequency support");
1056 response.set(
"error",
"DriverSetupFailed");
1058 msg <<
"Failed to set " << driver_name.
c_str() <<
" as exclusive driver";
1069 fl::ChipsetTimingConfig resolved_timing;
1071 if (use_legacy_api) {
1073 if (!legacy_chipsets.empty()) {
1074 first_chipset = legacy_chipsets[0];
1090 }
else if (timing_name ==
"UCS7604-800KHZ") {
1093 }
else if (timing_name ==
"WS2811-400KHZ") {
1102 }
else if (timing_name ==
"SK6812") {
1107 }
else if (timing_name ==
"WS2818") {
1114 fl::NamedTimingConfig timing_config(resolved_timing, timing_name.
c_str(), resolved_encoder);
1117 fl::vector<fl::unique_ptr<fl::vector<CRGB>>> led_arrays;
1118 fl::vector<fl::ChannelConfig> tx_configs;
1122 bool is_spi_chipset_driver = (driver_name ==
"LCD_SPI" ||
1123 driver_name ==
"I2S_SPI" ||
1124 driver_name ==
"SPI_UNIFIED");
1126 for (fl::size i = 0; i < lane_sizes.
size(); i++) {
1128 if (is_spi_chipset_driver) {
1134 int data_pin = pin_tx;
1135 int clock_pin = pin_rx + 1;
1142 fl::span<CRGB>(
leds->data(),
leds->size()),
1148 timing_config.timing,
1149 fl::span<CRGB>(
leds->data(),
leds->size()),
1153 if (worker_core_test) {
1155 tx_configs.
back().options.mWorker.core = worker_core;
1162 fl::shared_ptr<fl::RxChannel> rx_channel_to_use =
mState->rx_channel;
1168 bool have_backend_override =
false;
1169 if (config.
contains(
"rxBackend") && config[
"rxBackend"].is_string()) {
1170 fl::string rb = config[
"rxBackend"].
as_string().value();
1171 if (rb ==
"RMT") { rx_backend_override =
fl::RxBackend::RMT; have_backend_override =
true; }
1172 else if (rb ==
"ISR") { rx_backend_override =
fl::RxBackend::ISR; have_backend_override =
true; }
1173 else if (rb ==
"I2S_RX") { rx_backend_override =
fl::RxBackend::I2S_RX; have_backend_override =
true; }
1174 else if (rb !=
"PLATFORM_DEFAULT") {
1176 response.set(
"error",
"UnknownRxBackend");
1177 response.set(
"message",
"rxBackend must be PLATFORM_DEFAULT, RMT, ISR or I2S_RX");
1186#if defined(FL_IS_ESP_32C6)
1187 constexpr bool is_esp32_c6 =
true;
1189 constexpr bool is_esp32_c6 =
false;
1192 rx_backend_override, have_backend_override,
1193 driver_name ==
"PARLIO", is_esp32_c6);
1195 have_backend_override =
true;
1215 StandingRxChannelSwap standing_rx_swap(
mState.get());
1216 if (have_backend_override) {
1217 standing_rx_swap.release(&rx_channel_to_use);
1218 fl::RxChannelConfig rx_cfg(pin_rx, rx_backend_override);
1220 if (!rx_channel_to_use) {
1222 response.set(
"error",
"RxChannelCreationFailed");
1223 response.set(
"message",
"Failed to create RX channel for requested rxBackend");
1226 }
else if (pin_rx !=
mState->pin_rx &&
mState->rx_factory) {
1227 standing_rx_swap.release(&rx_channel_to_use);
1228 rx_channel_to_use =
mState->rx_factory(pin_rx);
1229 if (!rx_channel_to_use) {
1231 response.set(
"error",
"RxChannelCreationFailed");
1232 response.set(
"message",
"Failed to create RX channel on custom pin");
1237#if defined(FL_IS_RP2040) || defined(FL_IS_RP2350)
1254 rx_channel_to_use ? rx_channel_to_use->backend()
1265 constexpr fl::u32 kArmingLeadInNs = 64000;
1267 const fl::u32 bit_period_ns =
1273 fl::RxChannelConfig(pin_rx).signal_range_max_ns,
1274 kArmingLeadInNs, bit_period_ns);
1276 for (fl::size i = 0; i < lane_sizes.
size(); i++) {
1277 const fl::size
leds =
static_cast<fl::size
>(lane_sizes[i]);
1281 const bool lane_rgbw =
1283 (i < legacy_chipsets.size() &&
1285 const fl::size wire_bytes =
1286 rpPioWireFrameBytes(
leds, timing_config.encoder, lane_rgbw);
1287 if (wire_bytes > max_wire_bytes) {
1289 response.set(
"error",
"LaneSizeTooLarge");
1291 msg <<
"laneSizes[" << i <<
"] = " << lane_sizes[i] <<
" puts "
1292 <<
static_cast<int>(wire_bytes) <<
" bytes on the wire at "
1293 << timing_name.
c_str() <<
"; PIO RX capture holds "
1294 <<
static_cast<int>(max_wire_bytes) <<
" ("
1295 <<
static_cast<int>(
1296 rpPioMaxLedsForWireBytes(max_wire_bytes,
1297 timing_config.encoder,
1308 fl::AutoResearchConfig autoresearch_config(
1309 timing_config.timing,
1312 driver_name.
c_str(),
1317 timing_config.encoder,
1318 fl::span<const LegacyClocklessChipset>(legacy_chipsets),
1321 autoresearch_config.max_power_mw = max_power_mw;
1322 bool legacy_non_ws2812b =
false;
1323 for (
const auto chipset : legacy_chipsets) {
1325 legacy_non_ws2812b =
true;
1328 if (max_power_mw != 0 &&
1329 (lane_sizes.
size() != 1 || legacy_rgbw || legacy_non_ws2812b ||
1330 is_spi_chipset_driver ||
1333 response.set(
"error",
"MaxPowerUnsupportedConfig");
1335 "maxPowerMw needs one RGB clockless lane (WS2812B for the legacy API)");
1342 bool passed =
false;
1344 fl::vector<fl::RunResult> run_results;
1345 WorkerCoreLoad worker_load;
1346 if (worker_core_test && !worker_load.start()) {
1348 response.set(
"error",
"WorkerCoreLoadStartFailed");
1352 bool tight_timing_passed =
true;
1365 fl::ScopedLogDisable quiet_logs;
1367 if (is_object_fled_driver) {
1368 fl::objectFledDiagnosticsReset();
1369 fl::objectFledDiagnosticsSetRxPin(pin_rx);
1372 if (use_legacy_api) {
1374 for (
int iter = 0; iter < iterations; iter++) {
1375 int iter_total = 0, iter_passed = 0;
1382 for (
int iter = 0; iter < iterations; iter++) {
1383 int iter_total = 0, iter_passed = 0;
1393 if (measure_tight_timing) {
1394 if (use_legacy_api) {
1395 tight_timing_passed =
false;
1396 tight_timing_response.
set(
"requested",
true);
1397 tight_timing_response.
set(
"supported",
false);
1398 tight_timing_response.
set(
"passed",
false);
1399 tight_timing_response.
set(
"driver", driver_name.
c_str());
1400 tight_timing_response.
set(
"message",
"legacy API timing metric is not supported");
1402 tight_timing_response = measureTightTiming(
1404 timing_config.timing,
1406 tight_timing_iterations,
1407 tight_timing_max_overhead_us,
1408 tight_timing_passed);
1410 bool tight_timing_supported =
false;
1411 if (tight_timing_response.
contains(
"supported") &&
1412 tight_timing_response[
"supported"].is_bool()) {
1413 tight_timing_supported =
1414 tight_timing_response[
"supported"].
as_bool().value();
1416 if (tight_timing_supported) {
1417 passed = passed && tight_timing_passed;
1422 int capture_evidence_bytes = 0;
1423 int capture_evidence_raw_edges = 0;
1424 for (fl::size ri = 0; ri < run_results.
size(); ri++) {
1425 const auto& rr = run_results[ri];
1426 if (rr.capturedBytes > 0) {
1427 capture_evidence_bytes += rr.capturedBytes;
1429 if (rr.rawEdgesAfterWait > capture_evidence_raw_edges) {
1430 capture_evidence_raw_edges = rr.rawEdgesAfterWait;
1436 response.set(
"heapBeforeInternal",
static_cast<int64_t
>(heap_before.free_sram));
1437 response.set(
"heapBeforePsram",
static_cast<int64_t
>(heap_before.free_psram));
1438 response.set(
"heapAfterInternal",
static_cast<int64_t
>(heap_after.free_sram));
1439 response.set(
"heapAfterPsram",
static_cast<int64_t
>(heap_after.free_psram));
1441 if (selected_driver) {
1442 const auto state = selected_driver->poll();
1448 if (worker_core_test) {
1450 if (!selected_driver) {
1453 const auto worker = selected_driver->workerDiagnostics();
1454 response.set(
"workerCore", worker.core);
1455 response.set(
"workerObservedCore", worker.observedCore);
1456 response.set(
"workerPriority", worker.priority);
1457 response.set(
"workerSubmittedChunks",
static_cast<int64_t
>(worker.submittedChunks));
1458 response.set(
"workerCompletedChunks",
static_cast<int64_t
>(worker.completedChunks));
1459 response.set(
"workerTotalChunks",
static_cast<int64_t
>(worker.totalChunks));
1460 response.set(
"workerMaxEncodeUs",
static_cast<int64_t
>(worker.maxEncodeUs));
1461 response.set(
"workerMaxSubmitUs",
static_cast<int64_t
>(worker.maxSubmitUs));
1462 response.set(
"workerStreamError", worker.streamError);
1464 response.set(
"competingTaskPasses",
static_cast<int64_t
>(worker_load.passes()));
1465 response.set(
"competingTaskMaxPassUs",
static_cast<int64_t
>(worker_load.maxPassUs()));
1471 response.set(
"captureEvidenceExpected",
true);
1472 response.set(
"captureEvidenceBytes",
1473 static_cast<int64_t
>(capture_evidence_bytes));
1474 response.set(
"captureEvidenceRawEdges",
1475 static_cast<int64_t
>(capture_evidence_raw_edges));
1476 response.set(
"duration_ms",
static_cast<int64_t
>(duration_ms));
1477 response.set(
"show_duration_ms",
static_cast<int64_t
>(show_duration_ms));
1479 response.set(
"requestedTxPin",
static_cast<int64_t
>(pin_tx));
1480 response.set(
"requestedRxPin",
static_cast<int64_t
>(pin_rx));
1481 response.set(
"actualTxPin",
static_cast<int64_t
>(pin_tx));
1482 response.set(
"actualRxPin",
static_cast<int64_t
>(
1483 rx_channel_to_use ? rx_channel_to_use->getPin() : pin_rx));
1484 fl::string capture_backend = rx_channel_to_use
1485 ? rx_channel_to_use->getEngineName()
1486 : fl::string(
"none");
1488 response.set(
"laneCount",
static_cast<int64_t
>(lane_sizes.
size()));
1490 for (
const auto& channel : tx_configs) {
1491 pins_response.
push_back(
static_cast<int64_t
>(channel.getDataPin()));
1493 response.set(
"lanePins", pins_response);
1494#if defined(FL_IS_RP2040) || defined(FL_IS_RP2350)
1495 if (driver_name ==
"UART0" || driver_name ==
"UART1") {
1496 auto& uart = driver_name ==
"UART0"
1497 ? fl::BusTraits<fl::Bus::UART, 0>::instance()
1498 : fl::BusTraits<fl::
Bus::
UART, 1>::instance();
1499 response.set(
"rpUartStartAttempted", uart.lastStartAttempted());
1500 response.set(
"rpUartStartSucceeded", uart.lastStartSucceeded());
1502 static_cast<int64_t
>(uart.lastEncodedSize()));
1504 static_cast<int64_t
>(uart.lastActualBaud()));
1505 response.set(
"rpUartLastError", uart.lastError().c_str());
1507 if (driver_name ==
"PIO0" || driver_name ==
"PIO1") {
1508 auto& rp_pio = driver_name ==
"PIO0"
1509 ? fl::BusTraits<fl::Bus::FLEX_IO, 0>::instance()
1510 : fl::BusTraits<fl::
Bus::
FLEX_IO, 1>::instance();
1511 response.set(
"rpPioActive", rp_pio.isActive());
1512 response.set(
"rpPioLastError", rp_pio.lastError().c_str());
1513 response.set(
"rpPioStartAttempted", rp_pio.lastStartAttempted());
1514 response.set(
"rpPioStartSucceeded", rp_pio.lastStartSucceeded());
1515 response.set(
"rpPioWordCount",
static_cast<int64_t
>(rp_pio.lastWordCount()));
1517 #if defined(FL_IS_RP2350)
1518 if (driver_name ==
"PIO2") {
1519 auto& rp_pio = fl::BusTraits<fl::Bus::FLEX_IO, 2>::instance();
1520 response.set(
"rpPioActive", rp_pio.isActive());
1521 response.set(
"rpPioLastError", rp_pio.lastError().c_str());
1522 response.set(
"rpPioStartAttempted", rp_pio.lastStartAttempted());
1523 response.set(
"rpPioStartSucceeded", rp_pio.lastStartSucceeded());
1524 response.set(
"rpPioWordCount",
static_cast<int64_t
>(rp_pio.lastWordCount()));
1530 for (
int size : lane_sizes) {
1531 sizes_response.
push_back(
static_cast<int64_t
>(size));
1533 response.set(
"laneSizes", sizes_response);
1535 response.set(
"useLegacyApi", use_legacy_api);
1536 if (use_legacy_api) {
1537 if (legacy_driver_name !=
nullptr) {
1538 response.set(
"legacyDriver", legacy_driver_name);
1540 response.set(
"legacyRgbw", legacy_rgbw);
1546 response.set(
"legacyChipsets", legacy_chipsets_response);
1548 response.set(
"frameCount",
static_cast<int64_t
>(frame_count));
1549 response.set(
"contaminateTxMux", contaminate_tx_mux);
1550 if (contaminate_tx_mux) {
1551 response.set(
"contaminateTxMuxPin",
static_cast<int64_t
>(pin_tx));
1553 if (measure_tight_timing) {
1554 response.set(
"tightTiming", tight_timing_response);
1556 if (is_object_fled_driver) {
1557 response.set(
"objectFledDiagnostics",
1558 fl::objectFledDiagnosticsToJson());
1559 response.set(
"standardGpioPadProbe", standard_gpio_pad_probe);
1561#if defined(FL_IS_TEENSY_4X)
1565 fl::json ts = fl::FlexPwmRxChannel::streamStatsToJson();
1566 fl::FlexIODiagnostics sd{};
1567 fl::flexio_read_diagnostics(&sd);
1568 ts.
set(
"txUnderruns",
static_cast<int64_t
>(sd.txUnderruns));
1569 ts.
set(
"txIsrMaxCycles",
static_cast<int64_t
>(sd.txIsrMaxCycles));
1570 ts.
set(
"txStreamedWords",
static_cast<int64_t
>(sd.txStreamedWords));
1580 const bool emit_flex_diagnostics = (driver_name ==
"OBJECT_FLED");
1581 if (emit_flex_diagnostics) {
1582 response.set(
"flexPwmRxDiagnostics",
1583 fl::FlexPwmRxChannel::diagnosticsToJson(pin_rx));
1585 if (emit_flex_diagnostics) {
1591 fl::FlexIODiagnostics fd{};
1592 fl::flexio_read_diagnostics(&fd);
1594 fj.
set(
"ctrl",
static_cast<int64_t
>(fd.ctrl));
1595 fj.
set(
"shiftstat",
static_cast<int64_t
>(fd.shiftstat));
1596 fj.
set(
"shifterr",
static_cast<int64_t
>(fd.shifterr));
1597 fj.
set(
"timstat",
static_cast<int64_t
>(fd.timstat));
1598 fj.
set(
"shiftsden",
static_cast<int64_t
>(fd.shiftsden));
1599 fj.
set(
"shiftctl0",
static_cast<int64_t
>(fd.shiftctl0));
1600 fj.
set(
"shiftcfg0",
static_cast<int64_t
>(fd.shiftcfg0));
1601 fj.
set(
"timctl0",
static_cast<int64_t
>(fd.timctl0));
1602 fj.
set(
"timcfg0",
static_cast<int64_t
>(fd.timcfg0));
1603 fj.
set(
"timcmp0",
static_cast<int64_t
>(fd.timcmp0));
1604 fj.
set(
"ccmCcgr3",
static_cast<int64_t
>(fd.ccm_ccgr3));
1605 fj.
set(
"ccmCscmr2",
static_cast<int64_t
>(fd.ccm_cscmr2));
1606 fj.
set(
"ccmCs1cdr",
static_cast<int64_t
>(fd.ccm_cs1cdr));
1607 fj.
set(
"muxRegValue",
static_cast<int64_t
>(fd.muxRegValue));
1608 fj.
set(
"padRegValue",
static_cast<int64_t
>(fd.padRegValue));
1609 fj.
set(
"tcdSaddr",
static_cast<int64_t
>(fd.tcd_saddr));
1610 fj.
set(
"tcdDaddr",
static_cast<int64_t
>(fd.tcd_daddr));
1611 fj.
set(
"tcdCiter",
static_cast<int64_t
>(fd.tcd_citer));
1612 fj.
set(
"tcdBiter",
static_cast<int64_t
>(fd.tcd_biter));
1613 fj.
set(
"tcdCsr",
static_cast<int64_t
>(fd.tcd_csr));
1614 fj.
set(
"initialized", fd.initialized);
1615 fj.
set(
"dmaComplete", fd.dmaComplete);
1616 fj.
set(
"txUnderruns",
static_cast<int64_t
>(fd.txUnderruns));
1617 fj.
set(
"txIsrMaxCycles",
static_cast<int64_t
>(fd.txIsrMaxCycles));
1618 response.set(
"flexIoDiagnostics", fj);
1627 const bool ws2814_legacy = use_legacy_api && !legacy_chipsets.empty() &&
1629 if (max_power_mw != 0 && !run_results.
empty()) {
1633 for (fl::size ri = 0; ri < run_results.
size(); ri++) {
1634 const auto& rr = run_results[ri];
1636 f.
set(
"passed", rr.passed);
1637 f.
set(
"expectedScale",
static_cast<int64_t
>(rr.expectedScale));
1638 f.
set(
"fullDemandMw",
static_cast<int64_t
>(rr.fullDemandMw));
1639 f.
set(
"baselineMw",
static_cast<int64_t
>(rr.baselineMw));
1640 f.
set(
"sumRaw",
static_cast<int64_t
>(rr.sumRaw));
1641 f.
set(
"sumWire",
static_cast<int64_t
>(rr.sumWire));
1642 f.
set(
"mismatchedBytes",
static_cast<int64_t
>(rr.mismatchedBytes));
1645 response.set(
"maxPowerMw",
static_cast<int64_t
>(max_power_mw));
1646 response.set(
"powerFrames", frames);
1648 if ((!passed || ws2814_legacy) && !run_results.
empty()) {
1650 for (fl::size ri = 0; ri < run_results.
size(); ri++) {
1651 const auto& rr = run_results[ri];
1652 if (rr.passed && !ws2814_legacy)
continue;
1654 pat.
set(
"runNumber",
static_cast<int64_t
>(rr.run_number));
1655 pat.
set(
"totalLeds",
static_cast<int64_t
>(rr.total_leds));
1656 pat.
set(
"totalBytes",
static_cast<int64_t
>(rr.totalBytes));
1657 pat.
set(
"passed", rr.passed);
1662 pat.
set(
"mismatchedLeds",
static_cast<int64_t
>(rr.mismatches));
1663 pat.
set(
"capturedBytes",
static_cast<int64_t
>(rr.capturedBytes));
1664 pat.
set(
"captureWaitResult",
static_cast<int64_t
>(rr.captureWaitResult));
1665 pat.
set(
"rawEdgesAfterWait",
static_cast<int64_t
>(rr.rawEdgesAfterWait));
1666 pat.
set(
"decodeOk",
static_cast<int64_t
>(rr.decodeOk));
1667 pat.
set(
"decodeError",
static_cast<int64_t
>(rr.decodeError));
1668 pat.
set(
"decodeBytes",
static_cast<int64_t
>(rr.decodeBytes));
1669 pat.
set(
"decodeOutputCapacity",
1670 static_cast<int64_t
>(rr.decodeOutputCapacity));
1671 if (rr.rpPioGpioTransitions >= 0) {
1672 pat.
set(
"rpPioGpioTransitions",
1673 static_cast<int64_t
>(rr.rpPioGpioTransitions));
1675 if (!rr.rxBeginError.empty()) {
1676 pat.
set(
"rxBeginError", rr.rxBeginError.c_str());
1678 if (!rr.rawEdgeSample.empty()) {
1679 pat.
set(
"rawEdgeSample", rr.rawEdgeSample.c_str());
1681 pat.
set(
"captureFailed", rr.captureFailed);
1682 pat.
set(
"mismatchedBytes",
static_cast<int64_t
>(rr.mismatchedBytes));
1683 pat.
set(
"lsbOnlyErrors",
static_cast<int64_t
>(rr.lsbOnlyErrors));
1686 constexpr fl::size kMaxSerializedErrors = 5;
1687 if (!rr.errors.empty()) {
1689 const fl::size errLimit = rr.errors.size() < kMaxSerializedErrors
1691 : kMaxSerializedErrors;
1692 for (fl::size ei = 0; ei < errLimit; ei++) {
1693 const auto& e = rr.errors[ei];
1695 err.
set(
"led",
static_cast<int64_t
>(e.led_index));
1697 expected.
push_back(
static_cast<int64_t
>(e.expected_r));
1698 expected.
push_back(
static_cast<int64_t
>(e.expected_g));
1699 expected.
push_back(
static_cast<int64_t
>(e.expected_b));
1702 static_cast<int64_t
>(e.expected_w));
1704 err.
set(
"expected", expected);
1706 actual.
push_back(
static_cast<int64_t
>(e.actual_r));
1707 actual.
push_back(
static_cast<int64_t
>(e.actual_g));
1708 actual.
push_back(
static_cast<int64_t
>(e.actual_b));
1710 actual.
push_back(
static_cast<int64_t
>(e.actual_w));
1712 err.
set(
"actual", actual);
1715 pat.
set(
"errors", errs);
1716 pat.
set(
"totalErrors",
static_cast<int64_t
>(rr.errors.size()));
1720 response.set(
"patterns", patterns);
1722 run_results.
clear();
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
bool autoResearchSetExclusiveDriverByName(const char *name)
AutoResearch-style helper: set an exclusive driver by name.
Full PARLIO encode bench for ESP32-P4 (post-byte-LUT, #2526 landed).
PARLIO ISR-streaming functional validation (#2548 deep-dive follow-up).
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)
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)
Issue #2994 repro: compounded per-sequence timing drift vs 3.10.3.
Wave8 expansion micro-benchmark for #2526.
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
@ CHANNELS
Remove all channels from controller list.
bool legacyClocklessChipsetFromName(const fl::string &name, LegacyClocklessChipset *out)
const char * legacyClocklessChipsetName(LegacyClocklessChipset chipset)
const char * legacyClocklessBoundDriverName()
Name of the driver to which public legacy templates are bound.
bool legacyClocklessChipsetHasAutomaticRgbw(LegacyClocklessChipset chipset)
fl::net::ble — BLE GATT transport layer for JSON-RPC
SPI encoder configuration for clocked LED chipsets.
FastLED chrono implementation - duration types for time measurements.
fl::json runSingleTestImpl(const fl::json &args)
fl::shared_ptr< AutoResearchState > mState
fl::u8 getBrightness() FL_NO_EXCEPT
Get the current global brightness setting.
void setBrightness(fl::u8 scale) FL_NO_EXCEPT
Set the global brightness scaling.
static fl::RxChannelPtr addRx(const fl::RxChannelConfig &config) FL_NO_EXCEPT
Add an RX channel with runtime configuration.
fl::shared_ptr< IChannelDriver > findDriverByName(const fl::string &name) const FL_NO_EXCEPT
Silent counterpart to getDriverByName().
static ChannelManager & instance() FL_NO_EXCEPT
Get the global singleton instance.
const char * c_str() const FL_NO_EXCEPT
size_t size() const FL_NO_EXCEPT
fl::optional< fl::string > as_string() const FL_NO_EXCEPT
fl::optional< i64 > as_int() const FL_NO_EXCEPT
void set(const fl::string &key, const json &value) FL_NO_EXCEPT
fl::optional< bool > as_bool() const FL_NO_EXCEPT
void push_back(const json &value) FL_NO_EXCEPT
bool contains(size_t idx) const FL_NO_EXCEPT
static json object() FL_NO_EXCEPT
static json array() FL_NO_EXCEPT
void reset() FL_NO_EXCEPT
string str() const FL_NO_EXCEPT
void stop() FL_NO_EXCEPT
Stops the coroutine represented by this handle.
bool is_valid() const FL_NO_EXCEPT
Returns whether this handle refers to a task.
bool isRunning() const FL_NO_EXCEPT
Returns whether the represented coroutine is currently running.
fl::size size() const FL_NO_EXCEPT
bool empty() const FL_NO_EXCEPT
void clear() 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)
UCS7604 LED chipset encoder implementation.
Task executor — runs registered task runners and manages the run loop.
Platform-abstracted heap memory query functions.
FastLED's Elegant JSON Library: fl::json
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
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
void stop() FL_NO_EXCEPT
Stop WiFi entirely (STA and AP).
Handle coroutine(const CoroutineConfig &config) FL_NO_EXCEPT
Creates and starts an OS-level coroutine task.
function< void()> func
Function executed by the coroutine, copied at creation time.
u8 priority
Platform task priority relative to the platform idle priority, default 5.
size_t stack_size
Requested stack size in bytes, default 4096.
optional< int > core_id
Optional CPU core affinity, unset by default (no affinity).
string name
Diagnostic name reported by the platform. Defaults to "task".
RxBackend resolveCaptureBackend(RxBackend requested_backend, bool has_explicit_override, bool is_parlio_driver, bool is_esp32_c6) FL_NO_EXCEPT
Select the independent capture backend used by AutoResearch.
size_t rpPioMaxWireBytes(size_t edge_capacity, size_t dma_tail_words, u32 samples_per_dma_word, u32 sample_period_ns, u32 idle_tail_ns, u32 arming_lead_in_ns, u32 bit_period_ns) FL_NO_EXCEPT
Largest frame, in wire bytes, an RP PIO RX capture can hold.
ClocklessEncoder
Identifies which encoder to use for clockless chipsets in the Channel API.
@ CLOCKLESS_ENCODER_UCS7604_8BIT
UCS7604 8-bit 800KHz.
@ CLOCKLESS_ENCODER_TM1812_RGBWW
TM1812: two 5-byte RGBWW pixels in each 12-byte IC frame.
@ CLOCKLESS_ENCODER_UCS7604_16BIT
UCS7604 16-bit 800KHz.
@ CLOCKLESS_ENCODER_UCS7604_16BIT_1600
UCS7604 16-bit 1600KHz.
@ CLOCKLESS_ENCODER_WS2812
Default, no preamble (WS2812 and compatible)
@ CLOCKLESS_ENCODER_TM1908
TM1908: command prefix followed by RGB pixels.
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...
constexpr size_t kRpPioRxDmaTailWords
Reset-tail words appended to the DMA transfer.
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 kRpPioRxSamplesPerDmaWord
Pin samples packed into each 32-bit DMA word.
constexpr ChipsetTimingConfig makeTimingConfig() FL_NO_EXCEPT
Convert compile-time CHIPSET type to runtime timing config.
size_t ucs7604FrameBytes(size_t num_leds, UCS7604Mode mode, bool is_rgbw) FL_NO_EXCEPT
Total wire bytes of a complete UCS7604 frame.
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.
fl::u32 micros() FL_NO_EXCEPT
Universal microsecond timer - returns microseconds since system startup.
@ High
At networking priority or above, biased above when supported.
@ I2S_RX
Classic-ESP32 I2S 1-bit oversampling backend — DMA sampling at 16 MHz, capture length limited by RAM ...
@ PIO
RP2040/RP2350 PIO receive backend.
@ PLATFORM_DEFAULT
Use the recommended backend for the active platform (RMT on ESP32; FlexPWM on Teensy 4....
@ RMT
ESP32-only RMT capture backend.
@ ISR
Platform-neutral interrupt-driven edge capture backend when available.
constexpr size_t kRpPioRxEdgeCapacity
Phase slots in the shared capture pool.
Bus
Portable public bus selector.
HeapInfo getFreeHeap() FL_NO_EXCEPT
Query available heap memory.
void analogWrite(int pin, u16 val) FL_NO_EXCEPT
Write analog value to pin (PWM)
Core
Worker task affinity. This does not change peripheral interrupt affinity.
@ Auto
Inherit the engine default, otherwise its legacy policy.
@ Any
Allow the worker to run on any configured RTOS core.
@ CallingCore
Capture the core that creates the worker.
constexpr u32 kRpPioRxClockHz
After synchronizing to the first rising edge the PIO runs one IN PINS instruction per cycle,...
UCS7604Mode
UCS7604 protocol configuration modes.
@ UCS7604_MODE_8BIT_800KHZ
@ UCS7604_MODE_16BIT_1600KHZ
@ UCS7604_MODE_16BIT_800KHZ
void delayNanoseconds(fl::u32 ns) FL_NO_EXCEPT
Delay for a runtime number of nanoseconds.
constexpr ClocklessEncoder encoder_for() FL_NO_EXCEPT
Extract the encoder selector from a compile-time TIMING type.
size_t ucs7604BytesPerLed(UCS7604Mode mode, bool is_rgbw) FL_NO_EXCEPT
Wire bytes each LED contributes to a UCS7604 frame.
@ RMT
RMT-based receiver (ESP32)
void pinMode(int pin, PinMode mode) FL_NO_EXCEPT
Set pin mode (input, output, pull-up, pull-down)
void delayMicroseconds(u32 us) FL_NO_EXCEPT
Delay for a given number of microseconds.
Promise-based fluent API for FastLED - standalone async primitives.
Umbrella header for SIMD subsystem.
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Configuration for a single LED channel.
constexpr u32 total_period_ns() const FL_NO_EXCEPT
Get total bit period (T1 + T2 + T3)
u32 reset_us
Reset/latch time (microseconds)
Runtime bit-period timing for a clockless chipset.
@ ERROR
Driver encountered an error.
static SpiEncoder apa102(u32 clock_hz=6000000) FL_NO_EXCEPT
Create APA102 encoder configuration.