diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 74a3cc15..7e1d1634 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -7259,7 +7259,7 @@ static const char _data_RESERVED[] PROGMEM = "Reserved"; // if vector size() is smaller than id (single) data is appended at the end (regardless of id) void WS2812FX::addEffect(uint8_t id, mode_ptr mode_fn, const char *mode_name) { if (id == 255) { // find empty slot - for (int i=1; i<_mode.size(); i++) if (_modeData[i] == _data_RESERVED) { id = i; break; } + for (size_t i=1; i<_mode.size(); i++) if (_modeData[i] == _data_RESERVED) { id = i; break; } } if (id < _mode.size()) { if (_modeData[id] != _data_RESERVED) return; // do not overwrite alerady added effect @@ -7277,7 +7277,7 @@ void WS2812FX::setupEffectData() { _mode.push_back(&mode_static); _modeData.push_back(_data_FX_MODE_STATIC); // fill reserved word in case there will be any gaps in the array - for (int i=1; i<_modeCount; i++) { + for (size_t i=1; i<_modeCount; i++) { _mode.push_back(&mode_static); _modeData.push_back(_data_RESERVED); } diff --git a/wled00/json.cpp b/wled00/json.cpp index 347d742d..169a2454 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -316,13 +316,22 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId) bool stateResponse = root[F("v")] | false; bool onBefore = bri; - getVal(root["bri"], &bri); + uint8_t tmpBri = bri; + getVal(root["bri"], &tmpBri); if (root["on"].isNull()) { - if ((onBefore && bri==0) || (!onBefore && bri>0)) toggleOnOff(); + if ((onBefore && tmpBri==0) || (!onBefore && tmpBri>0)) toggleOnOff(); + bri = tmpBri; } else { bool on = root["on"] | onBefore; - if (on != onBefore || (root["on"].is() && root["on"].as()[0] == 't')) toggleOnOff(); + if (on != onBefore || (root["on"].is() && root["on"].as()[0] == 't')) { + toggleOnOff(); + // a hack is needed after toggleOnOf() + if (!root["bri"].isNull()) { + if (bri==0) briLast = tmpBri; + else bri = tmpBri; + } + } } if (bri && !onBefore) { // unfreeze all segments when turning on