From 2622c0d0dede55f2b214c6f0c4f44069c41ffad0 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Wed, 25 Sep 2019 15:00:52 +0200 Subject: [PATCH] sanitize compiler warning power.cpp --- src/power.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/power.cpp b/src/power.cpp index 83748286..6b7f1f5e 100644 --- a/src/power.cpp +++ b/src/power.cpp @@ -207,15 +207,17 @@ uint16_t read_voltage() { #ifdef BAT_MEASURE_ADC // multisample ADC uint32_t adc_reading = 0; +#ifndef BAT_MEASURE_ADC_UNIT // ADC1 + for (int i = 0; i < NO_OF_SAMPLES; i++) { + adc_reading += adc1_get_raw(adc_channel); + } +#else // ADC2 int adc_buf = 0; for (int i = 0; i < NO_OF_SAMPLES; i++) { -#ifndef BAT_MEASURE_ADC_UNIT // ADC1 - adc_reading += adc1_get_raw(adc_channel); -#else // ADC2 ESP_ERROR_CHECK(adc2_get_raw(adc_channel, ADC_WIDTH_BIT_12, &adc_buf)); adc_reading += adc_buf; -#endif } +#endif adc_reading /= NO_OF_SAMPLES; // Convert ADC reading to voltage in mV voltage = esp_adc_cal_raw_to_voltage(adc_reading, adc_characs);