#include "board.h"
#include <chrono>
#include <cstdio>
#include <thread>

using namespace std::chrono;
using Clock = steady_clock;
using TimeUnit = microseconds;

void Board::init_start() {}

void Board::enable_timer() {}

rl::TimePoint Board::get_now() {
  return duration_cast<TimeUnit>(Clock::now().time_since_epoch()).count();
}

void Board::toggle_led() {
  auto now = Clock::now();
  auto now_ms = duration_cast<TimeUnit>(now.time_since_epoch()).count();
  printf("%ld led toggle\n", now_ms);
}

void Board::delay() {
  printf("delay\n");
  using namespace std::chrono_literals;
  std::this_thread::sleep_for(1s);
}

void Board::sleep(const rl::TimePoint &until) {
  auto delta = until - get_now();
  std::this_thread::sleep_for(TimeUnit(delta));
}
