You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: usermods/Battery/usermod_v2_Battery.h
+29-12Lines changed: 29 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -60,9 +60,9 @@ class UsermodBattery : public Usermod
60
60
bool initializing = true;
61
61
62
62
// strings to reduce flash memory usage (used more than twice)
63
-
staticconstchar _name[];
63
+
//static const char _name[];
64
64
staticconstchar _readInterval[];
65
-
staticconstchar _enabled[];
65
+
//static const char _enabled[];
66
66
staticconstchar _threshold[];
67
67
staticconstchar _preset[];
68
68
staticconstchar _duration[];
@@ -117,6 +117,7 @@ class UsermodBattery : public Usermod
117
117
floatreadVoltage()
118
118
{
119
119
#ifdef ARDUINO_ARCH_ESP32
120
+
if ((batteryPin <0) || !pinManager.isPinAnalog(batteryPin)) return(-1.0f); // WLEDMM avoid reading from invalid pin
120
121
// use calibrated millivolts analogread on esp32 (150 mV ~ 2450 mV default attentuation) and divide by 1000 to get from milivolts to volts and multiply by voltage multiplier and apply calibration value
@@ -127,26 +128,29 @@ class UsermodBattery : public Usermod
127
128
128
129
public:
129
130
//Functions called by WLED
131
+
UsermodBattery(constchar *name, bool enabled):Usermod(name, enabled) {} //WLEDMM: this shouldn't be necessary (passthrough of constructor), maybe because Usermod is an abstract class
130
132
131
133
/*
132
134
* setup() is called once at boot. WiFi is not yet connected at this point.
133
135
* You can use it to initialize variables, sensors or similar.
134
136
*/
135
137
voidsetup()
136
138
{
139
+
if (!enabled) return; // WLEDMM
137
140
#ifdef ARDUINO_ARCH_ESP32
138
141
bool success = false;
139
142
DEBUG_PRINTLN(F("Allocating battery pin..."));
140
-
if (batteryPin >= 0 && digitalPinToAnalogChannel(batteryPin) >= 0)
143
+
if ((batteryPin >= 0) && (digitalPinToAnalogChannel(batteryPin) >= 0))
141
144
if (pinManager.allocatePin(batteryPin, false, PinOwner::UM_Battery)) {
Copy file name to clipboardExpand all lines: usermods/RTC/usermod_rtc.h
+23-8Lines changed: 23 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -8,21 +8,25 @@
8
8
9
9
#defineRTC_DELTA2// only modify RTC time if delta exceeds this number of seconds
10
10
11
-
//Connect DS1307 to standard I2C pins (ESP32: GPIO 21 (SDA)/GPIO 22 (SCL))
11
+
//Connect DS1307 or DS3231 to standard I2C pins (ESP32: GPIO 21 (SDA)/GPIO 22 (SCL))
12
12
13
13
classRTCUsermod : publicUsermod {
14
14
private:
15
15
unsignedlong lastTime = 0;
16
-
booldisabled = false;
16
+
boolRTCfound = false;// WLEDMM to prevent errors after anabling the usermod (Wire.cpp:526] write(): NULL TX buffer pointer)
17
17
public:
18
18
19
+
RTCUsermod(constchar *name, bool enabled):Usermod(name, enabled) {} //WLEDMM: this shouldn't be necessary (passthrough of constructor), maybe because Usermod is an abstract class
0 commit comments