MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / mergeConfiguration

Method mergeConfiguration

lib/DateTimePlugin/src/DateTimePlugin.cpp:292–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292bool DateTimePlugin::mergeConfiguration(JsonObject& jsonMerged, const JsonObjectConst& jsonSource)
293{
294 bool isSuccessful = false;
295 JsonVariantConst jsonMode = jsonSource["mode"];
296 JsonVariantConst jsonViewMode = jsonSource["viewMode"];
297 JsonVariantConst jsonTimeFormat = jsonSource["timeFormat"];
298 JsonVariantConst jsonDateFormat = jsonSource["dateFormat"];
299 JsonVariantConst jsonTimeZone = jsonSource["timeZone"];
300 JsonVariantConst jsonStartOfWeek = jsonSource["startOfWeek"];
301 JsonVariantConst jsonDayOnColor = jsonSource["dayOnColor"];
302 JsonVariantConst jsonDayOffColor = jsonSource["dayOffColor"];
303
304 /* The received configuration may not contain all single key/value pair.
305 * Therefore read first the complete internal configuration and
306 * overwrite them with the received ones.
307 */
308 getConfiguration(jsonMerged);
309
310 /* Note:
311 * Check only for the key/value pair availability.
312 * The type check will follow in the setConfiguration().
313 */
314
315 if (false == jsonMode.isNull())
316 {
317 jsonMerged["mode"] = jsonMode.as<uint8_t>();
318 isSuccessful = true;
319 }
320
321 if (false == jsonViewMode.isNull())
322 {
323 jsonMerged["viewMode"] = jsonViewMode.as<uint8_t>();
324 isSuccessful = true;
325 }
326
327 if (false == jsonTimeFormat.isNull())
328 {
329 jsonMerged["timeFormat"] = jsonTimeFormat.as<const char*>();
330 isSuccessful = true;
331 }
332
333 if (false == jsonDateFormat.isNull())
334 {
335 jsonMerged["dateFormat"] = jsonDateFormat.as<const char*>();
336 isSuccessful = true;
337 }
338
339 if (false == jsonTimeZone.isNull())
340 {
341 jsonMerged["timeZone"] = jsonTimeZone.as<const char*>();
342 isSuccessful = true;
343 }
344
345 if (false == jsonStartOfWeek.isNull())
346 {
347 jsonMerged["startOfWeek"] = jsonStartOfWeek.as<uint8_t>();
348 isSuccessful = true;
349 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected