Fix Non-ESP32 Analog read resolution

This commit is contained in:
Theo Arends 2024-07-25 18:04:01 +02:00
parent b9fcfa86c9
commit 2f33f8e5a8

View File

@ -35,6 +35,7 @@
#define ANALOG_RANGE 1023 // 4095 = 12, 2047 = 11, 1023 = 10
#define ANALOG_PERCENT 10 // backward compatible div10 range
#endif // ESP8266
#ifdef ESP32
#undef ANALOG_RESOLUTION
#define ANALOG_RESOLUTION 12 // 12 = 4095, 11 = 2047, 10 = 1023
@ -305,10 +306,8 @@ void AdcInit(void) {
if (Adcs.present) {
#ifdef ESP32
#if CONFIG_IDF_TARGET_ESP32
analogSetWidth(ANALOG_RESOLUTION); // Default 12 bits (0 - 4095)
#endif // CONFIG_IDF_TARGET_ESP32
analogSetAttenuation(ADC_11db); // Default 11db
analogReadResolution(ANALOG_RESOLUTION); // Default 12 bits (0 - 4095)
analogSetAttenuation(ADC_11db); // Default 11db
#endif
for (uint32_t idx = 0; idx < Adcs.present; idx++) {
AdcGetSettings(idx);