-
Notifications
You must be signed in to change notification settings - Fork 8
/
power.h
58 lines (42 loc) · 993 Bytes
/
power.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
/*
* Flybrix Flight Controller -- Copyright 2018 Flying Selfie Inc. d/b/a Flybrix
*
* http://www.flybrix.com
*/
#ifndef power_h
#define power_h
#include <Arduino.h>
#include <ADC.h>
class PowerMonitor {
public:
PowerMonitor();
void updateLevels();
float totalPower() const;
// battery power in mW
float electronicsPower() const;
// electronics power in mW
uint16_t rawV0() const {
return V0_;
}
uint16_t rawI0() const {
return I0_;
}
uint16_t rawI1() const {
return I1_;
}
float V0() const;
// measured at battery input terminal in V
float I0() const;
// total current from battery in mA
float I1() const;
// electronics load current in mA; assume DC/DC output voltage is 3.6V
private:
ADC adc;
uint16_t getV0Raw();
uint16_t getI0Raw();
uint16_t getI1Raw();
uint16_t V0_;
uint16_t I0_;
uint16_t I1_;
}; // class PowerMonitor
#endif