AP_RangeFinder_LightWareSerial.h 850 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include "RangeFinder.h"
  3. #include "RangeFinder_Backend.h"
  4. class AP_RangeFinder_LightWareSerial : public AP_RangeFinder_Backend
  5. {
  6. public:
  7. // constructor
  8. AP_RangeFinder_LightWareSerial(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. virtual MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
  17. return MAV_DISTANCE_SENSOR_LASER;
  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. uint32_t last_init_ms;
  26. };