diff --git a/src/Power.cpp b/src/Power.cpp index 9887ca6004..08faa38124 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -285,7 +285,7 @@ class AnalogBatteryLevel : public HasBatteryLevel // ADC2 wifi bug workaround not required, breaks compile // On ESP32S3, ADC2 can take turns with Wifi (?) - int32_t adc_buf; + int adc_buf; esp_err_t read_result; // Multiple samples @@ -293,7 +293,7 @@ class AnalogBatteryLevel : public HasBatteryLevel adc_buf = 0; read_result = -1; - read_result = adc2_get_raw(adc_channel, ADC_WIDTH_BIT_12, &adc_buf); + read_result = adc_oneshot_read(adc_unit_handle, adc_channel, &adc_buf); if (read_result == ESP_OK) { raw += adc_buf; raw_c++; // Count valid samples diff --git a/src/platform/esp32/quirks.h b/src/platform/esp32/quirks.h index ccdf499d76..b4858a3467 100644 --- a/src/platform/esp32/quirks.h +++ b/src/platform/esp32/quirks.h @@ -1,4 +1,4 @@ -#if QUIRK_RTTTL +#if QUIRK_RTTTL || QUIRK_LOVYAN #define ledcSetup(ch, freq, res) \ uint32_t __freq = freq; \ uint8_t __res = res; \ diff --git a/src/power.h b/src/power.h index be68934137..5e4505bf3d 100644 --- a/src/power.h +++ b/src/power.h @@ -7,8 +7,10 @@ #include #include #include -#include #include +#ifndef CONFIG_IDF_TARGET_ESP32C3 +#include +#endif #endif #ifndef NUM_OCV_POINTS diff --git a/variants/heltec_wireless_paper_v1/variant.h b/variants/heltec_wireless_paper_v1/variant.h index 29b8bbbd14..f15a71cd88 100644 --- a/variants/heltec_wireless_paper_v1/variant.h +++ b/variants/heltec_wireless_paper_v1/variant.h @@ -33,7 +33,7 @@ #define ADC_CHANNEL ADC2_GPIO20_CHANNEL #define ADC_MULTIPLIER 2 // Voltage divider is roughly 1:1 #define BAT_MEASURE_ADC_UNIT 2 // Use ADC2 -#define ADC_ATTENUATION ADC_ATTEN_DB_11 // Voltage divider output is quite high +#define ADC_ATTENUATION ADC_ATTEN_DB_12 // Voltage divider output is quite high #define USE_SX1262 @@ -54,4 +54,4 @@ #define SX126X_RESET LORA_RESET #define SX126X_DIO2_AS_RF_SWITCH -#define SX126X_DIO3_TCXO_VOLTAGE 1.8 +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 \ No newline at end of file