FastLED 3.10.6
Loading...
Searching...
No Matches
AutoResearchFlexIo.h
Go to the documentation of this file.
1
25
26#pragma once
27
28#include "FastLED.h"
29#include "fl/channels/bus.h"
30#include "fl/channels/manager.h"
31#include "fl/stl/int.h"
32#include "fl/stl/json.h"
33#include "fl/stl/string.h"
34#include "platforms/is_platform.h"
35
36namespace autoresearch {
37namespace flex_io {
38
41#if defined(FL_IS_ESP_32DEV)
42 return fl::string::from_literal("ESP32");
43#elif defined(FL_IS_ESP_32S2)
44 return fl::string::from_literal("ESP32-S2");
45#elif defined(FL_IS_ESP_32S3)
46 return fl::string::from_literal("ESP32-S3");
47#elif defined(FL_IS_ESP_32C3)
48 return fl::string::from_literal("ESP32-C3");
49#elif defined(FL_IS_ESP_32C5)
50 return fl::string::from_literal("ESP32-C5");
51#elif defined(FL_IS_ESP_32C6)
52 return fl::string::from_literal("ESP32-C6");
53#elif defined(FL_IS_ESP_32H2)
54 return fl::string::from_literal("ESP32-H2");
55#elif defined(FL_IS_ESP_32P4)
56 return fl::string::from_literal("ESP32-P4");
57#elif defined(FL_IS_TEENSY_4X)
58 return fl::string::from_literal("Teensy-4.x");
59#elif defined(FL_IS_STUB)
60 return fl::string::from_literal("Host-stub");
61#else
62 return fl::string::from_literal("Unknown");
63#endif
64}
65
68#if defined(FL_IS_ESP32) && defined(ESP_IDF_VERSION_MAJOR)
70 s << ESP_IDF_VERSION_MAJOR;
71#if defined(ESP_IDF_VERSION_MINOR)
72 s << '.' << ESP_IDF_VERSION_MINOR;
73#endif
74#if defined(ESP_IDF_VERSION_PATCH)
75 s << '.' << ESP_IDF_VERSION_PATCH;
76#endif
77 return s.str();
78#else
79 return fl::string::from_literal("n/a");
80#endif
81}
82
95 auto& manager = fl::channelManager();
96 auto infos = manager.getDriverInfos();
97 for (const auto& info : infos) {
98 if (!info.name.empty()) {
99 names.push_back(info.name);
100 }
101 }
102 return names;
103}
104
107 auto names = registeredDriverNames();
108 if (names.empty()) {
109 return fl::string::from_literal("<none>");
110 }
111 return names[0];
112}
113
128 fl::json info = fl::json::object();
129 info.set("bus", "FLEX_IO");
130 info.set("instance", static_cast<int64_t>(instance));
131 // firstDriverName gives the most-preferred registered driver's
132 // name — on classic ESP32 this is typically "I2S_SPI" for the
133 // FLEX_IO slot; on P4/C6/etc. "PARLIO"; on S3 "LCD_CLOCKLESS".
134 info.set("driverName", firstDriverName());
135 // Full driver list so the host can pick the FLEX_IO-bound one by
136 // name if firstDriverName isn't the FLEX_IO owner.
137 fl::json names_arr = fl::json::array();
138 for (const auto& n : registeredDriverNames()) {
139 names_arr.push_back(n);
140 }
141 info.set("registeredDriverNames", names_arr);
142 info.set("silicon", siliconName());
143 info.set("idfVersion", idfVersion());
144 info.set("supportedByBuild",
146 return info;
147}
148
149} // namespace flex_io
150} // namespace autoresearch
Portable compile-time identifiers for LED channel buses.
void set(const fl::string &key, const json &value) FL_NO_EXCEPT
Definition json.h:866
void push_back(const json &value) FL_NO_EXCEPT
Definition json.h:918
static json object() FL_NO_EXCEPT
Definition json.h:857
static json array() FL_NO_EXCEPT
Definition json.h:853
string str() const FL_NO_EXCEPT
Definition strstream.h:43
static string from_literal(const char *literal) FL_NO_EXCEPT
void push_back(const T &value) FL_NO_EXCEPT
Definition vector.h:624
FastLED's Elegant JSON Library: fl::json
Unified manager for channel drivers with priority-based fallback.
fl::vector< fl::string > registeredDriverNames() FL_NO_EXCEPT
Return the list of registered driver names.
fl::string idfVersion() FL_NO_EXCEPT
ESP-IDF version string, or "n/a" on non-ESP32 targets.
fl::string firstDriverName() FL_NO_EXCEPT
Convenience — first non-empty driver name, or "<none>" if empty.
fl::json buildDeviceInfo(fl::u8 instance) FL_NO_EXCEPT
Build the device-info JSON returned by the flexIoDeviceInfo RPC.
fl::string siliconName() FL_NO_EXCEPT
Platform identification string derived from build-time macros.
unsigned char u8
Definition stdint.h:131
ChannelManager & channelManager()
Get the global ChannelManager singleton instance.
#define FL_NO_EXCEPT