Use standard timeout checker for CycleTimeReport

Also, change timestamp from four bytes to two.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/642/head
Michael Richters 6 years ago
parent e7fd8a326a
commit ecfc9d935a

@ -20,12 +20,12 @@
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
uint32_t CycleTimeReport::next_report_time_; uint16_t CycleTimeReport::last_report_time_;
uint32_t CycleTimeReport::loop_start_time_; uint32_t CycleTimeReport::loop_start_time_;
uint32_t CycleTimeReport::average_loop_time; uint32_t CycleTimeReport::average_loop_time;
EventHandlerResult CycleTimeReport::onSetup() { EventHandlerResult CycleTimeReport::onSetup() {
next_report_time_ = millis() + 1000; last_report_time_ = Kaleidoscope.millisAtCycleStart();
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
@ -42,11 +42,11 @@ EventHandlerResult CycleTimeReport::afterEachCycle() {
else else
average_loop_time = loop_time; average_loop_time = loop_time;
if (millis() >= next_report_time_) { if (Kaleidoscope.hasTimeExpired(last_report_time_, uint16_t(1000))) {
cycleTimeReport(); cycleTimeReport();
average_loop_time = 0; average_loop_time = 0;
next_report_time_ = millis() + 1000; last_report_time_ = Kaleidoscope.millisAtCycleStart();
} }
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -32,7 +32,7 @@ class CycleTimeReport : public kaleidoscope::Plugin {
static uint32_t average_loop_time; static uint32_t average_loop_time;
private: private:
static uint32_t next_report_time_; static uint16_t last_report_time_;
static uint32_t loop_start_time_; static uint32_t loop_start_time_;
}; };
} }

Loading…
Cancel
Save