From b3865213c689cec683663207c6136902a936665a Mon Sep 17 00:00:00 2001 From: "Aaron.Lee" <32860565+Heltec-Aaron-Lee@users.noreply.github.com> Date: Sat, 2 Nov 2024 04:12:41 +0800 Subject: [PATCH] Add Heltec V3 battery read pin detect function (#5196) --- src/Power.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Power.cpp b/src/Power.cpp index 02a07e620c..96399f3883 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -154,9 +154,16 @@ static void adcEnable() #ifdef ADC_CTRL // enable adc voltage divider when we need to read #ifdef ADC_USE_PULLUP pinMode(ADC_CTRL, INPUT_PULLUP); +#else +#ifdef HELTEC_V3 + pinMode(ADC_CTRL,INPUT); + uint8_t adc_ctl_enable_value=!(digitalRead(ADC_CTRL)); + pinMode(ADC_CTRL, OUTPUT); + digitalWrite(ADC_CTRL, adc_ctl_enable_value); #else pinMode(ADC_CTRL, OUTPUT); digitalWrite(ADC_CTRL, ADC_CTRL_ENABLED); +#endif #endif delay(10); #endif @@ -167,10 +174,14 @@ static void adcDisable() #ifdef ADC_CTRL // disable adc voltage divider when we need to read #ifdef ADC_USE_PULLUP pinMode(ADC_CTRL, INPUT_PULLDOWN); +#else +#ifdef HELTEC_V3 + pinMode(ADC_CTRL,ANALOG); #else digitalWrite(ADC_CTRL, !ADC_CTRL_ENABLED); #endif #endif +#endif } #endif