From ecfc9d935a7c85bbf0e1a082889ecf4821262ab2 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 7 May 2019 11:12:27 -0500 Subject: [PATCH] Use standard timeout checker for CycleTimeReport Also, change timestamp from four bytes to two. Signed-off-by: Michael Richters --- src/kaleidoscope/plugin/CycleTimeReport.cpp | 8 ++++---- src/kaleidoscope/plugin/CycleTimeReport.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/kaleidoscope/plugin/CycleTimeReport.cpp b/src/kaleidoscope/plugin/CycleTimeReport.cpp index abc4d5a0..00d6f981 100644 --- a/src/kaleidoscope/plugin/CycleTimeReport.cpp +++ b/src/kaleidoscope/plugin/CycleTimeReport.cpp @@ -20,12 +20,12 @@ namespace kaleidoscope { namespace plugin { -uint32_t CycleTimeReport::next_report_time_; +uint16_t CycleTimeReport::last_report_time_; uint32_t CycleTimeReport::loop_start_time_; uint32_t CycleTimeReport::average_loop_time; EventHandlerResult CycleTimeReport::onSetup() { - next_report_time_ = millis() + 1000; + last_report_time_ = Kaleidoscope.millisAtCycleStart(); return EventHandlerResult::OK; } @@ -42,11 +42,11 @@ EventHandlerResult CycleTimeReport::afterEachCycle() { else average_loop_time = loop_time; - if (millis() >= next_report_time_) { + if (Kaleidoscope.hasTimeExpired(last_report_time_, uint16_t(1000))) { cycleTimeReport(); average_loop_time = 0; - next_report_time_ = millis() + 1000; + last_report_time_ = Kaleidoscope.millisAtCycleStart(); } return EventHandlerResult::OK; diff --git a/src/kaleidoscope/plugin/CycleTimeReport.h b/src/kaleidoscope/plugin/CycleTimeReport.h index d643574b..23005310 100644 --- a/src/kaleidoscope/plugin/CycleTimeReport.h +++ b/src/kaleidoscope/plugin/CycleTimeReport.h @@ -32,7 +32,7 @@ class CycleTimeReport : public kaleidoscope::Plugin { static uint32_t average_loop_time; private: - static uint32_t next_report_time_; + static uint16_t last_report_time_; static uint32_t loop_start_time_; }; }