From cd1ede38a70ca503d9a4ef675cfc4cab11d424d2 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Thu, 11 Jul 2024 21:22:58 +0200 Subject: [PATCH] Size & speed optimisations --- usermods/Temperature/usermod_temperature.h | 4 +-- .../usermod_v2_four_line_display_ALT.h | 26 +++++++------- .../usermod_v2_rotary_encoder_ui_ALT.h | 20 +++++------ wled00/FX_fcn.cpp | 6 ++-- wled00/NodeStruct.h | 2 +- wled00/alexa.cpp | 6 ++-- wled00/cfg.cpp | 12 +++---- wled00/dmx.cpp | 2 +- wled00/led.cpp | 4 +-- wled00/ntp.cpp | 2 +- wled00/overlay.cpp | 4 +-- wled00/pin_manager.cpp | 6 ++-- wled00/remote.cpp | 2 +- wled00/um_manager.cpp | 36 +++++++++---------- wled00/util.cpp | 2 +- wled00/xml.cpp | 8 ++--- 16 files changed, 72 insertions(+), 70 deletions(-) diff --git a/usermods/Temperature/usermod_temperature.h b/usermods/Temperature/usermod_temperature.h index 5b6b21d8c..5ac992f95 100644 --- a/usermods/Temperature/usermod_temperature.h +++ b/usermods/Temperature/usermod_temperature.h @@ -113,7 +113,7 @@ float UsermodTemperature::readDallas() { #ifdef WLED_DEBUG if (OneWire::crc8(data,8) != data[8]) { DEBUG_PRINTLN(F("CRC error reading temperature.")); - for (byte i=0; i < 9; i++) DEBUG_PRINTF_P(PSTR("0x%02X "), data[i]); + for (unsigned i=0; i < 9; i++) DEBUG_PRINTF_P(PSTR("0x%02X "), data[i]); DEBUG_PRINT(F(" => ")); DEBUG_PRINTF_P(PSTR("0x%02X\n"), OneWire::crc8(data,8)); } @@ -133,7 +133,7 @@ float UsermodTemperature::readDallas() { break; } } - for (byte i=1; i<9; i++) data[0] &= data[i]; + for (unsigned i=1; i<9; i++) data[0] &= data[i]; return data[0]==0xFF ? -127.0f : retVal; } diff --git a/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h b/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h index 2cb1507ce..008647fa7 100644 --- a/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h +++ b/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h @@ -445,8 +445,8 @@ void FourLineDisplayUsermod::setPowerSave(uint8_t save) { void FourLineDisplayUsermod::center(String &line, uint8_t width) { int len = line.length(); - if (len0; i--) line = ' ' + line; - for (byte i=line.length(); i0; i--) line = ' ' + line; + for (unsigned i=line.length(); i127)) { // remove note symbol from effect names - for (byte i=5; i<=printedChars; i++) lineBuffer[i-5] = lineBuffer[i]; //include '\0' + for (unsigned i=5; i<=printedChars; i++) lineBuffer[i-5] = lineBuffer[i]; //include '\0' printedChars -= 5; } if (lineHeight == 2) { // use this code for 8 line display char smallBuffer1[MAX_MODE_LINE_SPACE]; char smallBuffer2[MAX_MODE_LINE_SPACE]; - uint8_t smallChars1 = 0; - uint8_t smallChars2 = 0; + unsigned smallChars1 = 0; + unsigned smallChars2 = 0; if (printedChars < MAX_MODE_LINE_SPACE) { // use big font if the text fits while (printedChars < (MAX_MODE_LINE_SPACE-1)) lineBuffer[printedChars++]=' '; lineBuffer[printedChars] = 0; drawString(1, row*lineHeight, lineBuffer); } else { // for long names divide the text into 2 lines and print them small bool spaceHit = false; - for (uint8_t i = 0; i < printedChars; i++) { + for (unsigned i = 0; i < printedChars; i++) { switch (lineBuffer[i]) { case ' ': if (i > 4 && !spaceHit) { @@ -865,8 +865,8 @@ void FourLineDisplayUsermod::showCurrentEffectOrPalette(int inputEffPal, const c } } else { // use this code for 4 ling displays char smallBuffer3[MAX_MODE_LINE_SPACE+1]; // uses 1x1 icon for mode/palette - uint8_t smallChars3 = 0; - for (uint8_t i = 0; i < MAX_MODE_LINE_SPACE; i++) smallBuffer3[smallChars3++] = (i >= printedChars) ? ' ' : lineBuffer[i]; + unsigned smallChars3 = 0; + for (unsigned i = 0; i < MAX_MODE_LINE_SPACE; i++) smallBuffer3[smallChars3++] = (i >= printedChars) ? ' ' : lineBuffer[i]; smallBuffer3[smallChars3] = 0; drawString(1, row*lineHeight, smallBuffer3, true); } @@ -1265,7 +1265,7 @@ void FourLineDisplayUsermod::addToConfig(JsonObject& root) { bool FourLineDisplayUsermod::readFromConfig(JsonObject& root) { bool needsRedraw = false; DisplayType newType = type; - int8_t oldPin[3]; for (byte i=0; i<3; i++) oldPin[i] = ioPin[i]; + int8_t oldPin[3]; for (unsigned i=0; i<3; i++) oldPin[i] = ioPin[i]; JsonObject top = root[FPSTR(_name)]; if (top.isNull()) { @@ -1276,7 +1276,7 @@ bool FourLineDisplayUsermod::readFromConfig(JsonObject& root) { enabled = top[FPSTR(_enabled)] | enabled; newType = top["type"] | newType; - for (byte i=0; i<3; i++) ioPin[i] = top["pin"][i] | ioPin[i]; + for (unsigned i=0; i<3; i++) ioPin[i] = top["pin"][i] | ioPin[i]; flip = top[FPSTR(_flip)] | flip; contrast = top[FPSTR(_contrast)] | contrast; #ifndef ARDUINO_ARCH_ESP32 @@ -1302,7 +1302,7 @@ bool FourLineDisplayUsermod::readFromConfig(JsonObject& root) { DEBUG_PRINTLN(F(" config (re)loaded.")); // changing parameters from settings page bool pinsChanged = false; - for (byte i=0; i<3; i++) if (ioPin[i] != oldPin[i]) { pinsChanged = true; break; } + for (unsigned i=0; i<3; i++) if (ioPin[i] != oldPin[i]) { pinsChanged = true; break; } if (pinsChanged || type!=newType) { bool isSPI = (type == SSD1306_SPI || type == SSD1306_SPI64 || type == SSD1309_SPI64); bool newSPI = (newType == SSD1306_SPI || newType == SSD1306_SPI64 || newType == SSD1309_SPI64); diff --git a/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h b/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h index e5a5f24f7..5756fbb69 100644 --- a/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h +++ b/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h @@ -416,7 +416,7 @@ void RotaryEncoderUIUsermod::sortModesAndPalettes() { byte *RotaryEncoderUIUsermod::re_initIndexArray(int numModes) { byte *indexes = (byte *)malloc(sizeof(byte) * numModes); - for (byte i = 0; i < numModes; i++) { + for (unsigned i = 0; i < numModes; i++) { indexes[i] = i; } return indexes; @@ -700,7 +700,7 @@ void RotaryEncoderUIUsermod::findCurrentEffectAndPalette() { effectPaletteIndex = 0; DEBUG_PRINTLN(effectPalette); - for (uint8_t i = 0; i < strip.getPaletteCount()+strip.customPalettes.size(); i++) { + for (unsigned i = 0; i < strip.getPaletteCount()+strip.customPalettes.size(); i++) { if (palettes_alpha_indexes[i] == effectPalette) { effectPaletteIndex = i; DEBUG_PRINTLN(F("Found palette.")); @@ -764,7 +764,7 @@ void RotaryEncoderUIUsermod::changeEffect(bool increase) { effectCurrent = modes_alpha_indexes[effectCurrentIndex]; stateChanged = true; if (applyToAll) { - for (byte i=0; i defNumCounts && defNumCounts > 1 && defNumPins%defNumCounts == 0 ? defNumCounts : defNumPins; + const unsigned defNumCounts = ((sizeof defCounts) / (sizeof defCounts[0])); + // if number of pins is divisible by counts, use number of counts to determine number of buses, otherwise use pins + const unsigned defNumBusses = defNumPins > defNumCounts && defNumPins%defNumCounts == 0 ? defNumCounts : defNumPins; const unsigned pinsPerBus = defNumPins / defNumBusses; unsigned prevLen = 0; for (unsigned i = 0; i < defNumBusses && i < WLED_MAX_BUSSES+WLED_MIN_VIRTUAL_BUSSES; i++) { @@ -1229,6 +1230,7 @@ void WS2812FX::finalizeInit(void) { while (pinManager.isPinAllocated(defPin[0]) && defPin[0] < WLED_NUM_PINS) defPin[0]++; } unsigned start = prevLen; + // if we have less counts than pins and they do not align, use last known count to set current count unsigned count = defCounts[(i < defNumCounts) ? i : defNumCounts -1]; prevLen += count; BusConfig defCfg = BusConfig(DEFAULT_LED_TYPE, defPin, start, count, DEFAULT_LED_COLOR_ORDER, false, 0, RGBW_MODE_MANUAL_ONLY, 0, useGlobalLedBuffer); diff --git a/wled00/NodeStruct.h b/wled00/NodeStruct.h index 2d4d3609b..34f73ab41 100644 --- a/wled00/NodeStruct.h +++ b/wled00/NodeStruct.h @@ -34,7 +34,7 @@ struct NodeStruct NodeStruct() : age(0), nodeType(0), build(0) { - for (uint8_t i = 0; i < 4; ++i) { ip[i] = 0; } + for (unsigned i = 0; i < 4; ++i) { ip[i] = 0; } } }; typedef std::map NodesMap; diff --git a/wled00/alexa.cpp b/wled00/alexa.cpp index 179a522c0..b108f294b 100644 --- a/wled00/alexa.cpp +++ b/wled00/alexa.cpp @@ -25,7 +25,7 @@ void alexaInit() // names are identical as the preset names, switching off can be done by switching off any of them if (alexaNumPresets) { String name = ""; - for (byte presetIndex = 1; presetIndex <= alexaNumPresets; presetIndex++) + for (unsigned presetIndex = 1; presetIndex <= alexaNumPresets; presetIndex++) { if (!getPresetName(presetIndex, name)) break; // no more presets EspalexaDevice* dev = new EspalexaDevice(name.c_str(), onAlexaChange, EspalexaDeviceType::extendedcolor); @@ -64,7 +64,7 @@ void onAlexaChange(EspalexaDevice* dev) } else // switch-on behavior for preset devices { // turn off other preset devices - for (byte i = 1; i < espalexa.getDeviceCount(); i++) + for (unsigned i = 1; i < espalexa.getDeviceCount(); i++) { if (i == dev->getId()) continue; espalexa.getDevice(i)->setValue(0); // turn off other presets @@ -87,7 +87,7 @@ void onAlexaChange(EspalexaDevice* dev) applyPreset(macroAlexaOff, CALL_MODE_ALEXA); // below for loop stops Alexa from complaining if macroAlexaOff does not actually turn off } - for (byte i = 0; i < espalexa.getDeviceCount(); i++) + for (unsigned i = 0; i < espalexa.getDeviceCount(); i++) { espalexa.getDevice(i)->setValue(0); } diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 1fc3f2425..f9a94e228 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -86,7 +86,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(apBehavior, ap[F("behav")]); /* JsonArray ap_ip = ap["ip"]; - for (byte i = 0; i < 4; i++) { + for (unsigned i = 0; i < 4; i++) { apIP[i] = ap_ip; } */ @@ -565,7 +565,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { JsonArray if_hue_ip = if_hue["ip"]; - for (byte i = 0; i < 4; i++) + for (unsigned i = 0; i < 4; i++) CJSON(hueIP[i], if_hue_ip[i]); #endif @@ -793,7 +793,7 @@ void serializeConfig() { ethernet["type"] = ethernetType; if (ethernetType != WLED_ETH_NONE && ethernetType < WLED_NUM_ETH_TYPES) { JsonArray pins = ethernet.createNestedArray("pin"); - for (uint8_t p=0; p=0) pins.add(ethernetBoards[ethernetType].eth_power); if (ethernetBoards[ethernetType].eth_mdc>=0) pins.add(ethernetBoards[ethernetType].eth_mdc); if (ethernetBoards[ethernetType].eth_mdio>=0) pins.add(ethernetBoards[ethernetType].eth_mdio); @@ -1046,7 +1046,7 @@ void serializeConfig() { if_hue_recv["col"] = hueApplyColor; JsonArray if_hue_ip = if_hue.createNestedArray("ip"); - for (byte i = 0; i < 4; i++) { + for (unsigned i = 0; i < 4; i++) { if_hue_ip.add(hueIP[i]); } #endif @@ -1081,7 +1081,7 @@ void serializeConfig() { JsonArray timers_ins = timers.createNestedArray("ins"); - for (byte i = 0; i < 10; i++) { + for (unsigned i = 0; i < 10; i++) { if (timerMacro[i] == 0 && timerHours[i] == 0 && timerMinutes[i] == 0) continue; // sunrise/sunset get saved always (timerHours=255) JsonObject timers_ins0 = timers_ins.createNestedObject(); timers_ins0["en"] = (timerWeekday[i] & 0x01); @@ -1113,7 +1113,7 @@ void serializeConfig() { dmx[F("start-led")] = DMXStartLED; JsonArray dmx_fixmap = dmx.createNestedArray(F("fixmap")); - for (byte i = 0; i < 15; i++) { + for (unsigned i = 0; i < 15; i++) { dmx_fixmap.add(DMXFixtureMap[i]); } diff --git a/wled00/dmx.cpp b/wled00/dmx.cpp index 6bdf80a79..dbe70f2aa 100644 --- a/wled00/dmx.cpp +++ b/wled00/dmx.cpp @@ -22,7 +22,7 @@ void handleDMX() bool calc_brightness = true; // check if no shutter channel is set - for (byte i = 0; i < DMXChannels; i++) + for (unsigned i = 0; i < DMXChannels; i++) { if (DMXFixtureMap[i] == 5) calc_brightness = false; } diff --git a/wled00/led.cpp b/wled00/led.cpp index 704296461..ba6ed2550 100644 --- a/wled00/led.cpp +++ b/wled00/led.cpp @@ -226,7 +226,7 @@ void handleNightlight() nightlightDelayMs = (unsigned)(nightlightDelayMins*60000); nightlightActiveOld = true; briNlT = bri; - for (byte i=0; i<4; i++) colNlT[i] = col[i]; // remember starting color + for (unsigned i=0; i<4; i++) colNlT[i] = col[i]; // remember starting color if (nightlightMode == NL_MODE_SUN) { //save current @@ -251,7 +251,7 @@ void handleNightlight() bri = briNlT + ((nightlightTargetBri - briNlT)*nper); if (nightlightMode == NL_MODE_COLORFADE) // color fading only is enabled with "NF=2" { - for (byte i=0; i<4; i++) col[i] = colNlT[i]+ ((colSec[i] - colNlT[i])*nper); // fading from actual color to secondary color + for (unsigned i=0; i<4; i++) col[i] = colNlT[i]+ ((colSec[i] - colNlT[i])*nper); // fading from actual color to secondary color } colorUpdated(CALL_MODE_NO_NOTIFY); } diff --git a/wled00/ntp.cpp b/wled00/ntp.cpp index e2c99045a..056110a58 100644 --- a/wled00/ntp.cpp +++ b/wled00/ntp.cpp @@ -377,7 +377,7 @@ void checkTimers() if (!hour(localTime) && minute(localTime)==1) calculateSunriseAndSunset(); DEBUG_PRINTF_P(PSTR("Local time: %02d:%02d\n"), hour(localTime), minute(localTime)); - for (uint8_t i = 0; i < 8; i++) + for (unsigned i = 0; i < 8; i++) { if (timerMacro[i] != 0 && (timerWeekday[i] & 0x01) //timer is enabled diff --git a/wled00/overlay.cpp b/wled00/overlay.cpp index d6d8ba52a..239cff528 100644 --- a/wled00/overlay.cpp +++ b/wled00/overlay.cpp @@ -34,7 +34,7 @@ void _overlayAnalogClock() } if (analogClock5MinuteMarks) { - for (byte i = 0; i <= 12; i++) + for (unsigned i = 0; i <= 12; i++) { unsigned pix = analogClock12pixel + roundf((overlaySize / 12.0f) *i); if (pix > overlayMax) pix -= overlaySize; @@ -91,7 +91,7 @@ void handleOverlayDraw() { usermods.handleOverlayDraw(); if (analogClockSolidBlack) { const Segment* segments = strip.getSegments(); - for (uint8_t i = 0; i < strip.getSegmentsNum(); i++) { + for (unsigned i = 0; i < strip.getSegmentsNum(); i++) { const Segment& segment = segments[i]; if (!segment.isActive()) continue; if (segment.mode > 0 || segment.colors[0] > 0) { diff --git a/wled00/pin_manager.cpp b/wled00/pin_manager.cpp index b6dc9e35a..84101e7cf 100644 --- a/wled00/pin_manager.cpp +++ b/wled00/pin_manager.cpp @@ -295,7 +295,7 @@ byte PinManagerClass::allocateLedc(byte channels) { if (channels > MAX_LED_CHANNELS || channels == 0) return 255; byte ca = 0; - for (byte i = 0; i < MAX_LED_CHANNELS; i++) { + for (unsigned i = 0; i < MAX_LED_CHANNELS; i++) { byte by = i >> 3; byte bi = i - 8*by; if (bitRead(ledcAlloc[by], bi)) { //found occupied pin @@ -305,7 +305,7 @@ byte PinManagerClass::allocateLedc(byte channels) } if (ca >= channels) { //enough free channels byte in = (i + 1) - ca; - for (byte j = 0; j < ca; j++) { + for (unsigned j = 0; j < ca; j++) { byte bChan = in + j; byte byChan = bChan >> 3; byte biChan = bChan - 8*byChan; @@ -319,7 +319,7 @@ byte PinManagerClass::allocateLedc(byte channels) void PinManagerClass::deallocateLedc(byte pos, byte channels) { - for (byte j = pos; j < pos + channels; j++) { + for (unsigned j = pos; j < pos + channels; j++) { if (j > MAX_LED_CHANNELS) return; byte by = j >> 3; byte bi = j - 8*by; diff --git a/wled00/remote.cpp b/wled00/remote.cpp index 54cdf31f6..9c8d67d0d 100644 --- a/wled00/remote.cpp +++ b/wled00/remote.cpp @@ -68,7 +68,7 @@ static bool resetNightMode() { static void brightnessUp() { if (nightModeActive()) return; // dumb incremental search is efficient enough for so few items - for (uint8_t index = 0; index < numBrightnessSteps; ++index) { + for (unsigned index = 0; index < numBrightnessSteps; ++index) { if (brightnessSteps[index] > bri) { bri = brightnessSteps[index]; break; diff --git a/wled00/um_manager.cpp b/wled00/um_manager.cpp index e73b66c38..2db29c3cd 100644 --- a/wled00/um_manager.cpp +++ b/wled00/um_manager.cpp @@ -4,57 +4,57 @@ */ //Usermod Manager internals -void UsermodManager::setup() { for (byte i = 0; i < numMods; i++) ums[i]->setup(); } -void UsermodManager::connected() { for (byte i = 0; i < numMods; i++) ums[i]->connected(); } -void UsermodManager::loop() { for (byte i = 0; i < numMods; i++) ums[i]->loop(); } -void UsermodManager::handleOverlayDraw() { for (byte i = 0; i < numMods; i++) ums[i]->handleOverlayDraw(); } -void UsermodManager::appendConfigData() { for (byte i = 0; i < numMods; i++) ums[i]->appendConfigData(); } +void UsermodManager::setup() { for (unsigned i = 0; i < numMods; i++) ums[i]->setup(); } +void UsermodManager::connected() { for (unsigned i = 0; i < numMods; i++) ums[i]->connected(); } +void UsermodManager::loop() { for (unsigned i = 0; i < numMods; i++) ums[i]->loop(); } +void UsermodManager::handleOverlayDraw() { for (unsigned i = 0; i < numMods; i++) ums[i]->handleOverlayDraw(); } +void UsermodManager::appendConfigData() { for (unsigned i = 0; i < numMods; i++) ums[i]->appendConfigData(); } bool UsermodManager::handleButton(uint8_t b) { bool overrideIO = false; - for (byte i = 0; i < numMods; i++) { + for (unsigned i = 0; i < numMods; i++) { if (ums[i]->handleButton(b)) overrideIO = true; } return overrideIO; } bool UsermodManager::getUMData(um_data_t **data, uint8_t mod_id) { - for (byte i = 0; i < numMods; i++) { + for (unsigned i = 0; i < numMods; i++) { if (mod_id > 0 && ums[i]->getId() != mod_id) continue; // only get data form requested usermod if provided if (ums[i]->getUMData(data)) return true; // if usermod does provide data return immediately (only one usermod can provide data at one time) } return false; } -void UsermodManager::addToJsonState(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->addToJsonState(obj); } -void UsermodManager::addToJsonInfo(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->addToJsonInfo(obj); } -void UsermodManager::readFromJsonState(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->readFromJsonState(obj); } -void UsermodManager::addToConfig(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->addToConfig(obj); } +void UsermodManager::addToJsonState(JsonObject& obj) { for (unsigned i = 0; i < numMods; i++) ums[i]->addToJsonState(obj); } +void UsermodManager::addToJsonInfo(JsonObject& obj) { for (unsigned i = 0; i < numMods; i++) ums[i]->addToJsonInfo(obj); } +void UsermodManager::readFromJsonState(JsonObject& obj) { for (unsigned i = 0; i < numMods; i++) ums[i]->readFromJsonState(obj); } +void UsermodManager::addToConfig(JsonObject& obj) { for (unsigned i = 0; i < numMods; i++) ums[i]->addToConfig(obj); } bool UsermodManager::readFromConfig(JsonObject& obj) { bool allComplete = true; - for (byte i = 0; i < numMods; i++) { + for (unsigned i = 0; i < numMods; i++) { if (!ums[i]->readFromConfig(obj)) allComplete = false; } return allComplete; } #ifndef WLED_DISABLE_MQTT -void UsermodManager::onMqttConnect(bool sessionPresent) { for (byte i = 0; i < numMods; i++) ums[i]->onMqttConnect(sessionPresent); } +void UsermodManager::onMqttConnect(bool sessionPresent) { for (unsigned i = 0; i < numMods; i++) ums[i]->onMqttConnect(sessionPresent); } bool UsermodManager::onMqttMessage(char* topic, char* payload) { - for (byte i = 0; i < numMods; i++) if (ums[i]->onMqttMessage(topic, payload)) return true; + for (unsigned i = 0; i < numMods; i++) if (ums[i]->onMqttMessage(topic, payload)) return true; return false; } #endif #ifndef WLED_DISABLE_ESPNOW bool UsermodManager::onEspNowMessage(uint8_t* sender, uint8_t* payload, uint8_t len) { - for (byte i = 0; i < numMods; i++) if (ums[i]->onEspNowMessage(sender, payload, len)) return true; + for (unsigned i = 0; i < numMods; i++) if (ums[i]->onEspNowMessage(sender, payload, len)) return true; return false; } #endif -void UsermodManager::onUpdateBegin(bool init) { for (byte i = 0; i < numMods; i++) ums[i]->onUpdateBegin(init); } // notify usermods that update is to begin -void UsermodManager::onStateChange(uint8_t mode) { for (byte i = 0; i < numMods; i++) ums[i]->onStateChange(mode); } // notify usermods that WLED state changed +void UsermodManager::onUpdateBegin(bool init) { for (unsigned i = 0; i < numMods; i++) ums[i]->onUpdateBegin(init); } // notify usermods that update is to begin +void UsermodManager::onStateChange(uint8_t mode) { for (unsigned i = 0; i < numMods; i++) ums[i]->onStateChange(mode); } // notify usermods that WLED state changed /* * Enables usermods to lookup another Usermod. */ Usermod* UsermodManager::lookup(uint16_t mod_id) { - for (byte i = 0; i < numMods; i++) { + for (unsigned i = 0; i < numMods; i++) { if (ums[i]->getId() == mod_id) { return ums[i]; } diff --git a/wled00/util.cpp b/wled00/util.cpp index 3834939dc..6bc02234b 100644 --- a/wled00/util.cpp +++ b/wled00/util.cpp @@ -197,7 +197,7 @@ void prepareHostname(char* hostname) bool isAsterisksOnly(const char* str, byte maxLen) { - for (byte i = 0; i < maxLen; i++) { + for (unsigned i = 0; i < maxLen; i++) { if (str[i] == 0) break; if (str[i] != '*') return false; } diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 255402cea..7da301715 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -168,7 +168,7 @@ void appendGPIOinfo() { #ifdef WLED_USE_ETHERNET if (ethernetType != WLED_ETH_NONE && ethernetType < WLED_NUM_ETH_TYPES) { - for (uint8_t p=0; p=0) { oappend(","); oappend(itoa(ethernetBoards[ethernetType].eth_power,nS,10)); } if (ethernetBoards[ethernetType].eth_mdc>=0) { oappend(","); oappend(itoa(ethernetBoards[ethernetType].eth_mdc,nS,10)); } if (ethernetBoards[ethernetType].eth_mdio>=0) { oappend(","); oappend(itoa(ethernetBoards[ethernetType].eth_mdio,nS,10)); } @@ -632,7 +632,7 @@ void getSettingsJS(byte subPage, char* dest) sappend('v',SET_F("A1"),macroAlexaOff); sappend('v',SET_F("MC"),macroCountdown); sappend('v',SET_F("MN"),macroNl); - for (uint8_t i=0; i