From 840c9e65bb7a9460307aa981b5ee18e6d1bd75c6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 9 Nov 2015 14:34:07 +1100 Subject: [PATCH] AP_Baro: don't notify the GCS of new pressure reference too often --- libraries/AP_Baro/AP_Baro.cpp | 12 ++++++++++-- libraries/AP_Baro/AP_Baro.h | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Baro/AP_Baro.cpp b/libraries/AP_Baro/AP_Baro.cpp index 1e5718fcd9..53a8743c21 100644 --- a/libraries/AP_Baro/AP_Baro.cpp +++ b/libraries/AP_Baro/AP_Baro.cpp @@ -164,10 +164,18 @@ void AP_Baro::update_calibration() { for (uint8_t i=0; i<_num_sensors; i++) { if (healthy(i)) { - sensors[i].ground_pressure.set_and_notify(get_pressure(i)); + sensors[i].ground_pressure.set(get_pressure(i)); } float last_temperature = sensors[i].ground_temperature; - sensors[i].ground_temperature.set_and_notify(get_calibration_temperature(i)); + sensors[i].ground_temperature.set(get_calibration_temperature(i)); + + // don't notify the GCS too rapidly or we flood the link + uint32_t now = hal.scheduler->millis(); + if (now - _last_notify_ms > 10000) { + sensors[i].ground_pressure.notify(); + sensors[i].ground_temperature.notify(); + _last_notify_ms = now; + } if (fabsf(last_temperature - sensors[i].ground_temperature) > 3) { // reset _EAS2TAS to force it to recalculate. This happens // when a digital airspeed sensor comes online diff --git a/libraries/AP_Baro/AP_Baro.h b/libraries/AP_Baro/AP_Baro.h index 60cc233630..d17291b764 100644 --- a/libraries/AP_Baro/AP_Baro.h +++ b/libraries/AP_Baro/AP_Baro.h @@ -158,6 +158,9 @@ private: DerivativeFilterFloat_Size7 _climb_rate_filter; bool _hil_mode:1; + // when did we last notify the GCS of new pressure reference? + uint32_t _last_notify_ms; + void SimpleAtmosphere(const float alt, float &sigma, float &delta, float &theta); };