Skip to content

Commit

Permalink
Set 13 or 12bit depending on S3 or not
Browse files Browse the repository at this point in the history
  • Loading branch information
tyeth committed Sep 25, 2024
1 parent 6c7ff60 commit e900f61
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/analogIO/Wippersnapper_AnalogIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

#include "Wippersnapper_AnalogIO.h"
#include "Wippersnapper.h"

/***********************************************************************************/
/*!
Expand Down Expand Up @@ -89,7 +88,11 @@ void Wippersnapper_AnalogIO::setADCResolution(int resolution) {
_nativeResolution = 12;
#elif defined(ARDUINO_ARCH_ESP32)
scaleAnalogRead = true; // probably should be false, handled in bsp
_nativeResolution = 13; // S3 ADC is 13-bit, others are 12-bit
#if defined(ESP32S3)
_nativeResolution = 13; // S3 ADC is 13-bit, others are 12-bit
#else
_nativeResolution = 12;
#endif
#elif defined(ARDUINO_ARCH_RP2040)
scaleAnalogRead = true;
_nativeResolution = 10;
Expand Down Expand Up @@ -233,10 +236,8 @@ uint16_t Wippersnapper_AnalogIO::getPinValue(int pin) {
/**********************************************************/
float Wippersnapper_AnalogIO::getPinValueVolts(int pin) {
#ifdef ARDUINO_ARCH_ESP32
WS_DEBUG_PRINTLN("ESP32: Using analogReadMilliVolts()");
return analogReadMilliVolts(pin) / 1000.0;
#else
WS_DEBUG_PRINTLN("Using old getPinValueVolts()");
uint16_t rawValue = getPinValue(pin);
return rawValue * getAref() / 65536;
#endif
Expand Down

0 comments on commit e900f61

Please sign in to comment.