Get current WLED state as JSON object.
- Returns
- JSON object with "on" and "bri" fields
Example: fl::json state = remote.getState(); // Returns: {"on":true,"bri":128}
Definition at line 408 of file wled.cpp.hpp.
408 {
417
418
425
426
430 state.set(
"udpn", udpn);
431
432
435 }
436
437
442
443 segJson.
set(
"id",
static_cast<i64>(seg.mId));
444 segJson.
set(
"start",
static_cast<i64>(seg.mStart));
445 segJson.
set(
"stop",
static_cast<i64>(seg.mStop));
446 segJson.
set(
"len",
static_cast<i64>(seg.mLen));
447 segJson.
set(
"grp",
static_cast<i64>(seg.mGrp));
448 segJson.
set(
"spc",
static_cast<i64>(seg.mSpc));
449 segJson.
set(
"of",
static_cast<i64>(seg.mOf));
450 segJson.
set(
"on", seg.mOn);
451 segJson.
set(
"bri",
static_cast<i64>(seg.mBri));
452 segJson.
set(
"cct",
static_cast<i64>(seg.mCct));
453
454
455 segJson.
set(
"fx",
static_cast<i64>(seg.mFx));
456 segJson.
set(
"sx",
static_cast<i64>(seg.mSx));
457 segJson.
set(
"ix",
static_cast<i64>(seg.mIx));
458 segJson.
set(
"pal",
static_cast<i64>(seg.mPal));
459 segJson.
set(
"c1",
static_cast<i64>(seg.mC1));
460 segJson.
set(
"c2",
static_cast<i64>(seg.mC2));
461 segJson.
set(
"c3",
static_cast<i64>(seg.mC3));
462
463
464 segJson.
set(
"sel", seg.mSel);
465 segJson.
set(
"rev", seg.mRev);
466 segJson.
set(
"mi", seg.mMi);
467 segJson.
set(
"o1", seg.mO1);
468 segJson.
set(
"o2", seg.mO2);
469 segJson.
set(
"o3", seg.mO3);
470 segJson.
set(
"si",
static_cast<i64>(seg.mSi));
471 segJson.
set(
"m12",
static_cast<i64>(seg.mM12));
472 segJson.
set(
"rpt", seg.mRpt);
473
474 if (!seg.mName.empty()) {
475 segJson.
set(
"n", seg.mName);
476 }
477
478
479 if (!seg.mColors.empty()) {
481 for (const auto& color : seg.mColors) {
482 if (color.size() >= 3) {
484 for (size_t i = 0; i < color.size(); i++) {
485 colorArray.
push_back(fl::json(
static_cast<i64>(color[i])));
486 }
488 }
489 }
490 segJson.
set(
"col", colors);
491 }
492
493
494 if (!seg.mIndividualLeds.empty()) {
496 for (const auto& led : seg.mIndividualLeds) {
497 if (led.size() >= 3) {
499 leds.push_back(fl::json(hexColor.
c_str()));
500 }
501 }
503 }
504
506 }
507 state.set(
"seg", segments);
508 }
509
511}
bool hasPlaylistConfig() const FL_NO_EXCEPT
Check if playlist is active.
u8 mNightlightTargetBrightness
fl::json getPlaylistConfig() const FL_NO_EXCEPT
Get playlist configuration.
fl::vector< WLEDSegment > mSegments
const char * c_str() const FL_NO_EXCEPT
void set(const fl::string &key, const json &value) FL_NO_EXCEPT
void push_back(const json &value) FL_NO_EXCEPT
static json object() FL_NO_EXCEPT
static json array() FL_NO_EXCEPT
fl::string rgbToHex(u8 r, u8 g, u8 b) FL_NO_EXCEPT
Convert RGB components to hex string.
References fl::json::array(), fl::basic_string::c_str(), fl::FL_NO_EXCEPT, getPlaylistConfig(), hasPlaylistConfig(), leds, mLiveOverride, mMainSegment, mNightlightDuration, mNightlightMode, mNightlightOn, mNightlightTargetBrightness, mPlaylist, mPreset, mSegments, mTransition, mUdpReceive, mUdpSend, mWledBri, mWledOn, fl::json::object(), fl::json::push_back(), fl::wled::rgbToHex(), fl::json::set(), and state.