X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FIntervalTimer.hpp;h=06caa5e21b9bb5c805a1f2e73d68d89c855f8996;hb=045a6ec084bf1fb4df3c6ade4a88932cf61bed23;hp=0d6790be20850ebfb9276fc62f88b09408793917;hpb=6f94235a5b7c140852703e60c8a74760b8b61d99;p=blank.git diff --git a/src/app/IntervalTimer.hpp b/src/app/IntervalTimer.hpp index 0d6790b..06caa5e 100644 --- a/src/app/IntervalTimer.hpp +++ b/src/app/IntervalTimer.hpp @@ -13,7 +13,7 @@ class IntervalTimer { public: /// Create a timer that hits every interval_ms milliseconds. /// Initial state is stopped. - explicit IntervalTimer(int interval_ms) noexcept + explicit IntervalTimer(int interval_ms = 0) noexcept : intv(interval_ms) { } void Start() noexcept { @@ -23,6 +23,9 @@ public: value = 0; speed = 0; } + void Reset() noexcept { + value = 0; + } bool Running() const noexcept { return speed != 0; @@ -31,6 +34,9 @@ public: bool Hit() const noexcept { return Running() && value % intv < last_dt; } + bool HitOnce() const noexcept { + return Running() && value >= intv; + } int Elapsed() const noexcept { return value; }