1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00
CLK/OSBindings/Qt/timer.cpp
Thomas Harte e2ceb77501 Attempts to start updating a started machine.
No real progress on graphics output though.
2020-06-03 00:21:37 -04:00

21 lines
447 B
C++

#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);
}