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

◆ toJson()

void fl::ScreenMap::toJson ( const FixedMap< Str, ScreenMap, 16 > & segmentMaps,
JsonDocument * doc )
static

Definition at line 125 of file screenmap.cpp.

126 {
127
128#if !FASTLED_ENABLE_JSON
129 return;
130#else
131 if (!_doc) {
132 FASTLED_WARN("ScreenMap::toJson called with nullptr _doc");
133 return;
134 }
135 auto &doc = *_doc;
136 auto map = doc["map"].to<FLArduinoJson::JsonObject>();
137 if (!segmentMaps.empty()) {
138 for (auto kv : segmentMaps) {
139 auto segment = map[kv.first].to<FLArduinoJson::JsonObject>();
140 auto x_array = segment["x"].to<FLArduinoJson::JsonArray>();
141 auto y_array = segment["y"].to<FLArduinoJson::JsonArray>();
142 for (uint16_t i = 0; i < kv.second.getLength(); i++) {
143 const vec2f &xy = kv.second[i];
144 x_array.add(xy.x);
145 y_array.add(xy.y);
146 }
147 float diameter = kv.second.getDiameter();
148 if (diameter < 0.0f) {
149 diameter = .5f; // 5mm.
150 }
151 if (diameter > 0.0f) {
152 segment["diameter"] = diameter;
153 }
154 }
155 }
156
157#endif
158}
unsigned int xy(unsigned int x, unsigned int y)
long map(long x, long in_min, long in_max, long out_min, long out_max)
vec2< float > vec2f
Definition geometry.h:318
#define FASTLED_WARN
Definition warn.h:7

References fl::FixedMap< Key, Value, N >::empty(), FASTLED_WARN, and xy().

Referenced by toJsonStr().

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