Added a new getUpTime() method which returns the board running time

This commit is contained in:
anschrammh 2019-11-17 11:02:21 +01:00
parent cd46e089f1
commit efadce0b41
2 changed files with 14 additions and 2 deletions

View File

@ -16,7 +16,7 @@ _error(0)
{
//We set the gpio up
initGPIO();
Serial.begin(500000, SERIAL_8N1, SERIAL_TX_ONLY);
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
Serial.println();
delay(200);
@ -28,6 +28,8 @@ _error(0)
_screenManager.init();
_connectivityManager = new ConnectivityManager(_sdCardManager);
if(!_pcf.begin()){_error |= IO_INIT_ERR;}
_powerUpTime = _rtcManager.getDateTime();
}
SAB::SAB(const BoardConfig boardConfig, const unsigned int webServerPort, const unsigned int ftpServerPort) : _boardConfig(boardConfig),
@ -47,7 +49,7 @@ _error(0)
{
//We set the gpio up
initGPIO();
Serial.begin(500000, SERIAL_8N1, SERIAL_TX_ONLY);
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
Serial.println();
delay(200);
//We initialize the pins for the I2C communication
@ -58,6 +60,8 @@ _error(0)
_screenManager.init();
_connectivityManager = new ConnectivityManager(_sdCardManager);
if(!_pcf.begin()){_error |= IO_INIT_ERR;}
_powerUpTime = _rtcManager.getDateTime();
}
void SAB::initGPIO()
@ -115,6 +119,11 @@ PowerManager& SAB::getPowerManager()
return _powerManager;
}
TimeSpan SAB::getUpTime()
{
return _rtcManager.getDateTime() - _powerUpTime;
}
BoardConfig SAB::getBoardConfig() const
{
return _boardConfig;

View File

@ -39,7 +39,9 @@ class SAB
IOManager& getIoManager();
TaskSchedulerManager& getTaskSchedulerManager();
PowerManager& getPowerManager();
TimeSpan getUpTime();
BoardConfig getBoardConfig() const;
const char *getSoftVersion() const;
unsigned char getError() const;
private:
@ -60,6 +62,7 @@ class SAB
TaskSchedulerManager _taskSchedulerManager;
PowerManager _powerManager;
DateTime _powerUpTime;
uint8_t _error;
};