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_; }; }