Add Heltec V3 battery read pin detect function (#5196)

This commit is contained in:
Aaron.Lee 2024-11-02 04:12:41 +08:00 committed by GitHub
parent a1ac358b0a
commit 336cdc0efe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -154,9 +154,16 @@ static void adcEnable()
#ifdef ADC_CTRL // enable adc voltage divider when we need to read #ifdef ADC_CTRL // enable adc voltage divider when we need to read
#ifdef ADC_USE_PULLUP #ifdef ADC_USE_PULLUP
pinMode(ADC_CTRL, INPUT_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 #else
pinMode(ADC_CTRL, OUTPUT); pinMode(ADC_CTRL, OUTPUT);
digitalWrite(ADC_CTRL, ADC_CTRL_ENABLED); digitalWrite(ADC_CTRL, ADC_CTRL_ENABLED);
#endif
#endif #endif
delay(10); delay(10);
#endif #endif
@ -167,10 +174,14 @@ static void adcDisable()
#ifdef ADC_CTRL // disable adc voltage divider when we need to read #ifdef ADC_CTRL // disable adc voltage divider when we need to read
#ifdef ADC_USE_PULLUP #ifdef ADC_USE_PULLUP
pinMode(ADC_CTRL, INPUT_PULLDOWN); pinMode(ADC_CTRL, INPUT_PULLDOWN);
#else
#ifdef HELTEC_V3
pinMode(ADC_CTRL,ANALOG);
#else #else
digitalWrite(ADC_CTRL, !ADC_CTRL_ENABLED); digitalWrite(ADC_CTRL, !ADC_CTRL_ENABLED);
#endif #endif
#endif #endif
#endif
} }
#endif #endif