2012-07-15 22:21:20 -03:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
#ifndef __AP_AIRSPEED_H__
|
|
|
|
#define __AP_AIRSPEED_H__
|
|
|
|
|
|
|
|
#include <AP_Common.h>
|
|
|
|
#include <AP_Param.h>
|
|
|
|
#include <AP_AnalogSource.h>
|
|
|
|
#include <Filter.h>
|
|
|
|
#include <AverageFilter.h>
|
|
|
|
|
|
|
|
class AP_Airspeed
|
|
|
|
{
|
|
|
|
public:
|
2012-08-17 03:08:43 -03:00
|
|
|
// constructor
|
|
|
|
AP_Airspeed(AP_AnalogSource *source) {
|
|
|
|
_source = source;
|
|
|
|
}
|
2012-07-15 22:21:20 -03:00
|
|
|
|
2012-08-17 03:08:43 -03:00
|
|
|
// read the analog source and update _airspeed
|
|
|
|
void read(void);
|
2012-07-15 22:21:20 -03:00
|
|
|
|
2012-08-17 03:08:43 -03:00
|
|
|
// calibrate the airspeed. This must be called on startup if the
|
|
|
|
// altitude/climb_rate/acceleration interfaces are ever used
|
|
|
|
// the callback is a delay() like routine
|
|
|
|
void calibrate(void (*callback)(unsigned long t));
|
2012-07-15 22:21:20 -03:00
|
|
|
|
2012-08-17 03:08:43 -03:00
|
|
|
// return the current airspeed in m/s
|
|
|
|
float get_airspeed(void) {
|
|
|
|
return _airspeed;
|
|
|
|
}
|
2012-07-15 22:21:20 -03:00
|
|
|
|
2012-08-17 03:08:43 -03:00
|
|
|
// return the current airspeed in cm/s
|
|
|
|
float get_airspeed_cm(void) {
|
|
|
|
return _airspeed*100;
|
|
|
|
}
|
2012-07-15 22:21:20 -03:00
|
|
|
|
|
|
|
// return true if airspeed is enabled, and airspeed use is set
|
2012-08-17 03:08:43 -03:00
|
|
|
bool use(void) {
|
|
|
|
return _enable && _use && _offset != 0;
|
|
|
|
}
|
2012-07-15 22:21:20 -03:00
|
|
|
|
|
|
|
// return true if airspeed is enabled
|
2012-08-17 03:08:43 -03:00
|
|
|
bool enabled(void) {
|
|
|
|
return _enable;
|
|
|
|
}
|
2012-07-15 22:21:20 -03:00
|
|
|
|
|
|
|
// used by HIL to set the airspeed
|
2012-08-17 03:08:43 -03:00
|
|
|
void set_HIL(float airspeed) {
|
|
|
|
_airspeed = airspeed;
|
|
|
|
}
|
2012-07-15 22:21:20 -03:00
|
|
|
|
2012-08-17 03:08:43 -03:00
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
2012-07-15 22:21:20 -03:00
|
|
|
|
|
|
|
private:
|
2012-08-17 03:08:43 -03:00
|
|
|
AP_AnalogSource * _source;
|
|
|
|
AP_Float _offset;
|
|
|
|
AP_Float _ratio;
|
|
|
|
AP_Int8 _use;
|
|
|
|
AP_Int8 _enable;
|
|
|
|
float _airspeed;
|
|
|
|
float _airspeed_raw;
|
2012-07-15 22:21:20 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __AP_AIRSPEED_H__
|