small rework of timer class

This commit is contained in:
h4570
2020-12-03 20:04:35 +01:00
parent 72266d0c25
commit f45f5c39c7
3 changed files with 9 additions and 20 deletions
+6 -18
View File
@@ -10,16 +10,11 @@
#include "../include/modules/timer.hpp"
#include <timer.h>
// ----
// Constructors/Destructors
// ----
Timer::Timer()
{
this->lastTime = *T3_COUNT;
}
Timer::Timer() { prime(); }
Timer::~Timer() {}
@@ -29,20 +24,13 @@ Timer::~Timer() {}
u32 Timer::getTimeDelta()
{
this->time = *T3_COUNT;
time = *T3_COUNT;
if (this->time < this->lastTime) // The counter has wrapped
this->change = this->time + (65536 - this->lastTime);
if (time < lastTime) // The counter has wrapped
change = time + (65536 - lastTime);
else
this->change = this->time - this->lastTime;
this->lastTime = this->time;
return this->change;
}
void Timer::primeTimer()
{
lastTime = *T3_COUNT;
change = time - lastTime;
return change;
}
float Timer::getFPS()