Browse Source

AP_Airspeed: expose get_temperature()

mission-4.1.18
Andrew Tridgell 11 years ago
parent
commit
cf1f05a198
  1. 16
      libraries/AP_Airspeed/AP_Airspeed.cpp
  2. 6
      libraries/AP_Airspeed/AP_Airspeed.h

16
libraries/AP_Airspeed/AP_Airspeed.cpp

@ -49,7 +49,7 @@ extern const AP_HAL::HAL& hal; @@ -49,7 +49,7 @@ extern const AP_HAL::HAL& hal;
#elif CONFIG_HAL_BOARD == HAL_BOARD_FLYMAPLE
#define ARSPD_DEFAULT_PIN 16
#elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#define ARSPD_DEFAULT_PIN 65
#define ARSPD_DEFAULT_PIN AP_AIRSPEED_I2C_PIN
#else
#define ARSPD_DEFAULT_PIN 0
#endif
@ -122,7 +122,7 @@ float AP_Airspeed::get_pressure(void) @@ -122,7 +122,7 @@ float AP_Airspeed::get_pressure(void)
return 0;
}
float pressure = 0;
if (_pin == 65) {
if (_pin == AP_AIRSPEED_I2C_PIN) {
_healthy = digital.get_differential_pressure(pressure);
} else {
_healthy = analog.get_differential_pressure(pressure);
@ -130,6 +130,18 @@ float AP_Airspeed::get_pressure(void) @@ -130,6 +130,18 @@ float AP_Airspeed::get_pressure(void)
return pressure;
}
// get a temperature reading if possible
bool AP_Airspeed::get_temperature(float &temperature)
{
if (!_enable) {
return false;
}
if (_pin == AP_AIRSPEED_I2C_PIN) {
return digital.get_temperature(temperature);
}
return false;
}
// calibrate the airspeed. This must be called at least once before
// the get_airspeed() interface can be used
void AP_Airspeed::calibrate()

6
libraries/AP_Airspeed/AP_Airspeed.h

@ -78,6 +78,9 @@ public: @@ -78,6 +78,9 @@ public:
return _ratio;
}
// get temperature if available
bool get_temperature(float &temperature);
// set the airspeed ratio (dimensionless)
void set_airspeed_ratio(float ratio) {
_ratio.set(ratio);
@ -158,5 +161,8 @@ private: @@ -158,5 +161,8 @@ private:
#endif
};
// the virtual pin for digital airspeed sensors
#define AP_AIRSPEED_I2C_PIN 65
#endif // __AP_AIRSPEED_H__

Loading…
Cancel
Save