t1000 : power bat sensor only when necessary

This commit is contained in:
Florent 2025-04-10 22:00:25 +02:00
parent a5f210779f
commit 96d6ffefad
2 changed files with 5 additions and 2 deletions

View file

@ -29,9 +29,12 @@ public:
uint16_t getBattMilliVolts() override {
#ifdef BATTERY_PIN
digitalWrite(PIN_3V3_EN, HIGH);
analogReference(AR_INTERNAL_3_0);
analogReadResolution(12);
delay(10);
float volts = (analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE) / 4096;
digitalWrite(PIN_3V3_EN, LOW);
analogReference(AR_DEFAULT); // put back to default
analogReadResolution(10);