Helper function to parse segment fields
| 65 | |
| 66 | // Helper function to parse segment fields |
| 67 | void parseSegmentFields(const fl::json& segJson, WLEDSegment& seg) { |
| 68 | // Extract basic properties |
| 69 | if (segJson.contains("start") && segJson["start"].is_int()) { |
| 70 | i64 startInt = segJson["start"] | 0; |
| 71 | if (startInt < 0) startInt = 0; |
| 72 | if (startInt > 65535) startInt = 65535; |
| 73 | seg.mStart = static_cast<u16>(startInt); |
| 74 | } |
| 75 | |
| 76 | if (segJson.contains("stop") && segJson["stop"].is_int()) { |
| 77 | i64 stopInt = segJson["stop"] | 0; |
| 78 | if (stopInt < 0) stopInt = 0; |
| 79 | if (stopInt > 65535) stopInt = 65535; |
| 80 | seg.mStop = static_cast<u16>(stopInt); |
| 81 | } |
| 82 | |
| 83 | if (segJson.contains("len") && segJson["len"].is_int()) { |
| 84 | i64 lenInt = segJson["len"] | 0; |
| 85 | if (lenInt < 0) lenInt = 0; |
| 86 | if (lenInt > 65535) lenInt = 65535; |
| 87 | seg.mLen = static_cast<u16>(lenInt); |
| 88 | } |
| 89 | |
| 90 | if (segJson.contains("grp") && segJson["grp"].is_int()) { |
| 91 | i64 grpInt = segJson["grp"] | 1; |
| 92 | if (grpInt < 1) grpInt = 1; |
| 93 | if (grpInt > 255) grpInt = 255; |
| 94 | seg.mGrp = static_cast<u8>(grpInt); |
| 95 | } |
| 96 | |
| 97 | if (segJson.contains("spc") && segJson["spc"].is_int()) { |
| 98 | i64 spcInt = segJson["spc"] | 0; |
| 99 | if (spcInt < 0) spcInt = 0; |
| 100 | if (spcInt > 255) spcInt = 255; |
| 101 | seg.mSpc = static_cast<u8>(spcInt); |
| 102 | } |
| 103 | |
| 104 | if (segJson.contains("of") && segJson["of"].is_int()) { |
| 105 | i64 ofInt = segJson["of"] | 0; |
| 106 | if (ofInt < 0) ofInt = 0; |
| 107 | if (ofInt > 65535) ofInt = 65535; |
| 108 | seg.mOf = static_cast<u16>(ofInt); |
| 109 | } |
| 110 | |
| 111 | if (segJson.contains("on") && segJson["on"].is_bool()) { |
| 112 | seg.mOn = segJson["on"] | true; |
| 113 | } |
| 114 | |
| 115 | if (segJson.contains("bri") && segJson["bri"].is_int()) { |
| 116 | i64 briInt = segJson["bri"] | 255; |
| 117 | if (briInt < 0) briInt = 0; |
| 118 | if (briInt > 255) briInt = 255; |
| 119 | seg.mBri = static_cast<u8>(briInt); |
| 120 | } |
| 121 | |
| 122 | if (segJson.contains("cct") && segJson["cct"].is_int()) { |
| 123 | i64 cctInt = segJson["cct"] | 0; |
| 124 | if (cctInt < 0) cctInt = 0; |
no test coverage detected