mirror of https://github.com/rusefi/wideband.git
avoid 64 bit divide (!) exploding binary size
This commit is contained in:
parent
52f306b6f5
commit
4bdd8f5c44
|
@ -54,6 +54,8 @@ bool Timer::hasElapsedMs(float milliseconds) const {
|
||||||
return hasElapsedUs(milliseconds * 1000);
|
return hasElapsedUs(milliseconds * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const float usPerTick = 1000000.0 / CH_CFG_ST_FREQUENCY;
|
||||||
|
|
||||||
bool Timer::hasElapsedUs(float microseconds) const {
|
bool Timer::hasElapsedUs(float microseconds) const {
|
||||||
auto delta = getTimestamp() - m_lastReset;
|
auto delta = getTimestamp() - m_lastReset;
|
||||||
|
|
||||||
|
@ -64,10 +66,9 @@ bool Timer::hasElapsedUs(float microseconds) const {
|
||||||
|
|
||||||
auto delta32 = (uint32_t)delta;
|
auto delta32 = (uint32_t)delta;
|
||||||
|
|
||||||
return delta32 > TIME_US2I(microseconds);
|
return delta32 > (microseconds / usPerTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float Timer::getElapsedSeconds() const {
|
float Timer::getElapsedSeconds() const {
|
||||||
return getElapsedSeconds(getTimestamp());
|
return getElapsedSeconds(getTimestamp());
|
||||||
}
|
}
|
||||||
|
@ -96,7 +97,7 @@ float Timer::getElapsedUs(int64_t stamp) const {
|
||||||
|
|
||||||
auto delta32 = (uint32_t)deltaNt;
|
auto delta32 = (uint32_t)deltaNt;
|
||||||
|
|
||||||
return TIME_I2US(delta32);
|
return delta32 * usPerTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Timer::getElapsedSecondsAndReset() {
|
float Timer::getElapsedSecondsAndReset() {
|
||||||
|
|
Loading…
Reference in New Issue