ardupilot/libraries/AP_Airspeed/AP_Airspeed.h

66 lines
1.5 KiB
C
Raw Normal View History

/// -*- 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>
2012-10-09 21:01:22 -03:00
#include <AP_HAL.h>
#include <AP_Param.h>
class AP_Airspeed
{
public:
// constructor
2012-12-12 17:42:43 -04:00
AP_Airspeed() {
AP_Param::setup_object_defaults(this, var_info);
};
2012-10-09 21:01:22 -03:00
void init(AP_HAL::AnalogSource *source) {
_source = source;
}
// read the analog source and update _airspeed
void read(void);
// calibrate the airspeed. This must be called on startup if the
// altitude/climb_rate/acceleration interfaces are ever used
2012-10-09 21:01:22 -03:00
void calibrate();
// return the current airspeed in m/s
float get_airspeed(void) {
return _airspeed;
}
// return the current airspeed in cm/s
float get_airspeed_cm(void) {
return _airspeed*100;
}
// return true if airspeed is enabled, and airspeed use is set
bool use(void) {
return _enable && _use && _offset != 0;
}
// return true if airspeed is enabled
bool enabled(void) {
return _enable;
}
// used by HIL to set the airspeed
void set_HIL(float airspeed) {
_airspeed = airspeed;
}
2012-10-09 21:01:22 -03:00
static const struct AP_Param::GroupInfo var_info[];
private:
2012-10-09 21:01:22 -03:00
AP_HAL::AnalogSource *_source;
AP_Float _offset;
AP_Float _ratio;
AP_Int8 _use;
AP_Int8 _enable;
float _airspeed;
};
#endif // __AP_AIRSPEED_H__