Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Airspeed/AP_Airspeed_DLVR.h
9872 views
1
/*
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License as published by
4
the Free Software Foundation, either version 3 of the License, or
5
(at your option) any later version.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
#pragma once
16
17
// backend driver for AllSensors DLVR differential airspeed sensor
18
// currently assumes a 5" of water, noise reduced, sensor
19
20
#include "AP_Airspeed_config.h"
21
22
#if AP_AIRSPEED_DLVR_ENABLED
23
24
#include <AP_HAL/AP_HAL.h>
25
#include <AP_HAL/I2CDevice.h>
26
#include <utility>
27
28
#include "AP_Airspeed_Backend.h"
29
30
class AP_Airspeed_DLVR : public AP_Airspeed_Backend
31
{
32
public:
33
34
AP_Airspeed_DLVR(AP_Airspeed &frontend, uint8_t _instance, const float _range_inH2O);
35
static AP_Airspeed_Backend *probe(AP_Airspeed &frontend, uint8_t _instance, AP_HAL::I2CDevice *_dev, const float _range_inH2O);
36
37
~AP_Airspeed_DLVR(void) {
38
delete dev;
39
}
40
41
// probe and initialise the sensor
42
bool init() override;
43
44
// return the current differential_pressure in Pascal
45
bool get_differential_pressure(float &pressure) override;
46
47
// return the current temperature in degrees C, if available
48
bool get_temperature(float &temperature) override;
49
50
private:
51
void timer();
52
53
float pressure;
54
float temperature;
55
float temperature_sum;
56
float pressure_sum;
57
uint32_t temp_count;
58
uint32_t press_count;
59
60
uint32_t last_sample_time_ms;
61
const float range_inH2O;
62
63
// initialise the sensor
64
void setup();
65
66
AP_HAL::I2CDevice *dev;
67
};
68
69
#endif // AP_AIRSPEED_DLVR_ENABLED
70
71