2013-09-28 05:40:29 -03:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2016-02-17 21:25:14 -04:00
|
|
|
#pragma once
|
2013-09-28 05:40:29 -03:00
|
|
|
|
|
|
|
/*
|
|
|
|
backend driver for airspeed from I2C
|
|
|
|
*/
|
|
|
|
|
2015-08-11 03:28:42 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2016-06-08 21:10:54 -03:00
|
|
|
#include <AP_Param/AP_Param.h>
|
|
|
|
#include <AP_HAL/utility/OwnPtr.h>
|
|
|
|
#include <AP_HAL/I2CDevice.h>
|
|
|
|
#include <utility>
|
2016-01-29 07:38:33 -04:00
|
|
|
|
2015-08-11 03:28:42 -03:00
|
|
|
#include "AP_Airspeed_Backend.h"
|
2016-04-19 14:16:19 -03:00
|
|
|
#include <AP_HAL/I2CDevice.h>
|
2013-09-28 05:40:29 -03:00
|
|
|
|
2016-01-29 07:38:33 -04:00
|
|
|
class AP_Airspeed_I2C : public AP_Airspeed_Backend
|
2013-09-28 05:40:29 -03:00
|
|
|
{
|
|
|
|
public:
|
2016-06-08 21:10:54 -03:00
|
|
|
AP_Airspeed_I2C(const AP_Float &psi_range);
|
|
|
|
~AP_Airspeed_I2C(void) {}
|
|
|
|
|
2013-09-28 05:40:29 -03:00
|
|
|
// probe and initialise the sensor
|
2016-01-29 07:38:33 -04:00
|
|
|
bool init();
|
2013-09-28 05:40:29 -03:00
|
|
|
|
|
|
|
// return the current differential_pressure in Pascal
|
|
|
|
bool get_differential_pressure(float &pressure);
|
|
|
|
|
|
|
|
// return the current temperature in degrees C, if available
|
|
|
|
bool get_temperature(float &temperature);
|
|
|
|
|
|
|
|
private:
|
2016-01-29 07:38:33 -04:00
|
|
|
void _measure();
|
|
|
|
void _collect();
|
|
|
|
void _timer();
|
2013-09-28 05:40:29 -03:00
|
|
|
float _temperature;
|
|
|
|
float _pressure;
|
|
|
|
uint32_t _last_sample_time_ms;
|
|
|
|
uint32_t _measurement_started_ms;
|
2016-04-19 14:16:19 -03:00
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> _dev;
|
2016-06-08 21:10:54 -03:00
|
|
|
const AP_Float &_psi_range;
|
2013-09-28 05:40:29 -03:00
|
|
|
};
|