batt display, low batt shutdown, timeout shutdown

This commit is contained in:
2021-03-27 14:00:37 +01:00
parent 79edcef8ce
commit 0146c32da4
14 changed files with 4962 additions and 3865 deletions

75
src/power.cpp Normal file
View File

@@ -0,0 +1,75 @@
#include "power.h"
#include "board.h"
#include "rtc.h"
#include "low_Power.h"
#include "led.h"
#ifdef VBATTPIN
#include "Battery.h"
Battery battery(2500, 4160, VBATTPIN);
#endif
void initBattery(void)
{
#ifdef VBATTPIN
battery.begin(3300, (R12+R13)/R13); //R1 = 220K, R2 = 100K, factor = (R1+R2)/R2
#endif
}
uint16_t batteryGetVoltage( void )
{
return battery.voltage();
}
void batterydisplay(void)
{
#ifdef VBATTPIN
uint16_t currentlevel = battery.level();
uint16_t currentvoltage = batteryGetVoltage();
if(currentvoltage)
{
if (currentlevel > 90)
{
turnOnLed(3);
}
if (currentlevel > 50)
{
turnOnLed(2);
}
if (currentlevel > 20)
{
turnOnLed(1);
}
}
#endif
}
void batteryCheck(void)
{
#ifdef VBATTPIN
if (battery.level() < 10)
{
for( int i = 0; i < 10;i++)
{
turnOnLed(1);
delay(300);
turnOffLed(1);
delay(300);
}
delay(5000);
shutdown();
}
#endif
}
//low power
void initLowPower(void)
{
LowPower_init();
}
void shutdown(void)
{
LowPower_shutdown();
}