Skip to content
Snippets Groups Projects
Commit cf1f05a1 authored by Andrew Tridgell's avatar Andrew Tridgell
Browse files

AP_Airspeed: expose get_temperature()

parent fc3ed61e
No related branches found
No related tags found
No related merge requests found
......@@ -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)
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)
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()
......
......@@ -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:
#endif
};
// the virtual pin for digital airspeed sensors
#define AP_AIRSPEED_I2C_PIN 65
#endif // __AP_AIRSPEED_H__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment