Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug refactor #4050

Open
wants to merge 8 commits into
base: 0_15
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ platform_packages = platformio/toolchain-xtensa @ ~2.100300.220621 #2.40802.2005
# esp8266 : see https://docs.platformio.org/en/latest/platforms/espressif8266.html#debug-level
# esp32 : see https://docs.platformio.org/en/latest/platforms/espressif32.html#debug-level
# ------------------------------------------------------------------------------
debug_flags = -D DEBUG=1 -D WLED_DEBUG
debug_flags = -D DEBUG=1 -D WLED_DEBUG_ALL ;; or -D WLED_DEBUG -DWLED_DEBUG_FS -DWLED_DEBUG_FX -DWLED_DEBUG_BUS -DWLED_DEBUG_PINMANAGER -DWLED_DEBUG_USERMODS -DWLED_DEBUG_MATH
-DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_TLS_MEM ;; for esp8266
# if needed (for memleaks etc) also add; -DDEBUG_ESP_OOM -include "umm_malloc/umm_malloc_cfg.h"
# -DDEBUG_ESP_CORE is not working right now
Expand Down
7 changes: 7 additions & 0 deletions platformio_override.sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ build_flags = ${common.build_flags} ${esp8266.build_flags}
; -D WLED_WATCHDOG_TIMEOUT=10
;
; Create debug build (with remote debug)
; -D WLED_DEBUG_ALL ;; or
; -D WLED_DEBUG
; -D WLED_DEBUG_FS
; -D WLED_DEBUG_FX
; -D WLED_DEBUG_BUS
; -D WLED_DEBUG_PINMANAGER
; -D WLED_DEBUG_USERMODS
; -D WLED_DEBUG_MATH
; -D WLED_DEBUG_HOST='"192.168.0.100"'
; -D WLED_DEBUG_PORT=7868
;
Expand Down
10 changes: 5 additions & 5 deletions usermods/AHT10_v2/usermod_aht10.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ class UsermodAHT10 : public Usermod

String temp;
serializeJson(doc, temp);
DEBUG_PRINTLN(t);
DEBUG_PRINTLN(temp);
DEBUGUM_PRINTLN(t);
DEBUGUM_PRINTLN(temp);

mqtt->publish(t.c_str(), 0, true, temp.c_str());
}
Expand Down Expand Up @@ -146,10 +146,10 @@ class UsermodAHT10 : public Usermod
if (_lastStatus == AHT10_ERROR)
{
// Perform softReset and retry
DEBUG_PRINTLN(F("AHTxx returned error, doing softReset"));
DEBUGUM_PRINTLN(F("AHTxx returned error, doing softReset"));
if (!_aht->softReset())
{
DEBUG_PRINTLN(F("softReset failed"));
DEBUGUM_PRINTLN(F("softReset failed"));
return;
}

Expand Down Expand Up @@ -244,7 +244,7 @@ class UsermodAHT10 : public Usermod
top[F("MqttHomeAssistantDiscovery")] = _mqttHomeAssistant;
#endif

DEBUG_PRINTLN(F("AHT10 config saved."));
DEBUGUM_PRINTLN(F("AHT10 config saved."));
}

bool readFromConfig(JsonObject &root) override
Expand Down
42 changes: 21 additions & 21 deletions usermods/Animated_Staircase/Animated_Staircase.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ class Animated_Staircase : public Usermod {
bottomSensorState = bottomSensorRead; // change previous state
sensorChanged = true;
publishMqtt(true, bottomSensorState ? "on" : "off");
DEBUG_PRINTLN(F("Bottom sensor changed."));
DEBUGUM_PRINTLN(F("Bottom sensor changed."));
}

if (topSensorRead != topSensorState) {
topSensorState = topSensorRead; // change previous state
sensorChanged = true;
publishMqtt(false, topSensorState ? "on" : "off");
DEBUG_PRINTLN(F("Top sensor changed."));
DEBUGUM_PRINTLN(F("Top sensor changed."));
}

