CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Airspeed/AP_Airspeed_DLVR.h
Views: 1798
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/utility/OwnPtr.h>
26
#include <AP_HAL/I2CDevice.h>
27
#include <utility>
28
29
#include "AP_Airspeed_Backend.h"
30
31
class AP_Airspeed_DLVR : public AP_Airspeed_Backend
32
{
33
public:
34
35
AP_Airspeed_DLVR(AP_Airspeed &frontend, uint8_t _instance, const float _range_inH2O);
36
static AP_Airspeed_Backend *probe(AP_Airspeed &frontend, uint8_t _instance, AP_HAL::OwnPtr<AP_HAL::I2CDevice> _dev, const float _range_inH2O);
37
38
~AP_Airspeed_DLVR(void) {}
39
40
// probe and initialise the sensor
41
bool init() override;
42
43
// return the current differential_pressure in Pascal
44
bool get_differential_pressure(float &pressure) override;
45
46
// return the current temperature in degrees C, if available
47
bool get_temperature(float &temperature) override;
48
49
private:
50
void timer();
51
52
float pressure;
53
float temperature;
54
float temperature_sum;
55
float pressure_sum;
56
uint32_t temp_count;
57
uint32_t press_count;
58
59
uint32_t last_sample_time_ms;
60
const float range_inH2O;
61
62
// initialise the sensor
63
void setup();
64
65
AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev;
66
};
67
68
#endif // AP_AIRSPEED_DLVR_ENABLED
69
70