diff --git a/usermods/Battery/usermod_v2_Battery.h b/usermods/Battery/usermod_v2_Battery.h index d765ddbb86..c64cd4e48e 100644 --- a/usermods/Battery/usermod_v2_Battery.h +++ b/usermods/Battery/usermod_v2_Battery.h @@ -160,9 +160,9 @@ class UsermodBattery : public Usermod device[F("sw")] = versionString; sprintf_P(buf, PSTR("homeassistant/%s/%s/%s/config"), type, mqttClientID, uid); - DEBUG_PRINTLN(buf); + DEBUGUM_PRINTLN(buf); size_t payload_size = serializeJson(doc, json_str); - DEBUG_PRINTLN(json_str); + DEBUGUM_PRINTLN(json_str); mqtt->publish(buf, 0, true, json_str, payload_size); } diff --git a/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h b/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h index 31f41e6c59..4a830b735d 100644 --- a/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h +++ b/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h @@ -229,7 +229,7 @@ void PIRsensorSwitch::switchStrip(bool switchOn) if (m_offOnly && bri && (switchOn || (!PIRtriggered && !switchOn))) return; //if lights on and off only, do nothing if (PIRtriggered && switchOn) return; //if already on and triggered before, do nothing PIRtriggered = switchOn; - DEBUGUM_PRINT(F("PIR: strip=")); DEBUGUM_PRINTLN(switchOn?"on":"off"); + DEBUGUM_PRINTF_P(PSTR("PIR: strip=%s\n"), switchOn?"on":"off"); if (switchOn) { if (m_onPreset) { if (currentPlaylist>0 && !offMode) { @@ -384,7 +384,7 @@ void PIRsensorSwitch::setup() #endif sensorPinState[i] = digitalRead(PIRsensorPin[i]); } else { - DEBUGUM_PRINT(F("PIRSensorSwitch pin ")); DEBUGUM_PRINTLN(i); DEBUGUM_PRINTLN(F(" allocation failed.")); + DEBUGUM_PRINTF_P(PSTR("PIRSensorSwitch: pin %d allocation failed.\n"), i); PIRsensorPin[i] = -1; // allocation failed } } @@ -471,7 +471,7 @@ void PIRsensorSwitch::addToJsonInfo(JsonObject &root) void PIRsensorSwitch::onStateChange(uint8_t mode) { if (!initDone) return; - DEBUGUM_PRINT(F("PIR: offTimerStart=")); DEBUGUM_PRINTLN(offTimerStart); + DEBUGUM_PRINTF_P(PSTR("PIR: offTimerStart=%lu\n"), offTimerStart); if (m_override && PIRtriggered && offTimerStart) { // debounce // checking PIRtriggered and offTimerStart will prevent cancellation upon On trigger DEBUGUM_PRINTLN(F("PIR: Canceled.")); @@ -561,12 +561,12 @@ bool PIRsensorSwitch::readFromConfig(JsonObject &root) if (!initDone) { // reading config prior to setup() - DEBUGUM_PRINTLN(F(" config loaded.")); + DEBUGUM_PRINTLN(F(": config loaded.")); } else { for (int i = 0; i < PIR_SENSOR_MAX_SENSORS; i++) if (oldPin[i] >= 0) PinManager::deallocatePin(oldPin[i], PinOwner::UM_PIR); setup(); - DEBUGUM_PRINTLN(F(" config (re)loaded.")); + DEBUGUM_PRINTLN(F(": config (re)loaded.")); } // use "return !top["newestParameter"].isNull();" when updating Usermod with new features return !(pins.isNull() || pins.size() != PIR_SENSOR_MAX_SENSORS); diff --git a/usermods/Temperature/usermod_temperature.h b/usermods/Temperature/usermod_temperature.h index a4f98b8b37..d0df015765 100644 --- a/usermods/Temperature/usermod_temperature.h +++ b/usermods/Temperature/usermod_temperature.h @@ -122,8 +122,7 @@ float UsermodTemperature::readDallas() { if (OneWire::crc8(data,8) != data[8]) { DEBUGUM_PRINTLN(F("CRC error reading temperature.")); for (unsigend i=0; i < 9; i++) DEBUGUM_PRINTF_P(PSTR("0x%02X "), data[i]); - DEBUGUM_PRINT(F(" => ")); - DEBUGUM_PRINTF_P(PSTR("0x%02X\n"), OneWire::crc8(data,8)); + DEBUGUM_PRINTF_P(PSTR(" => 0x%02X\n"), OneWire::crc8(data,8)); } #endif switch(sensorFound) { @@ -161,8 +160,7 @@ void UsermodTemperature::readTemperature() { lastMeasurement = millis(); waitingForConversion = false; //DEBUGUM_PRINTF_P(PSTR("Read temperature %2.1f.\n"), temperature); // does not work properly on 8266 - DEBUGUM_PRINT(F("Read temperature ")); - DEBUGUM_PRINTLN(temperature); + DEBUGUM_PRINTF_P(PSTR("Read temperature %3.1f\n"), (double)temperature); } bool UsermodTemperature::findSensor() { @@ -415,12 +413,12 @@ bool UsermodTemperature::readFromConfig(JsonObject &root) { if (!initDone) { // first run: reading from cfg.json temperaturePin = newTemperaturePin; - DEBUGUM_PRINTLN(F(" config loaded.")); + DEBUGUM_PRINTLN(F(": config loaded.")); } else { - DEBUGUM_PRINTLN(F(" config (re)loaded.")); + DEBUGUM_PRINTLN(F(": config (re)loaded.")); // changing paramters from settings page if (newTemperaturePin != temperaturePin) { - DEBUGUM_PRINTLN(F("Re-init temperature.")); + DEBUGUM_PRINTLN(F(" Re-init temperature.")); // deallocate pin and release memory delete oneWire; PinManager::deallocatePin(temperaturePin, PinOwner::UM_Temperature); diff --git a/usermods/boblight/boblight.h b/usermods/boblight/boblight.h index 16b43d8380..5465e247ce 100644 --- a/usermods/boblight/boblight.h +++ b/usermods/boblight/boblight.h @@ -173,8 +173,7 @@ class BobLightUsermod : public Usermod { numLights = lightcount; #if WLED_DEBUG_USERMODS - DEBUGUM_PRINTLN(F("Fill light data: ")); - DEBUGUM_PRINTF_P(PSTR(" lights %d\n"), numLights); + DEBUGUM_PRINTF_P(PSTR("Fill light data:\n lights %d\n"), numLights); for (int i=0; i strip.getLengthTotal() ) { - DEBUGUM_PRINTLN(F("BobLight: Too many lights.")); - DEBUGUM_PRINTF_P(PSTR("%d+%d+%d+%d>%d\n"), bottom, left, top, right, strip.getLengthTotal()); + DEBUGUM_PRINTF_P(PSTR("BobLight: Too many lights.\n%d+%d+%d+%d>%d\n"), bottom, left, top, right, strip.getLengthTotal()); totalLights = strip.getLengthTotal(); top = bottom = (uint16_t) roundf((float)totalLights * 16.0f / 50.0f); left = right = (uint16_t) roundf((float)totalLights * 9.0f / 50.0f); diff --git a/usermods/multi_relay/usermod_multi_relay.h b/usermods/multi_relay/usermod_multi_relay.h index b833ffacda..73f4975b96 100644 --- a/usermods/multi_relay/usermod_multi_relay.h +++ b/usermods/multi_relay/usermod_multi_relay.h @@ -399,7 +399,7 @@ void MultiRelay::switchRelay(uint8_t relay, bool mode) { state |= (_relay[i].invert ? !_relay[i].state : _relay[i].state) << pin; // fill relay states for all pins } IOexpanderWrite(addrPcf8574, state); - DEBUGUM_PRINT(F("Writing to PCF8574: ")); DEBUGUM_PRINTLN(state); + DEBUGUM_PRINTF_P(PSTR("Writing to PCF8574: %d\n"), (int)state); } else if (_relay[relay].pin < 100) { pinMode(_relay[relay].pin, OUTPUT); digitalWrite(_relay[relay].pin, _relay[relay].invert ? !_relay[relay].state : _relay[relay].state); @@ -781,8 +781,8 @@ bool MultiRelay::readFromConfig(JsonObject &root) { int8_t oldPin[MULTI_RELAY_MAX_RELAYS]; JsonObject top = root[FPSTR(_name)]; + DEBUGUM_PRINT(FPSTR(_name)); if (top.isNull()) { - DEBUGUM_PRINT(FPSTR(_name)); DEBUGUM_PRINTLN(F(": No config found. (Using defaults.)")); return false; } @@ -809,10 +809,9 @@ bool MultiRelay::readFromConfig(JsonObject &root) { _relay[i].delay = min(600,max(0,abs((int)_relay[i].delay))); // bounds checking max 10min } - DEBUGUM_PRINT(FPSTR(_name)); if (!initDone) { // reading config prior to setup() - DEBUGUM_PRINTLN(F(" config loaded.")); + DEBUGUM_PRINTLN(F(": config loaded.")); } else { // deallocate all pins 1st for (int i=0; i= 0) { detachInterrupt(pinIRQ); PinManager::deallocatePin(pinIRQ, PinOwner::UM_RotaryEncoderUI); - DEBUGUM_PRINTLN(F("Deallocated old IRQ pin.")); + DEBUGUM_PRINTLN(F(" Deallocated old IRQ pin.")); } pinIRQ = newIRQpin<100 ? newIRQpin : -1; // ignore PCF8574 pins } else { PinManager::deallocatePin(pinA, PinOwner::UM_RotaryEncoderUI); PinManager::deallocatePin(pinB, PinOwner::UM_RotaryEncoderUI); PinManager::deallocatePin(pinC, PinOwner::UM_RotaryEncoderUI); - DEBUGUM_PRINTLN(F("Deallocated old pins.")); + DEBUGUM_PRINTLN(F(" Deallocated old pins.")); } pinA = newDTpin; pinB = newCLKpin; diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index 0e249b2f78..c9b59fee57 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -89,8 +89,7 @@ void WS2812FX::setUpMatrix() { int8_t *gapTable = nullptr; if (isFile && requestJSONBufferLock(20)) { - DEBUGFX_PRINT(F("Reading LED gap from ")); - DEBUGFX_PRINTLN(fileName); + DEBUGFX_PRINTF_P(PSTR("Reading LED gap from %s\n"), fileName); // read the array into global JSON buffer if (readObjectFromFile(fileName, nullptr, pDoc)) { // the array is similar to ledmap, except it has only 3 values: diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 1cc78f71e5..769bf652fa 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -163,8 +163,7 @@ bool IRAM_ATTR_YN Segment::allocateData(size_t len) { deallocateData(); // if the old buffer was smaller release it first if (Segment::getUsedSegmentData() + len > MAX_SEGMENT_DATA) { // not enough memory - DEBUGFX_PRINT(F("!!! Effect RAM depleted: ")); - DEBUGFX_PRINTF_P(PSTR("%d/%d !!!\n"), len, Segment::getUsedSegmentData()); + DEBUGFX_PRINTF_P(PSTR("!!! Effect RAM depleted: %d/%d !!!\n"), len, Segment::getUsedSegmentData()); errorFlag = ERR_NORAM; return false; } @@ -492,10 +491,7 @@ void Segment::setUp(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, uint16_t } if (ofs < UINT16_MAX) offset = ofs; - DEBUGFX_PRINT(F("setUp segment: ")); DEBUGFX_PRINT(i1); - DEBUGFX_PRINT(','); DEBUGFX_PRINT(i2); - DEBUGFX_PRINT(F(" -> ")); DEBUGFX_PRINT(i1Y); - DEBUGFX_PRINT(','); DEBUGFX_PRINTLN(i2Y); + DEBUGFX_PRINTF_P(PSTR("setUp segment: %d,%d -> %d,%d\n"), (int)i1, (int)i2, (int)i1Y, (int)i2Y); markForReset(); if (boundsUnchanged) return; @@ -1248,13 +1244,13 @@ void WS2812FX::finalizeInit() { // Pin should not be already allocated, read/only or defined for current bus while (PinManager::isPinAllocated(defPin[j]) || !PinManager::isPinOk(defPin[j],true)) { if (validPin) { - DEBUG_PRINTLN(F("Some of the provided pins cannot be used to configure this LED output.")); + DEBUGFX_PRINTLN(F("Some of the provided pins cannot be used to configure this LED output.")); defPin[j] = 1; // start with GPIO1 and work upwards validPin = false; } else if (defPin[j] < WLED_NUM_PINS) { defPin[j]++; } else { - DEBUG_PRINTLN(F("No available pins left! Can't configure output.")); + DEBUGFX_PRINTLN(F("No available pins left! Can't configure output.")); return; } // is the newly assigned pin already defined or used previously? @@ -1780,8 +1776,7 @@ void WS2812FX::loadCustomPalettes() { StaticJsonDocument<1536> pDoc; // barely enough to fit 72 numbers if (WLED_FS.exists(fileName)) { - DEBUGFX_PRINT(F("Reading palette from ")); - DEBUGFX_PRINTLN(fileName); + DEBUGFX_PRINTF_P(PSTR("Reading palette from %s\n"), fileName); if (readObjectFromFile(fileName, nullptr, &pDoc)) { JsonArray pal = pDoc[F("palette")]; @@ -1841,7 +1836,7 @@ bool WS2812FX::deserializeMap(uint8_t n) { if (!isFile || !requestJSONBufferLock(7)) return false; if (!readObjectFromFile(fileName, nullptr, pDoc)) { - DEBUGFX_PRINT(F("ERROR Invalid ledmap in ")); DEBUGFX_PRINTLN(fileName); + DEBUGFX_PRINTF_P(PSTR("ERROR Invalid ledmap in %s\n"), fileName); releaseJSONBufferLock(); return false; // if file does not load properly then exit } @@ -1857,7 +1852,7 @@ bool WS2812FX::deserializeMap(uint8_t n) { customMappingTable = new uint16_t[getLengthTotal()]; if (customMappingTable) { - DEBUGFX_PRINT(F("Reading LED map from ")); DEBUGFX_PRINTLN(fileName); + DEBUGFX_PRINTF_P(PSTR("Reading LED map from %s\n"), fileName); JsonArray map = root[F("map")]; if (!map.isNull() && map.size()) { // not an empty map customMappingSize = min((unsigned)map.size(), (unsigned)getLengthTotal()); diff --git a/wled00/util.cpp b/wled00/util.cpp index 99a75bdd30..68027ceaaf 100644 --- a/wled00/util.cpp +++ b/wled00/util.cpp @@ -158,11 +158,7 @@ bool oappend(const char* txt) { unsigned len = strlen(txt); if ((obuf == nullptr) || (olen + len >= SETTINGS_STACK_BUF_SIZE)) { // sanity checks -#ifdef WLED_DEBUG - DEBUG_PRINT(F("oappend() buffer overflow. Cannot append ")); - DEBUG_PRINT(len); DEBUG_PRINT(F(" bytes \t\"")); - DEBUG_PRINT(txt); DEBUG_PRINTLN(F("\"")); -#endif + DEBUG_PRINTF_P(PSTR("oappend() buffer overflow. Cannot append %u bytes ->\"%s\"\n"), len, txt); return false; // buffer full } strcpy(obuf + olen, txt);