Skip to content

Commit

Permalink
potentiometer: check that pin supports ananlogread
Browse files Browse the repository at this point in the history
newer esp32 frameworks will throw lots of warnings when trying to read from a non-analog pin.
  • Loading branch information
softhack007 committed Sep 7, 2023
1 parent 111f172 commit c7dd4a7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion wled00/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void handleAnalog(uint8_t b)
#ifdef ESP8266
rawReading = analogRead(A0) << 2; // convert 10bit read to 12bit
#else
if ((btnPin[b] < 0) || (digitalPinToAnalogChannel(btnPin[b]) < 0)) return; // pin must support analog ADC - newer esp32 frameworks throw lots of warnings otherwise
rawReading = analogRead(btnPin[b]); // collect at full 12bit resolution
#endif
yield(); // keep WiFi task running - analog read may take several millis on ESP8266
Expand Down Expand Up @@ -188,7 +189,7 @@ void handleAnalog(uint8_t b)
if (aRead == 0) {
briLast = bri;
bri = 0;
} else{
} else {
bri = aRead;
}
} else if (macroDoublePress[b] == 249) {
Expand Down

0 comments on commit c7dd4a7

Please sign in to comment.