~aleteoryx/muditaos

ref: 44d3306f280cc7d6daa718d2a9f6323e48f54616 muditaos/module-services/service-evtmgr/battery/BatteryState.hpp -rw-r--r-- 944 bytes
44d3306f — rrandomsky [CP-1059] Fix for erase only sensitive data from logs 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <memory>
#include <functional>
#include <Units.hpp>

namespace sys
{
    class Service;
} // namespace sys

class BatteryState
{
  public:
    enum class ChargingState
    {
        Charging,
        ChargingDone,
        Discharging,
        PluggedNotCharging
    };

    enum class State
    {
        Normal,
        Shutdown,
        CriticalCharging,
        CriticalNotCharging
    };

    struct Thresholds
    {
        units::Percent critical;
        units::Percent shutdown;
    };

    using NotifyStateChangedCallback = std::function<void(State)>;

    BatteryState(sys::Service *service, NotifyStateChangedCallback notifyCallback, Thresholds thresholds);

    void check(ChargingState state, float soc);

  private:
    class Pimpl;
    std::shared_ptr<Pimpl> pimpl;
};