1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-16 22:28:57 +00:00
CLK/OSBindings/Qt/timer.cpp

21 lines
447 B
C++
Raw Normal View History

#include "timer.h"
#include "../../ClockReceiver/TimeTypes.hpp"
#include <algorithm>
#include <QDebug>
Timer::Timer(QObject *parent) : QObject(parent) {}
void Timer::setMachine(MachineTypes::TimedMachine *machine) {
this->machine = machine;
}
void Timer::tick() {
const auto now = Time::nanos_now();
const auto duration = std::min(now - lastTickNanos, int64_t(500'000));
lastTickNanos = now;
machine->run_for(double(duration) / 1e9);
}