From 547f99787ffaac42500803409cd8a450c9dfbeeb Mon Sep 17 00:00:00 2001 From: GuruSR Date: Mon, 29 Nov 2021 19:57:51 -0500 Subject: [PATCH] Unified Version 1.3.4. --- src/Watchy_GSR.cpp | 15 +++++++-------- src/Watchy_GSR.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Watchy_GSR.cpp b/src/Watchy_GSR.cpp index 521ded0..1a2f3af 100644 --- a/src/Watchy_GSR.cpp +++ b/src/Watchy_GSR.cpp @@ -2234,14 +2234,13 @@ void WatchyGSR::_bmaConfig() { // sensor.enableWakeupInterrupt(); } -float WatchyGSR::getBatteryVoltage(){ - float A, B, C, D; - WatchyBatt Batt; - A = Batt.Read(RTC) - 0.0125; - B = Batt.Read(RTC) - 0.0125; - C = Batt.Read(RTC) - 0.0125; - D = Batt.Read(RTC) - 0.0125; - return (((A + B + C + D) / 16384.0) * 7.23); +float WatchyGSR::getBatteryVoltage(){ return ((BatteryRead() - 0.0125) + (BatteryRead() - 0.0125) + (BatteryRead() - 0.0125) + (BatteryRead() - 0.0125)) / 4; } +float WatchyGSR::BatteryRead(){ + if (RTC.rtcType == DS3231) + return analogReadMilliVolts(V10_ADC_PIN) / 500.0f; // Battery voltage goes through a 1/2 divider. + else if (RTC.rtcType == PCF8563) + return analogReadMilliVolts(V15_ADC_PIN) / 500.0f; + return 0.0; } uint16_t WatchyGSR::_readRegister(uint8_t address, uint8_t reg, uint8_t *data, uint16_t len) { diff --git a/src/Watchy_GSR.h b/src/Watchy_GSR.h index 65076bd..6e35876 100644 --- a/src/Watchy_GSR.h +++ b/src/Watchy_GSR.h @@ -17,7 +17,6 @@ #include #include #include -#include "WatchyBattery.h" #include "GxEPD2_BW.h" #include #include @@ -49,6 +48,7 @@ class WatchyGSR{ void handleButtonPress(uint8_t Pressed); virtual void deepSleep(); float getBatteryVoltage(); + float BatteryRead(); bool IsDark(); IRAM_ATTR void handleInterrupt(); private: