FastLED 3.10.8
Loading...
Searching...
No Matches
AutoResearchHelpers.cpp
Go to the documentation of this file.
1// AutoResearchHelpers.cpp - Helper function implementations
2
3// Gate out under low-memory mode -- the LowMemory bring-up surface
4// (AutoResearchLowMemory.h) carries its own minimal helper inlined into
5// the .ino, and the full helpers here pull in fl/channels/manager.h and
6// the validation suite which exceed the LPC845 / Tiny-memory budgets.
7// Matches the conditional structure in AutoResearch.ino itself.
9#if FL_PLATFORM_HAS_LARGE_MEMORY
10
11#include "AutoResearchHelpers.h"
12#include "fl/channels/manager.h"
13#include "fl/stl/cstdio.h"
14#include "fl/stl/sstream.h"
15
16// PR #3421 framework-hang fix: gate FL_WARN sstream construction on log
17// level so the heap-backed sstream is never built under ScopedLogDisable.
18// See AutoResearchTest.cpp for the full investigation note.
19#define AR_FL_WARN(...) do { \
20 if (fl::getLogLevel() >= static_cast<fl::u8>(fl::LogLevel::FL_LOG_LEVEL_WARN)) { \
21 FL_WARN(__VA_ARGS__); \
22 } \
23} while (0)
24#define AR_FL_ERROR(...) do { \
25 if (fl::getLogLevel() >= static_cast<fl::u8>(fl::LogLevel::FL_LOG_LEVEL_ERROR)) { \
26 FL_ERROR(__VA_ARGS__); \
27 } \
28} while (0)
29#include "fl/system/pin.h" // Platform-independent pin API
33
34bool testRxChannel(
36 int pin_tx,
37 int pin_rx,
38 uint32_t hz,
39 size_t buffer_size) {
40 // Delegate to library implementation
41 return fl::validation::testRxChannel(rx_channel, pin_tx, pin_rx, hz, buffer_size);
42}
43
44
46 // Delegate to library implementation
48}
49
50bool autoResearchSetExclusiveDriverByName(const char* name) {
51 // AutoResearch resolves driver names at runtime (RPC/JSON). The caller
52 // (AutoResearch.ino setup()) must already have enrolled every available
53 // driver via FastLED.enableAllDrivers(). We deliberately do NOT call
54 // enableAllDrivers() here — doing it per-iteration would re-add every
55 // driver each call, triggering ChannelManager's "Replacing existing driver"
56 // path and resetting state mid-test (#2469).
58}
59
60void testDriver(
61 const char* driver_name,
62 const fl::NamedTimingConfig& timing_config,
63 int pin_data,
64 size_t num_leds,
65 CRGB* leds,
66 EOrder color_order,
68 fl::span<uint8_t> rx_buffer,
69 int base_strip_size,
70 fl::RxDeviceType rx_type,
71 fl::DriverTestResult& result) {
72
73 // Set this driver as exclusive for testing. AutoResearch resolves driver
74 // names at runtime, so we use the by-name helper (auto-enables all
75 // drivers first to ensure the lookup succeeds).
76 if (!autoResearchSetExclusiveDriverByName(driver_name)) {
77 AR_FL_ERROR("Failed to set " << driver_name << " as exclusive driver");
78 result.skipped = true;
79 return;
80 }
81 AR_FL_WARN(driver_name << " driver enabled exclusively\n");
82
83 AR_FL_WARN("[CONFIG] Driver: " << driver_name << " (physical jumper required)\n");
84
85 // Create TX configuration for autoresearch tests.
86 // Build the ClocklessChipset explicitly so the encoder selector (carried
87 // alongside timing in NamedTimingConfig, #2467) is preserved end-to-end.
88 fl::ClocklessChipset chipset(pin_data, timing_config.timing, timing_config.encoder);
89 fl::ChannelConfig tx_config(chipset, fl::span<CRGB>(leds, num_leds), color_order);
90
91 AR_FL_WARN("[INFO] Testing " << timing_config.name << " timing\n");
92
93 // Create autoresearch configuration with all input parameters
94 fl::AutoResearchConfig autoresearch_config(
95 timing_config.timing,
96 timing_config.name,
97 fl::span<fl::ChannelConfig>(&tx_config, 1),
98 driver_name,
99 rx_channel,
100 rx_buffer,
101 base_strip_size,
102 rx_type,
103 timing_config.encoder
104 );
105
106 // FIRST RUN: Discard results (timing warm-up)
107 // TX channel construction may have extra latency on first run
108 AR_FL_WARN("[INFO] Running warm-up frame (results will be discarded)");
109 int warmup_total = 0, warmup_passed = 0;
110 uint32_t warmup_duration_ms = 0;
111 autoResearchChipsetTiming(autoresearch_config, warmup_total, warmup_passed, warmup_duration_ms);
112 AR_FL_WARN("[INFO] Warm-up complete (" << warmup_passed << "/" << warmup_total << " passed - discarding)");
113
114 // SECOND RUN: Keep results (actual test)
115 AR_FL_WARN("[INFO] Running actual test frame");
116 uint32_t test_duration_ms = 0;
117 autoResearchChipsetTiming(autoresearch_config, result.total_tests, result.passed_tests, test_duration_ms);
118
119 AR_FL_WARN("\n[INFO] All timing tests complete for " << driver_name << " driver");
120}
121
122void printSummaryTable(const fl::vector<fl::DriverTestResult>& driver_results) {
123 // Delegate to library implementation
124 fl::validation::printSummaryTable(driver_results);
125}
126
127// Build test matrix configuration from preprocessor defines and available drivers
128
129#endif // FL_PLATFORM_HAS_LARGE_MEMORY
CRGB leds[1]
void testDriver(const char *driver_name, const fl::NamedTimingConfig &timing_config, int pin_data, size_t num_leds, CRGB *leds, EOrder color_order, fl::shared_ptr< fl::RxChannel > rx_channel, fl::span< uint8_t > rx_buffer, int base_strip_size, fl::RxDeviceType rx_type, fl::DriverTestResult &result)
Test a specific driver with given timing configuration.
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.
bool autoResearchSetExclusiveDriverByName(const char *name)
AutoResearch-style helper: set an exclusive driver by name.
void printSummaryTable(const fl::vector< fl::DriverTestResult > &driver_results)
Print driver autoresearch summary table.
void autoResearchExpectedEngines()
AutoResearch that expected engines are available for this platform Prints ERROR if any expected engin...
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)
bool setExclusiveDriverByName(const char *name) FL_NO_EXCEPT
Enable only one driver exclusively (disables all others) — by-name escape hatch.
static ChannelManager & instance() FL_NO_EXCEPT
Get the global singleton instance.
fl::EOrder EOrder
Definition eorder.h:12
fl::CRGB CRGB
Definition crgb.h:25
Unified manager for channel drivers with priority-based fallback.
void printSummaryTable(const fl::vector< fl::DriverTestResult > &driver_results) FL_NO_EXCEPT
Print driver validation summary table to log.
bool testRxChannel(fl::shared_ptr< fl::RxChannel > rx_channel, int pin_tx, int pin_rx, u32 hz, size_t buffer_size) FL_NO_EXCEPT
Test RX channel with manual GPIO toggle pattern.
void printEngineValidation() FL_NO_EXCEPT
Print validation results (logs registered drivers and status)
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
RxDeviceType
RX device type enumeration.
Definition rx.h:164
fl::u32 uint32_t
Definition stdint.h:218
Configuration for driver-agnostic autoresearch testing Contains all input parameters needed for autor...
Configuration for a single LED channel.
Definition config.h:167
Clockless chipset configuration (single data pin)
Definition config.h:33
Driver test result tracking (moved from ValidationTest.h)
Definition validation.h:236
fl::ClocklessEncoder encoder
Definition Common.h:35
const char * name
Definition Common.h:36
fl::ChipsetTimingConfig timing
Definition Common.h:34
Chipset timing configuration with name for testing.
Definition Common.h:33