~aleteoryx/muditaos

ref: 36b0228de2c847f7e0f8bf7a215539609c82ebcd muditaos/module-services/service-evtmgr/battery/BatteryState.hpp -rw-r--r-- 956 bytes
36b0228d — Lefucjusz [BH-2100] Fix crash when seeking in large MP3 file 1 year, 1 month 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-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/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;
};