ESP_VCP/lib/uinterval/uinterval.cpp

37 lines
559 B
C++

extern "C" {
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
}
#include <Arduino.h>
#include "uinterval.h"
// Public Methods //////////////////////////////////////////////////////////////
uint32_t uInterval::remains(void)
{
return _timeout - (micros() - _timefrom);
}
uint32_t uInterval::elapsed(void)
{
return micros() - _timefrom;
}
bool uInterval::expired(void)
{
if ((micros() - _timefrom) >= _timeout)
return true;
else
return false;
}
void uInterval::set(uint32_t tmout)
{
_timefrom = micros();
_timeout = tmout;
}