AP_RangeFinder_TeraRangerI2C.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include "RangeFinder.h"
  3. #include "RangeFinder_Backend.h"
  4. #include <AP_HAL/I2CDevice.h>
  5. class AP_RangeFinder_TeraRangerI2C : public AP_RangeFinder_Backend
  6. {
  7. public:
  8. // static detection function
  9. static AP_RangeFinder_Backend *detect(RangeFinder::RangeFinder_State &_state,
  10. AP_RangeFinder_Params &_params,
  11. AP_HAL::OwnPtr<AP_HAL::I2CDevice> i2c_dev);
  12. // update state
  13. void update(void) override;
  14. protected:
  15. virtual MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
  16. return MAV_DISTANCE_SENSOR_LASER;
  17. }
  18. private:
  19. // constructor
  20. AP_RangeFinder_TeraRangerI2C(RangeFinder::RangeFinder_State &_state,
  21. AP_RangeFinder_Params &_params,
  22. AP_HAL::OwnPtr<AP_HAL::I2CDevice> i2c_dev);
  23. bool measure(void);
  24. bool collect_raw(uint16_t &raw_distance);
  25. bool process_raw_measure(uint16_t raw_distance, uint16_t &distance_cm);
  26. bool init(void);
  27. void timer(void);
  28. AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev;
  29. struct {
  30. uint32_t sum;
  31. uint32_t count;
  32. } accum;
  33. };