FastLED 3.9.15
Loading...
Searching...
No Matches
AutoResearchHelpers.cpp
Go to the documentation of this file.
1// AutoResearchHelpers.cpp - Helper function implementations
2
5#include "fl/stl/sstream.h"
6#include "fl/system/pin.h" // Platform-independent pin API
10
13 int pin_tx,
14 int pin_rx,
15 uint32_t hz,
16 size_t buffer_size) {
17 // Delegate to library implementation
18 return fl::validation::testRxChannel(rx_channel, pin_tx, pin_rx, hz, buffer_size);
19}
20
21
23 // Delegate to library implementation
25}
26
28 // AutoResearch resolves driver names at runtime (RPC/JSON). The caller
29 // (AutoResearch.ino setup()) must already have enrolled every available
30 // driver via FastLED.enableAllDrivers(). We deliberately do NOT call
31 // enableAllDrivers() here — doing it per-iteration would re-add every
32 // driver each call, triggering ChannelManager's "Replacing existing driver"
33 // path and resetting state mid-test (#2469).
35}
36
38 const char* driver_name,
39 const fl::NamedTimingConfig& timing_config,
40 int pin_data,
41 size_t num_leds,
42 CRGB* leds,
43 EOrder color_order,
45 fl::span<uint8_t> rx_buffer,
46 int base_strip_size,
47 fl::RxDeviceType rx_type,
48 fl::DriverTestResult& result) {
49
50 // Set this driver as exclusive for testing. AutoResearch resolves driver
51 // names at runtime, so we use the by-name helper (auto-enables all
52 // drivers first to ensure the lookup succeeds).
53 if (!autoResearchSetExclusiveDriverByName(driver_name)) {
54 FL_ERROR("Failed to set " << driver_name << " as exclusive driver");
55 result.skipped = true;
56 return;
57 }
58 FL_WARN(driver_name << " driver enabled exclusively\n");
59
60 FL_WARN("[CONFIG] Driver: " << driver_name << " (physical jumper required)\n");
61
62 // Create TX configuration for autoresearch tests.
63 // Build the ClocklessChipset explicitly so the encoder selector (carried
64 // alongside timing in NamedTimingConfig, #2467) is preserved end-to-end.
65 fl::ClocklessChipset chipset(pin_data, timing_config.timing, timing_config.encoder);
66 fl::ChannelConfig tx_config(chipset, fl::span<CRGB>(leds, num_leds), color_order);
67
68 FL_WARN("[INFO] Testing " << timing_config.name << " timing\n");
69
70 // Create autoresearch configuration with all input parameters
71 fl::AutoResearchConfig autoresearch_config(
72 timing_config.timing,
73 timing_config.name,
74 fl::span<fl::ChannelConfig>(&tx_config, 1),
75 driver_name,
76 rx_channel,
77 rx_buffer,
78 base_strip_size,
79 rx_type,
80 timing_config.encoder
81 );
82
83 // FIRST RUN: Discard results (timing warm-up)
84 // TX channel construction may have extra latency on first run
85 FL_WARN("[INFO] Running warm-up frame (results will be discarded)");
86 int warmup_total = 0, warmup_passed = 0;
87 uint32_t warmup_duration_ms = 0;
88 autoResearchChipsetTiming(autoresearch_config, warmup_total, warmup_passed, warmup_duration_ms);
89 FL_WARN("[INFO] Warm-up complete (" << warmup_passed << "/" << warmup_total << " passed - discarding)");
90
91 // SECOND RUN: Keep results (actual test)
92 FL_WARN("[INFO] Running actual test frame");
93 uint32_t test_duration_ms = 0;
94 autoResearchChipsetTiming(autoresearch_config, result.total_tests, result.passed_tests, test_duration_ms);
95
96 FL_WARN("\n[INFO] All timing tests complete for " << driver_name << " driver");
97}
98
100 // Delegate to library implementation
101 fl::validation::printSummaryTable(driver_results);
102}
103
104// Build test matrix configuration from preprocessor defines and available drivers
fl::CRGB leds[NUM_LEDS]
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 &driver_total, int &driver_passed, uint32_t &out_show_duration_ms, fl::vector< fl::RunResult > *out_results, int num_runs_per_pattern)
bool setExclusiveDriverByName(const char *name) FL_NOEXCEPT
Enable only one driver exclusively (disables all others) — by-name escape hatch.
static ChannelManager & instance() FL_NOEXCEPT
Get the global singleton instance.
fl::EOrder EOrder
Definition eorder.h:12
fl::CRGB CRGB
Definition crgb.h:25
#define FL_WARN(X)
Definition log.h:276
#define FL_ERROR(X)
Definition log.h:219
Unified manager for channel drivers with priority-based fallback.
void printSummaryTable(const fl::vector< fl::DriverTestResult > &driver_results)
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)
Test RX channel with manual GPIO toggle pattern.
void printEngineValidation()
Print validation results (logs registered drivers and status)
RxDeviceType
RX device type enumeration.
Definition rx.h:163
Configuration for driver-agnostic autoresearch testing Contains all input parameters needed for autor...
Configuration for a single LED channel.
Definition config.h:163
Clockless chipset configuration (single data pin)
Definition config.h:32
Driver test result tracking (moved from ValidationTest.h)
Definition validation.h:68
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