Line data Source code
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 : #include "AP_Airspeed_config.h" 18 : 19 : #if AP_AIRSPEED_ASP5033_ENABLED 20 : 21 : /* 22 : backend driver for airspeed from I2C 23 : */ 24 : #include "AP_Airspeed_Backend.h" 25 : #include <AP_HAL/I2CDevice.h> 26 : 27 : class AP_Airspeed_ASP5033 : public AP_Airspeed_Backend 28 : { 29 : public: 30 : using AP_Airspeed_Backend::AP_Airspeed_Backend; 31 : 32 0 : ~AP_Airspeed_ASP5033(void) { 33 0 : delete dev; 34 0 : } 35 : 36 : bool init() override; 37 : 38 : // return the current differential_pressure in Pascal 39 : bool get_differential_pressure(float &_pressure) override; 40 : 41 : // return the current temperature in degrees C, if available 42 : bool get_temperature(float &_temperature) override; 43 : 44 : private: 45 : void timer(); 46 : bool confirm_sensor_id(void); 47 : float temp_sum; 48 : float press_sum; 49 : float last_pressure; 50 : float last_temperature; 51 : uint32_t press_count; 52 : uint32_t temp_count; 53 : uint32_t last_sample_ms; 54 : 55 : AP_HAL::I2CDevice *dev; 56 : }; 57 : 58 : #endif // AP_AIRSPEED_ASP5033_ENABLED