// Values read, reset the flags for next API call
Expand All @@ -202,8 +202,8 @@ class Animated_Staircase : public Usermod {
// If the bottom sensor triggered, we need to swipe up, ON
swipe = bottomSensorRead;

DEBUG_PRINT(F("ON -> Swipe "));
DEBUG_PRINTLN(swipe ? F("up.") : F("down."));
DEBUGUM_PRINT(F("ON -> Swipe "));
DEBUGUM_PRINTLN(swipe ? F("up.") : F("down."));

if (onIndex == offIndex) {
// Position the indices for a correct on-swipe
Expand All @@ -230,8 +230,8 @@ class Animated_Staircase : public Usermod {
swipe = lastSensor;
on = false;

DEBUG_PRINT(F("OFF -> Swipe "));
DEBUG_PRINTLN(swipe ? F("up.") : F("down."));
DEBUGUM_PRINT(F("OFF -> Swipe "));
DEBUGUM_PRINTLN(swipe ? F("up.") : F("down."));
}
}

Expand Down Expand Up @@ -273,12 +273,12 @@ class Animated_Staircase : public Usermod {

void enable(bool enable) {
if (enable) {
DEBUG_PRINTLN(F("Animated Staircase enabled."));
DEBUG_PRINT(F("Delay between steps: "));
DEBUG_PRINT(segment_delay_ms);
DEBUG_PRINT(F(" milliseconds.\nStairs switch off after: "));
DEBUG_PRINT(on_time_ms / 1000);
DEBUG_PRINTLN(F(" seconds."));
DEBUGUM_PRINTLN(F("Animated Staircase enabled."));
DEBUGUM_PRINT(F("Delay between steps: "));
DEBUGUM_PRINT(segment_delay_ms);
DEBUGUM_PRINT(F(" milliseconds.\nStairs switch off after: "));
DEBUGUM_PRINT(on_time_ms / 1000);
DEBUGUM_PRINTLN(F(" seconds."));

if (!useUSSensorBottom)
pinMode(bottomPIRorTriggerPin, INPUT_PULLUP);
Expand Down Expand Up @@ -311,7 +311,7 @@ class Animated_Staircase : public Usermod {
strip.trigger(); // force strip update
stateChanged = true; // inform external devices/UI of change
colorUpdated(CALL_MODE_DIRECT_CHANGE);
DEBUG_PRINTLN(F("Animated Staircase disabled."));
DEBUGUM_PRINTLN(F("Animated Staircase disabled."));
}
enabled = enable;
}
Expand Down Expand Up @@ -400,7 +400,7 @@ class Animated_Staircase : public Usermod {
staircase = root.createNestedObject(FPSTR(_name));
}
writeSensorsToJson(staircase);
DEBUG_PRINTLN(F("Staircase sensor state exposed in API."));
DEBUGUM_PRINTLN(F("Staircase sensor state exposed in API."));
}

/*
Expand All @@ -420,7 +420,7 @@ class Animated_Staircase : public Usermod {
}
if (en != enabled) enable(en);
readSensorsFromJson(staircase);
DEBUG_PRINTLN(F("Staircase sensor state read from API."));
DEBUGUM_PRINTLN(F("Staircase sensor state read from API."));
}
}

Expand Down Expand Up @@ -452,7 +452,7 @@ class Animated_Staircase : public Usermod {
staircase[FPSTR(_topEchoCm)] = topMaxDist;
staircase[FPSTR(_bottomEchoCm)] = bottomMaxDist;
staircase[FPSTR(_togglePower)] = togglePower;
DEBUG_PRINTLN(F("Staircase config saved."));
DEBUGUM_PRINTLN(F("Staircase config saved."));
}

/*
Expand All @@ -470,8 +470,8 @@ class Animated_Staircase : public Usermod {

JsonObject top = root[FPSTR(_name)];
if (top.isNull()) {
DEBUG_PRINT(FPSTR(_name));
DEBUG_PRINTLN(F(": No config found. (Using defaults.)"));
DEBUGUM_PRINT(FPSTR(_name));
DEBUGUM_PRINTLN(F(": No config found. (Using defaults.)"));
return false;
}

Expand All @@ -498,13 +498,13 @@ class Animated_Staircase : public Usermod {

togglePower = top[FPSTR(_togglePower)] | togglePower; // staircase toggles power on/off

DEBUG_PRINT(FPSTR(_name));
DEBUGUM_PRINT(FPSTR(_name));
if (!initDone) {
// first run: reading from cfg.json
DEBUG_PRINTLN(F(" config loaded."));
DEBUGUM_PRINTLN(F(" config loaded."));
} else {
// changing parameters from settings page
DEBUG_PRINTLN(F(" config (re)loaded."));
DEBUGUM_PRINTLN(F(" config (re)loaded."));
bool changed = false;
if ((oldUseUSSensorTop != useUSSensorTop) ||
(oldUseUSSensorBottom != useUSSensorBottom) ||
Expand Down
22 changes: 11 additions & 11 deletions usermods/BH1750_v2/usermod_bh1750.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class Usermod_BH1750 : public Usermod

String temp;
serializeJson(doc, temp);
DEBUG_PRINTLN(t);
DEBUG_PRINTLN(temp);
DEBUGUM_PRINTLN(t);
DEBUGUM_PRINTLN(temp);

mqtt->publish(t.c_str(), 0, true, temp.c_str());
}
Expand Down Expand Up @@ -152,11 +152,11 @@ class Usermod_BH1750 : public Usermod
mqttInitialized = true;
}
mqtt->publish(mqttLuminanceTopic.c_str(), 0, true, String(lux).c_str());
DEBUG_PRINTLN(F("Brightness: ") + String(lux) + F("lx"));
DEBUGUM_PRINTLN(F("Brightness: ") + String(lux) + F("lx"));
}
else
{
DEBUG_PRINTLN(F("Missing MQTT connection. Not publishing data"));
DEBUGUM_PRINTLN(F("Missing MQTT connection. Not publishing data"));
}
#endif
}
Expand Down Expand Up @@ -202,7 +202,7 @@ class Usermod_BH1750 : public Usermod
top[FPSTR(_HomeAssistantDiscovery)] = HomeAssistantDiscovery;
top[FPSTR(_offset)] = offset;

DEBUG_PRINTLN(F("BH1750 config saved."));
DEBUGUM_PRINTLN(F("BH1750 config saved."));
}

// called before setup() to populate properties from values stored in cfg.json
Expand All @@ -212,9 +212,9 @@ class Usermod_BH1750 : public Usermod
JsonObject top = root[FPSTR(_name)];
if (top.isNull())
{
DEBUG_PRINT(FPSTR(_name));
DEBUG_PRINT(F("BH1750"));
DEBUG_PRINTLN(F(": No config found. (Using defaults.)"));
DEBUGUM_PRINT(FPSTR(_name));
DEBUGUM_PRINT(F("BH1750"));
DEBUGUM_PRINTLN(F(": No config found. (Using defaults.)"));
return false;
}
bool configComplete = !top.isNull();
Expand All @@ -225,11 +225,11 @@ class Usermod_BH1750 : public Usermod
configComplete &= getJsonValue(top[FPSTR(_HomeAssistantDiscovery)], HomeAssistantDiscovery, false);
configComplete &= getJsonValue(top[FPSTR(_offset)], offset, 1);

DEBUG_PRINT(FPSTR(_name));
DEBUGUM_PRINT(FPSTR(_name));
if (!initDone) {
DEBUG_PRINTLN(F(" config loaded."));
DEBUGUM_PRINTLN(F(" config loaded."));
} else {
DEBUG_PRINTLN(F(" config (re)loaded."));
DEBUGUM_PRINTLN(F(" config (re)loaded."));
}

return configComplete;
Expand Down
24 changes: 12 additions & 12 deletions usermods/BME280_v2/usermod_bme280.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ class UsermodBME280 : public Usermod

String temp;
serializeJson(doc, temp);
DEBUG_PRINTLN(t);
DEBUG_PRINTLN(temp);
DEBUGUM_PRINTLN(t);
DEBUGUM_PRINTLN(temp);

mqtt->publish(t.c_str(), 0, true, temp.c_str());
}
Expand Down Expand Up @@ -187,23 +187,23 @@ class UsermodBME280 : public Usermod
if (!bme.begin())
{
sensorType = 0;
DEBUG_PRINTLN(F("Could not find BME280 I2C sensor!"));
DEBUGUM_PRINTLN(F("Could not find BME280 I2C sensor!"));
}
else
{
switch (bme.chipModel())
{
case BME280::ChipModel_BME280:
sensorType = 1;
DEBUG_PRINTLN(F("Found BME280 sensor! Success."));
DEBUGUM_PRINTLN(F("Found BME280 sensor! Success."));
break;
case BME280::ChipModel_BMP280:
sensorType = 2;
DEBUG_PRINTLN(F("Found BMP280 sensor! No Humidity available."));
DEBUGUM_PRINTLN(F("Found BMP280 sensor! No Humidity available."));
break;
default:
sensorType = 0;
DEBUG_PRINTLN(F("Found UNKNOWN sensor! Error!"));
DEBUGUM_PRINTLN(F("Found UNKNOWN sensor! Error!"));
}
}
}
Expand Down Expand Up @@ -413,7 +413,7 @@ class UsermodBME280 : public Usermod
top[F("PublishAlways")] = PublishAlways;
top[F("UseCelsius")] = UseCelsius;
top[F("HomeAssistantDiscovery")] = HomeAssistantDiscovery;
DEBUG_PRINTLN(F("BME280 config saved."));
DEBUGUM_PRINTLN(F("BME280 config saved."));
}

// Read Usermod Config Settings
Expand All @@ -424,8 +424,8 @@ class UsermodBME280 : public Usermod

JsonObject top = root[FPSTR(_name)];
if (top.isNull()) {
DEBUG_PRINT(F(_name));
DEBUG_PRINTLN(F(": No config found. (Using defaults.)"));
DEBUGUM_PRINT(F(_name));
DEBUGUM_PRINTLN(F(": No config found. (Using defaults.)"));
return false;
}
bool configComplete = !top.isNull();
Expand All @@ -445,13 +445,13 @@ class UsermodBME280 : public Usermod
configComplete &= getJsonValue(top[F("UseCelsius")], UseCelsius, true);
configComplete &= getJsonValue(top[F("HomeAssistantDiscovery")], HomeAssistantDiscovery, false);

DEBUG_PRINT(FPSTR(_name));
DEBUGUM_PRINT(FPSTR(_name));
if (!initDone) {
// first run: reading from cfg.json
DEBUG_PRINTLN(F(" config loaded."));
DEBUGUM_PRINTLN(F(" config loaded."));
} else {
// changing parameters from settings page
DEBUG_PRINTLN(F(" config (re)loaded."));
DEBUGUM_PRINTLN(F(" config (re)loaded."));

// Reset all known values
sensorType = 0;
Expand Down
Loading