13 #include "../includes/battery.h"
19 #include "../includes/alarm_controller.h"
20 #include "../includes/debug.h"
21 #include "../includes/parameters.h"
AlarmController alarmController
Instance of the alarm controller.
uint32_t getBatteryLevelX100()
Returns battery level x100 for better accuracy.
uint32_t getBatteryLevelX10()
Returns battery level x10 for better accuracy.
void updateBatteryState(uint32_t p_cycleNumber)
Updates battery states.
static bool isRunningOnBattery
bool isBatteryDeepDischarged()
Check if battery is deeply discharged.
static uint32_t batteryCurrentSample
uint32_t getBatteryLevel()
Returns battery level.
static uint32_t rawBatteryMeanVoltage
static uint32_t batteryTotalSamples
void updateBatterySample()
Handle battery voltage calculation.
bool isMainsAvailable()
Check if the cable between power supply and expander input is connected.
bool isBatteryVeryLow()
Check if battery level is very low.
bool isMainsConnected()
Check if mains are connected.
static bool mainsConnected
static uint32_t rawBatterySample[BATTERY_MAX_SAMPLES]
static bool mainsConnectedAvailable
void initBattery()
Initialize battery abstraction.
void batteryLoop(uint32_t p_cycleNumber)
Handle battery events.
#define RAW_VOLTAGE_ON_BATTERY_HIGH
RCM_SW_16 Expected voltage in volts when power cord is unplugged = 27 => 27 / RAW_BATTERY_MULTIPLIER.
#define BATTERY_MAX_SAMPLES
Number of samples of the moving average.
#define RAW_BATTERY_MULTIPLIER
The divider between real battery voltage and STM32 input is 8.2K-1k resistors So, the multiplier is 1...
#define RAW_VOLTAGE_ON_BATTERY_NOT_STARTING_THRESHOLD
Below this value, the machine wont start = 22 => 22 / RAW_BATTERY_MULTIPLIER.
#define RAW_VOLTAGE_ON_BATTERY_LOW
RCM_SW_12 = 22,6 => 22,6 / RAW_BATTERY_MULTIPLIER.
#define RAW_VOLTAGE_MAINS
Expected voltage in volts when power cord is plugged 27,4 V => 27,4 / RAW_BATTERY_MULTIPLIER.
#define RAW_VOLTAGE_ON_BATTERY_STOP_THRESHOLD
Below this value, the machine will stop immediately = 20 => 20 / RAW_BATTERY_MULTIPLIER.
#define RAW_VOLTAGE_HYSTERESIS
Hysteresis is used to prevent fast switching when voltage is at the limit of 2 states analogRead(PIN)...
#define RAW_VOLTAGE_ON_BATTERY
RCM_SW_11 = 23,2 => 23,2 / RAW_BATTERY_MULTIPLIER.
void detectedAlarm(uint8_t p_alarmCode, uint32_t p_cycleNumber, uint32_t p_expected, uint32_t p_measured)
Mark a specific alarm as detected.
void notDetectedAlarm(uint8_t p_alarmCode)
Reset detection of a specific alarm.
#define ADC_RESOLUTION_MAKAIR
#define PIN_IN_MAINS_CONNECTED
#define PIN_IN_CONNECTION_TO_SUPPLY_OK