mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 05:06:32 +00:00
Fix Non-ESP32 Analog read resolution
This commit is contained in:
parent
b9fcfa86c9
commit
2f33f8e5a8
@ -35,6 +35,7 @@
|
|||||||
#define ANALOG_RANGE 1023 // 4095 = 12, 2047 = 11, 1023 = 10
|
#define ANALOG_RANGE 1023 // 4095 = 12, 2047 = 11, 1023 = 10
|
||||||
#define ANALOG_PERCENT 10 // backward compatible div10 range
|
#define ANALOG_PERCENT 10 // backward compatible div10 range
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#undef ANALOG_RESOLUTION
|
#undef ANALOG_RESOLUTION
|
||||||
#define ANALOG_RESOLUTION 12 // 12 = 4095, 11 = 2047, 10 = 1023
|
#define ANALOG_RESOLUTION 12 // 12 = 4095, 11 = 2047, 10 = 1023
|
||||||
@ -305,9 +306,7 @@ void AdcInit(void) {
|
|||||||
|
|
||||||
if (Adcs.present) {
|
if (Adcs.present) {
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
analogReadResolution(ANALOG_RESOLUTION); // Default 12 bits (0 - 4095)
|
||||||
analogSetWidth(ANALOG_RESOLUTION); // Default 12 bits (0 - 4095)
|
|
||||||
#endif // CONFIG_IDF_TARGET_ESP32
|
|
||||||
analogSetAttenuation(ADC_11db); // Default 11db
|
analogSetAttenuation(ADC_11db); // Default 11db
|
||||||
#endif
|
#endif
|
||||||
for (uint32_t idx = 0; idx < Adcs.present; idx++) {
|
for (uint32_t idx = 0; idx < Adcs.present; idx++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user