#include "delay.h"

using namespace pinetime;
using namespace pinetime::virtual_timer;

Delay::Delay()
    : VirtualTimer(0)
    , pause(false)
{
}

void Delay::delay(uint64_t time_ms)
{
    this->pause = true;
    this->timer_set_period_ms(time_ms);
    this->timer_enable();
    while(this->pause) {
        // FIXME: Low power
        asm volatile("nop");
    }
    this->timer_disable();
}

void Delay::notification()
{
    this->pause = false;
}
