summaryrefslogtreecommitdiff
path: root/src/Components/Battery/BatteryController.h
blob: 5c631dc257621d1790894e3552b133fc3ef1a428 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once
#include <drivers/include/nrfx_saadc.h>


namespace Pinetime {
  namespace Controllers {
    class Battery {
      public:
        void Init();
        void Update();
        float PercentRemaining() const { return percentRemaining; }
        float Voltage() const { return voltage; }
        bool IsCharging() const { return isCharging; }
        bool IsPowerPresent() const { return isPowerPresent; }

      private:
        static void SaadcEventHandler(nrfx_saadc_evt_t const * p_event);
        float percentRemaining = 0.0f;
        float voltage = 0.0f;
        bool isCharging = false;
        bool isPowerPresent = false;
    };
  }
}