software:firmware
MakAir Firmware
battery.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include "Arduino.h"
11 
22 #define RAW_BATTERY_MULTIPLIER 0.0075196210
23 
28 #define RAW_VOLTAGE_MAINS 3643u
29 
35 #define RAW_VOLTAGE_ON_BATTERY_HIGH 3590u
36 
41 #define RAW_VOLTAGE_HYSTERESIS 12u
42 
47 #define RAW_VOLTAGE_ON_BATTERY 3085u
48 
53 #define RAW_VOLTAGE_ON_BATTERY_LOW 3005u
54 
59 #define RAW_VOLTAGE_ON_BATTERY_NOT_STARTING_THRESHOLD 3191u
60 
65 #define RAW_VOLTAGE_ON_BATTERY_STOP_THRESHOLD 2660u
66 
68 #define BATTERY_MAX_SAMPLES 20u
69 
75 void initBattery();
76 
83 void batteryLoop(uint32_t p_cycleNumber);
84 
86 void updateBatterySample();
87 
93 void updateBatteryState(uint32_t p_cycleNumber);
94 
100 uint32_t getBatteryLevel();
101 
107 uint32_t getBatteryLevelX10();
108 
114 uint32_t getBatteryLevelX100();
115 
117 bool isBatteryVeryLow();
118 
121 
123 bool isMainsConnected();
124 
126 bool isMainsAvailable();
uint32_t getBatteryLevelX100()
Returns battery level x100 for better accuracy.
Definition: battery.cpp:129
uint32_t getBatteryLevelX10()
Returns battery level x10 for better accuracy.
Definition: battery.cpp:126
void updateBatteryState(uint32_t p_cycleNumber)
Updates battery states.
Definition: battery.cpp:71
bool isBatteryDeepDischarged()
Check if battery is deeply discharged.
Definition: battery.cpp:136
uint32_t getBatteryLevel()
Returns battery level.
Definition: battery.cpp:123
void updateBatterySample()
Handle battery voltage calculation.
Definition: battery.cpp:49
bool isMainsAvailable()
Check if the cable between power supply and expander input is connected.
Definition: battery.cpp:144
bool isBatteryVeryLow()
Check if battery level is very low.
Definition: battery.cpp:132
bool isMainsConnected()
Check if mains are connected.
Definition: battery.cpp:141
void initBattery()
Initialize battery abstraction.
Definition: battery.cpp:33
void batteryLoop(uint32_t p_cycleNumber)
Handle battery events.
Definition: battery.cpp:117