Skip to content

Commit 7982926

Browse files
committed
Add a bit of logging to analogIO + fix PicoW
1 parent 3a64cec commit 7982926

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/components/analogIO/Wippersnapper_AnalogIO.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ void Wippersnapper_AnalogIO::setADCResolution(int resolution) {
8989
#elif defined(ARDUINO_ARCH_ESP32)
9090
scaleAnalogRead = true;
9191
_nativeResolution = 13;
92+
#elif defined(ARDUINO_ARCH_RP2040)
93+
scaleAnalogRead = true;
94+
_nativeResolution = 10;
95+
#else
96+
scaleAnalogRead = true;
97+
_nativeResolution = 10;
9298
#endif
9399

94100
_adcResolution = resolution;
@@ -101,7 +107,11 @@ void Wippersnapper_AnalogIO::setADCResolution(int resolution) {
101107
The scaled analog resolution, in bits.
102108
*/
103109
/***********************************************************************************/
104-
int Wippersnapper_AnalogIO::getADCresolution() { return _adcResolution; }
110+
int Wippersnapper_AnalogIO::getADCresolution() {
111+
WS_DEBUG_PRINT("Returning ADC resolution: ");
112+
WS_DEBUG_PRINTLN(_adcResolution);
113+
return _adcResolution;
114+
}
105115

106116
/***********************************************************************************/
107117
/*!
@@ -110,7 +120,11 @@ int Wippersnapper_AnalogIO::getADCresolution() { return _adcResolution; }
110120
The native analog resolution, in bits.
111121
*/
112122
/***********************************************************************************/
113-
int Wippersnapper_AnalogIO::getNativeResolution() { return _nativeResolution; }
123+
int Wippersnapper_AnalogIO::getNativeResolution() {
124+
WS_DEBUG_PRINT("Returning native ADC resolution: ");
125+
WS_DEBUG_PRINTLN(_nativeResolution);
126+
return _nativeResolution;
127+
}
114128

115129
/***********************************************************************************/
116130
/*!
@@ -205,9 +219,13 @@ void Wippersnapper_AnalogIO::deinitAnalogPin(
205219
uint16_t Wippersnapper_AnalogIO::getPinValue(int pin) {
206220
// get pin value
207221
uint16_t value = analogRead(pin);
208-
222+
WS_DEBUG_PRINT("Analog Pin (#");
223+
WS_DEBUG_PRINT(pin);
224+
WS_DEBUG_PRINT(") read: ");
225+
WS_DEBUG_PRINTLN(value);
209226
// scale by the ADC resolution manually if not implemented by BSP
210227
if (scaleAnalogRead) {
228+
WS_DEBUG_PRINTLN("Scaling analog read value...");
211229
if (getADCresolution() > getNativeResolution()) {
212230
value = value << (getADCresolution() - getNativeResolution());
213231
} else {

0 commit comments

Comments
 (0)