From edb25340d1cd095c71b2280918b503644bfbf88b Mon Sep 17 00:00:00 2001 From: Gone4Dirt Date: Wed, 20 Apr 2022 10:06:58 +0100 Subject: [PATCH] AP_Airspeed: Move multi-line functions out of header --- libraries/AP_Airspeed/AP_Airspeed.cpp | 20 ++++++++++++++++++++ libraries/AP_Airspeed/AP_Airspeed.h | 16 ++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/libraries/AP_Airspeed/AP_Airspeed.cpp b/libraries/AP_Airspeed/AP_Airspeed.cpp index 557bddb1a1..1319a80ca9 100644 --- a/libraries/AP_Airspeed/AP_Airspeed.cpp +++ b/libraries/AP_Airspeed/AP_Airspeed.cpp @@ -737,6 +737,24 @@ bool AP_Airspeed::all_healthy(void) const return true; } +// return true if airspeed is enabled +bool AP_Airspeed::enabled(uint8_t i) const { + if (i < AIRSPEED_MAX_SENSORS) { + return param[i].type.get() != TYPE_NONE; + } + return false; +} + +// return health status of sensor +bool AP_Airspeed::healthy(uint8_t i) const { + bool ok = state[i].healthy && enabled(i); +#ifndef HAL_BUILD_AP_PERIPH + // sanity check the offset parameter. Zero is permitted if we are skipping calibration. + ok &= (fabsf(param[i].offset) > 0 || state[i].use_zero_offset || param[i].skip_cal); +#endif + return ok; +} + #else // build type is not appropriate; provide a dummy implementation: const AP_Param::GroupInfo AP_Airspeed::var_info[] = { AP_GROUPEND }; @@ -744,6 +762,8 @@ void AP_Airspeed::update() {}; bool AP_Airspeed::get_temperature(uint8_t i, float &temperature) { return false; } void AP_Airspeed::calibrate(bool in_startup) {} bool AP_Airspeed::use(uint8_t i) const { return false; } +bool AP_Airspeed::enabled(uint8_t i) const { return false; } +bool AP_Airspeed::healthy(uint8_t i) const { return false; } #if HAL_MSP_AIRSPEED_ENABLED void AP_Airspeed::handle_msp(const MSP::msp_airspeed_data_message_t &pkt) {} diff --git a/libraries/AP_Airspeed/AP_Airspeed.h b/libraries/AP_Airspeed/AP_Airspeed.h index 440c5bb18f..7e9bd74a95 100644 --- a/libraries/AP_Airspeed/AP_Airspeed.h +++ b/libraries/AP_Airspeed/AP_Airspeed.h @@ -110,12 +110,7 @@ public: } // return true if airspeed is enabled - bool enabled(uint8_t i) const { - if (i < AIRSPEED_MAX_SENSORS) { - return param[i].type.get() != TYPE_NONE; - } - return false; - } + bool enabled(uint8_t i) const; bool enabled(void) const { return enabled(primary); } // return the differential pressure in Pascal for the last airspeed reading @@ -128,14 +123,7 @@ public: void update_calibration(const Vector3f &vground, int16_t max_airspeed_allowed_during_cal); // return health status of sensor - bool healthy(uint8_t i) const { - bool ok = state[i].healthy && enabled(i); -#ifndef HAL_BUILD_AP_PERIPH - // sanity check the offset parameter. Zero is permitted if we are skipping calibration. - ok &= (fabsf(param[i].offset) > 0 || state[i].use_zero_offset || param[i].skip_cal); -#endif - return ok; - } + bool healthy(uint8_t i) const; bool healthy(void) const { return healthy(primary); } // return true if all enabled sensors are healthy