diff --git a/libraries/AP_Scheduler/PerfInfo.h b/libraries/AP_Scheduler/PerfInfo.h index 3813321387..c1984f86d1 100644 --- a/libraries/AP_Scheduler/PerfInfo.h +++ b/libraries/AP_Scheduler/PerfInfo.h @@ -23,7 +23,13 @@ public: uint32_t get_avg_time() const; uint32_t get_stddev_time() const; + void set_loop_rate(uint16_t rate_hz) { + // allow a 20% overrun before we consider a loop "slow": + overtime_threshold_micros = 1000000/rate_hz * 1.2f; + } + private: + uint16_t overtime_threshold_micros; uint16_t loop_count; uint32_t max_time; // in microseconds uint32_t min_time; // in microseconds @@ -33,6 +39,7 @@ private: uint32_t log_dropped; uint32_t overtime_threshold_us; bool ignore_loop; + }; };