Skip to content

Commit c7dd4a7

Browse files
committed
potentiometer: check that pin supports ananlogread
newer esp32 frameworks will throw lots of warnings when trying to read from a non-analog pin.
1 parent 111f172 commit c7dd4a7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

wled00/button.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ void handleAnalog(uint8_t b)
156156
#ifdef ESP8266
157157
rawReading = analogRead(A0) << 2; // convert 10bit read to 12bit
158158
#else
159+
if ((btnPin[b] < 0) || (digitalPinToAnalogChannel(btnPin[b]) < 0)) return; // pin must support analog ADC - newer esp32 frameworks throw lots of warnings otherwise
159160
rawReading = analogRead(btnPin[b]); // collect at full 12bit resolution
160161
#endif
161162
yield(); // keep WiFi task running - analog read may take several millis on ESP8266
@@ -188,7 +189,7 @@ void handleAnalog(uint8_t b)
188189
if (aRead == 0) {
189190
briLast = bri;
190191
bri = 0;
191-
} else{
192+
} else {
192193
bri = aRead;
193194
}
194195
} else if (macroDoublePress[b] == 249) {

0 commit comments

Comments
 (0)