#include <stdlib.h>
#include "platform.h"
#include "watch.h"
Watch::Watch(void)
{
Reset();
}
void Watch::Start()
{
system_time(&_startTime);
_isRunning = true;
}
void Watch::Stop()
{
system_time(&_stopTime);
_isRunning = false;
}
void Watch::Reset()
{
_startTime = _stopTime;
_isRunning = false;
}
// Get elapsed time in millisec
uint64_t Watch::GetElapsedTime()
{
if(_isRunning)
{
sys_time_t now;
system_time(&now);
return time_to_msec(now)-time_to_msec(_startTime);
}
return time_to_msec(_stopTime)-time_to_msec(_startTime);
}
uint64_t Watch::GetRandomSeed()
{
sys_time_t now;
system_time(&now);
return time_to_msec(now);
}