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

View File

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