-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathBoxBattery.h
71 lines (54 loc) · 1.59 KB
/
BoxBattery.h
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef BoxBattery_h
#define BoxBattery_h
#include "BaseHeader.h"
#include "JC_Button.h"
#include <EnhancedThread.h>
class BoxBattery : public EnhancedThread {
public:
struct BatteryStats {
bool charging;
bool low;
bool critical;
uint16_t adcRaw;
uint16_t voltage;
bool testActive;
uint16_t testActiveMinutes;
};
enum class BatteryEvent {
BAT_LOW,
BAT_CRITICAL,
CHR_CONNECT,
CHR_DISCONNECT
};
void
begin(),
loop(),
reloadConfig();
uint16_t getBatteryAdcRaw();
uint16_t getBatteryVoltage();
bool
isChargerConnected(),
isBatteryLow(),
isBatteryCritical();
void logBatteryStatus();
void startBatteryTest();
void stopBatteryTest();
bool batteryTestActive();
EnhancedThread batteryTestThread;
void doBatteryTestStep();
BoxBattery::BatteryStats getBatteryStats();
private:
uint32_t _batteryVoltageFactor;
uint16_t _batteryLowAdc;
uint16_t _batteryCriticalAdc;
Button _charger = Button(8, 25, false, false);
bool _wasLow;
bool _wasCritical;
uint16_t _batteryAdcRaw;
uint16_t _batteryAdcLowRaw;
const char* _batteryTestFilename = "/revvox/batteryTest.csv";
uint64_t _batteryTestStartMillis;
const static uint8_t BATTERY_VOLTAGE_PIN = 60;
void _readBatteryAdc();
};
#endif