AP_RangeFinder_MaxsonarSerialLV.h 822 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #include "RangeFinder.h"
  3. #include "RangeFinder_Backend.h"
  4. class AP_RangeFinder_MaxsonarSerialLV : public AP_RangeFinder_Backend
  5. {
  6. public:
  7. // constructor
  8. AP_RangeFinder_MaxsonarSerialLV(RangeFinder::RangeFinder_State &_state,
  9. AP_RangeFinder_Params &_params,
  10. uint8_t serial_instance);
  11. // static detection function
  12. static bool detect(uint8_t serial_instance);
  13. // update state
  14. void update(void) override;
  15. protected:
  16. MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
  17. return MAV_DISTANCE_SENSOR_ULTRASOUND;
  18. }
  19. private:
  20. // get a reading
  21. bool get_reading(uint16_t &reading_cm);
  22. AP_HAL::UARTDriver *uart = nullptr;
  23. char linebuf[10];
  24. uint8_t linebuf_len = 0;
  25. };