AP_Airspeed_DLVR.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. */
  13. #pragma once
  14. // backend driver for AllSensors DLVR differential airspeed sensor
  15. // currently assumes a 5" of water, noise reduced, sensor
  16. #include <AP_HAL/AP_HAL.h>
  17. #include <AP_HAL/utility/OwnPtr.h>
  18. #include <AP_HAL/I2CDevice.h>
  19. #include <utility>
  20. #include "AP_Airspeed_Backend.h"
  21. class AP_Airspeed_DLVR : public AP_Airspeed_Backend
  22. {
  23. public:
  24. AP_Airspeed_DLVR(AP_Airspeed &frontend, uint8_t _instance, const float _range_inH2O);
  25. ~AP_Airspeed_DLVR(void) {}
  26. // probe and initialise the sensor
  27. bool init() override;
  28. // return the current differential_pressure in Pascal
  29. bool get_differential_pressure(float &pressure) override;
  30. // return the current temperature in degrees C, if available
  31. bool get_temperature(float &temperature) override;
  32. private:
  33. void timer();
  34. float pressure;
  35. float temperature;
  36. float temperature_sum;
  37. float pressure_sum;
  38. uint32_t temp_count;
  39. uint32_t press_count;
  40. uint32_t last_sample_time_ms;
  41. const float range_inH2O;
  42. AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev;
  43. };