From 23428d171ffedd44fab4b67d0f5f82cdb8a0d601 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 20 Oct 2021 16:27:01 -0400 Subject: [PATCH] Make dsp::Timer a template. --- include/dsp/digital.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/dsp/digital.hpp b/include/dsp/digital.hpp index f38b7d90..0d33bc22 100644 --- a/include/dsp/digital.hpp +++ b/include/dsp/digital.hpp @@ -112,20 +112,23 @@ struct PulseGenerator { /** Accumulates a timer when process() is called. */ -struct Timer { - float time = 0.f; +template +struct TTimer { + T time = 0.f; void reset() { time = 0.f; } /** Returns the time since last reset or initialization. */ - float process(float deltaTime) { + T process(T deltaTime) { time += deltaTime; return time; } }; +typedef TTimer<> Timer; + /** Counts calls to process(), returning true every `division` calls. Example: