summaryrefslogtreecommitdiffstats
path: root/src/utils/timer.hpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-04-02 23:46:56 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-04-11 12:41:42 +0200
commit745ff334267ab92051bc8261a7daa0165c700fac (patch)
tree34b32afe9fdad423118f3799c6dfb2e5d768f168 /src/utils/timer.hpp
parentdcc4af2d7e74762ec8d1caf04657b47fca560fed (diff)
Fix: wrong period operation without unit multiplicator
Possible divsion by 0. Don't know if it is good to keep different time unit instead having one unit for project... Change-Id: I73cfc1ab72d3420d337f10a9b79bdf305a3a2bc7 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/utils/timer.hpp')
-rw-r--r--src/utils/timer.hpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/utils/timer.hpp b/src/utils/timer.hpp
index 5be0e3cd..f5659044 100644
--- a/src/utils/timer.hpp
+++ b/src/utils/timer.hpp
@@ -32,6 +32,7 @@ long long int system_time_s();
class frequency_clock_t
{
private:
+ float unit_; ///< unit_ - multiplicator to make operation to be in the right unit (milli, micro, nano, etc)
float frequency_; ///< the clock frequency in Hz.
unsigned long last_tick_; ///< the last time (in milliseconds since startup) that the clock ticked.
time_function_t time_function_; ///< a function returning current time
@@ -42,7 +43,8 @@ public:
frequency_clock_t(float frequency, unsigned long last_tick, time_function_t time_function);
float get_frequency() const;
- static float frequency_to_period(float frequency);
+
+ float frequency_to_period();
bool started();
time_function_t get_time_function();
bool elapsed(bool stagger);