Tezzeret  1
Tezzeret
BatteryMonitor.hpp
1 
2 #ifndef BATTERY_MONITOR_H
3 #define BATTERY_MONITOR_H
4 
5 #include <ti/drivers/I2C.h>
6 
7 #define Board_AD7993_ADDR (0x21)
8 #define AD7998_I2C_ADDRESS (0x21)
9 #define AD4151_I2C_ADDRESS (0x68)
10 // or it could be ...
11 // #define AD7998_I2C_ADDRESS (0x22)
12 
13 namespace Geometrics {
14 
16 public:
17  double VoltageTotal;
18  double VoltageCell1;
19  double VoltageCell2;
20  double VoltageCell3;
21  double Current;
22 };
23 
24 
25 
26 
28 {
29 public:
30  enum BatteryState {
31  bsFirstOn = 0, // Power up only
32  bsPowerOff, // Just as we switch off
33  bsNoMag, // No mag but stay on
34  bsLow, // About 30% left
35  bsNormal, // Almost always here
36  bsWiFiOnly, // Only WiFi powered
37  };
38  enum BatteryLevel {
39  blUnknown,
40  blNormal,
41  blLow,
42  blVeryLow,
43  blCritical
44  };
45 
46 public:
47  static void Initialize (const I2C_Handle offboardI2cHandle);
48  static enum BatteryState VoltageLogic(float temperatureDegreesC);
49  static void InitADC (void);
50  static void ConvertAllAdcChannels (void);
51  static int TemperatureAdjustedBatteryPercentage (float batteryVoltage, float temperatureDegreesC);
52  static float Get30PercentVoltage (float temperatureDegreesC);
53  static double FindLowestCell (int batteryIndex);
54 
55  static BatteryLevel sBatteryLevel;
56  static unsigned sBatteryPercentage;
57  static BatteryState sBatteryState;
58  static float sVoltageForPercentageCalc;
59 
60  #if (GEO_7998_BATTERY_MONITOR == GEO_TRUE)
61  static BatteryMonitorReadings sReadings[2];
62  #else
63  static BatteryMonitorReadings sReadings[1];
64  #endif
65 };
66 
67 }
68 
69 #endif
Definition: BatteryMonitor.hpp:15
Definition: BatteryMonitor.hpp:28
GmApp/GmLoggingApp.hpp>
Definition: Analogs.hpp:47