From 258542b939295f14d55c995b53590e28e8d82b73 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 13 Nov 2014 21:12:37 +1100 Subject: [PATCH] AP_Airspeed: added ARSPD_SKIP_CAL parameter allows airspeed calibration to be skipped for easier startup --- libraries/AP_Airspeed/AP_Airspeed.cpp | 12 +++++++++++- libraries/AP_Airspeed/AP_Airspeed.h | 3 ++- libraries/AP_Airspeed/examples/Airspeed/Airspeed.pde | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/libraries/AP_Airspeed/AP_Airspeed.cpp b/libraries/AP_Airspeed/AP_Airspeed.cpp index d23c2d9ec5..2fea1e432d 100644 --- a/libraries/AP_Airspeed/AP_Airspeed.cpp +++ b/libraries/AP_Airspeed/AP_Airspeed.cpp @@ -115,6 +115,13 @@ const AP_Param::GroupInfo AP_Airspeed::var_info[] PROGMEM = { // @User: Advanced AP_GROUPINFO("TUBE_ORDER", 6, AP_Airspeed, _tube_order, 2), + // @Param: SKIP_CAL + // @DisplayName: Skip airspeed calibration on startup + // @Description: This parameter allows you to skip airspeed offset calibration on startup, instead using the offset from the last calibration. This may be desirable if the offset variance between flights for your sensor is low and you want to avoid having to cover the pitot tube on each boot. + // @Values: 0:Disable,1:Enable + // @User: Advanced + AP_GROUPINFO("SKIP_CAL", 7, AP_Airspeed, _skip_cal, 0), + AP_GROUPEND }; @@ -170,13 +177,16 @@ bool AP_Airspeed::get_temperature(float &temperature) // calibrate the airspeed. This must be called at least once before // the get_airspeed() interface can be used -void AP_Airspeed::calibrate() +void AP_Airspeed::calibrate(bool in_startup) { float sum = 0; uint8_t count = 0; if (!_enable) { return; } + if (in_startup && _skip_cal) { + return; + } // discard first reading get_pressure(); for (uint8_t i = 0; i < 10; i++) { diff --git a/libraries/AP_Airspeed/AP_Airspeed.h b/libraries/AP_Airspeed/AP_Airspeed.h index e575efcd2d..54e7dfeef2 100644 --- a/libraries/AP_Airspeed/AP_Airspeed.h +++ b/libraries/AP_Airspeed/AP_Airspeed.h @@ -64,7 +64,7 @@ public: // calibrate the airspeed. This must be called on startup if the // altitude/climb_rate/acceleration interfaces are ever used - void calibrate(); + void calibrate(bool in_startup); // return the current airspeed in m/s float get_airspeed(void) const { @@ -170,6 +170,7 @@ private: AP_Int8 _pin; AP_Int8 _autocal; AP_Int8 _tube_order; + AP_Int8 _skip_cal; float _raw_airspeed; float _airspeed; float _last_pressure; diff --git a/libraries/AP_Airspeed/examples/Airspeed/Airspeed.pde b/libraries/AP_Airspeed/examples/Airspeed/Airspeed.pde index 92f6656ff1..0da7796852 100644 --- a/libraries/AP_Airspeed/examples/Airspeed/Airspeed.pde +++ b/libraries/AP_Airspeed/examples/Airspeed/Airspeed.pde @@ -65,7 +65,7 @@ void setup() AP_Param::set_object_value(&airspeed, airspeed.var_info, "_PIN", 65); airspeed.init(); - airspeed.calibrate(); + airspeed.calibrate(false); } void loop(void)