1#include "TimerManager.hh"
8Timer::Timer(u16 min_, u8 sec_, u16 mil_) : min(min_), sec(sec_), mil(mil_), valid(true) {}
13 min =
static_cast<u16>(data >> 0x19);
14 sec =
static_cast<u8
>(data >> 0x12) & 0x7F;
15 mil =
static_cast<u16>(data >> 8) & 0x3FF;
20Timer::~Timer() =
default;
23TimerManager::TimerManager() {
28TimerManager::~TimerManager() =
default;
31void TimerManager::init() {
32 m_currentTimer.min = 0;
33 m_currentTimer.sec = 0;
34 m_currentTimer.
mil = 0;
35 m_currentTimer.valid =
true;
42void TimerManager::calc() {
43 constexpr f32 REFRESH_PERIOD = 1000.0f / 59.94f;
44 constexpr f32 MILLISECONDS_TO_MINUTES = 1.0f / 60000.0f;
45 constexpr f32 MILLISECONDS_TO_SECONDS = 1.0f / 1000.0f;
46 constexpr f32 SECONDS_TO_MILLISECONDS = 1000.0f;
47 constexpr f32 MINUTES_TO_MILLISECONDS = 60000.0f;
53 u32 minutesMs =
static_cast<u32
>(
static_cast<f32
>(m_frameCounter) * REFRESH_PERIOD);
54 u16 minutes =
static_cast<u16>(
static_cast<f32
>(minutesMs) * MILLISECONDS_TO_MINUTES);
55 u32 secondsMs =
static_cast<u32
>(
56 static_cast<f32
>(minutesMs) -
static_cast<f32
>(minutes) * MINUTES_TO_MILLISECONDS);
57 u8 seconds =
static_cast<u8
>(
static_cast<f32
>(secondsMs) * MILLISECONDS_TO_SECONDS);
58 u16 milliseconds =
static_cast<u16>(
59 static_cast<f32
>(secondsMs) -
static_cast<f32
>(seconds) * SECONDS_TO_MILLISECONDS);
61 m_currentTimer.min = minutes;
62 m_currentTimer.sec = seconds;
63 m_currentTimer.
mil = milliseconds;
64 m_currentTimer.valid =
true;
High-level handling for generic system operations, such as input reading, race configuration,...
Timer()
[Unused] Creates a zero'd timer.