From a4cd9c4bd7a15f8359fc2dc2aa99e9425e728ce7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Aug 2014 18:16:53 +1000 Subject: [PATCH] AP_Airspeed: added HIL support --- libraries/AP_Airspeed/AP_Airspeed.cpp | 4 ++++ libraries/AP_Airspeed/AP_Airspeed.h | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Airspeed/AP_Airspeed.cpp b/libraries/AP_Airspeed/AP_Airspeed.cpp index 86bf19bb0e..2878497bf3 100644 --- a/libraries/AP_Airspeed/AP_Airspeed.cpp +++ b/libraries/AP_Airspeed/AP_Airspeed.cpp @@ -143,6 +143,10 @@ float AP_Airspeed::get_pressure(void) if (!_enable) { return 0; } + if (_hil_set) { + _healthy = true; + return _hil_pressure; + } float pressure = 0; if (_pin == AP_AIRSPEED_I2C_PIN) { _healthy = digital.get_differential_pressure(pressure); diff --git a/libraries/AP_Airspeed/AP_Airspeed.h b/libraries/AP_Airspeed/AP_Airspeed.h index eb611b3bc1..47c186ec6d 100644 --- a/libraries/AP_Airspeed/AP_Airspeed.h +++ b/libraries/AP_Airspeed/AP_Airspeed.h @@ -46,6 +46,7 @@ public: _last_pressure(0.0f), _EAS2TAS(1.0f), _healthy(false), + _hil_set(false), _last_update_ms(0), _calibration(parms), _last_saved_ratio(0.0f), @@ -137,6 +138,8 @@ public: // return health status of sensor bool healthy(void) const { return _healthy; } + void setHIL(float pressure) { _hil_set=true; _hil_pressure=pressure; }; + // return time in ms of last update uint32_t last_update_ms(void) const { return _last_update_ms; } @@ -160,7 +163,9 @@ private: float _airspeed; float _last_pressure; float _EAS2TAS; - bool _healthy; + bool _healthy:1; + bool _hil_set:1; + float _hil_pressure; uint32_t _last_update_ms; Airspeed_Calibration _calibration;