FastLED 3.9.15
Loading...
Searching...
No Matches

◆ openVideoEitherFormat()

fl::Video openVideoEitherFormat ( const char * fledPath,
const char * rgbPath,
const char * sidecarScreenmapPath,
fl::ScreenMap * outScreenMap )

Definition at line 95 of file FxSdCard.ino.

98 {
99 // Try FLED first.
100 fl::Video v = filesystem.openVideo(fledPath, NUM_LEDS, FPS, NUM_VIDEO_FRAMES);
101 if (v && v.hasEmbeddedScreenMap()) {
102 const fl::string &json = v.embeddedScreenMapJson();
103 fl::string parseErr;
104 if (!fl::ScreenMap::ParseJson(json.c_str(), "strip1", outScreenMap, &parseErr)) {
105 FL_WARN("FLED embedded screenmap parse failed: " << parseErr.c_str());
106 gError = true;
107 return v;
108 }
109 validateScreenMapSize(*outScreenMap, fledPath);
110 return v;
111 }
112 // No .fled (or it lacks an embedded map). Fall back to legacy .rgb.
113 fl::Video legacy = filesystem.openVideo(rgbPath, NUM_LEDS, FPS, NUM_VIDEO_FRAMES);
114 if (!legacy) {
115 FL_WARN("Failed to open " << rgbPath << " (and no " << fledPath << " either)");
116 gError = true;
117 return legacy;
118 }
119 if (!filesystem.readScreenMap(sidecarScreenmapPath, "strip1", outScreenMap)) {
120 FL_WARN("Failed to read sidecar " << sidecarScreenmapPath);
121 gError = true;
122 return legacy;
123 }
124 validateScreenMapSize(*outScreenMap, sidecarScreenmapPath);
125 return legacy;
126}
#define NUM_LEDS
fl::FileSystem filesystem
Definition FxSdCard.ino:64
#define NUM_VIDEO_FRAMES
Definition FxSdCard.ino:50
bool gError
Definition FxSdCard.ino:72
static bool validateScreenMapSize(const fl::ScreenMap &m, const char *source)
Definition FxSdCard.ino:84
#define FPS
Definition FxSdCard.ino:43
static bool ParseJson(const char *jsonStrScreenMap, fl::flat_map< string, ScreenMap > *segmentMaps, string *err=nullptr) FL_NOEXCEPT
bool hasEmbeddedScreenMap() const FL_NOEXCEPT
const fl::string & embeddedScreenMapJson() const FL_NOEXCEPT
const char * c_str() const FL_NOEXCEPT
#define FL_WARN(X)
Definition log.h:276

References fl::basic_string::c_str(), fl::Video::embeddedScreenMapJson(), filesystem, FL_WARN, FPS, gError, fl::Video::hasEmbeddedScreenMap(), NUM_LEDS, NUM_VIDEO_FRAMES, fl::ScreenMap::ParseJson(), and validateScreenMapSize().

Referenced by setup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: