2020-06-14 03:11:25 -03:00
|
|
|
#pragma once
|
|
|
|
|
2023-07-06 01:25:14 -03:00
|
|
|
#include "AP_RangeFinder_config.h"
|
2022-03-12 06:37:29 -04:00
|
|
|
|
|
|
|
#if AP_RANGEFINDER_GYUS42V2_ENABLED
|
|
|
|
|
2023-07-06 01:25:14 -03:00
|
|
|
#include "AP_RangeFinder.h"
|
2020-06-14 03:11:25 -03:00
|
|
|
#include "AP_RangeFinder_Backend_Serial.h"
|
|
|
|
|
|
|
|
class AP_RangeFinder_GYUS42v2 : public AP_RangeFinder_Backend_Serial
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2022-06-22 08:03:22 -03:00
|
|
|
static AP_RangeFinder_Backend_Serial *create(
|
|
|
|
RangeFinder::RangeFinder_State &_state,
|
|
|
|
AP_RangeFinder_Params &_params) {
|
|
|
|
return new AP_RangeFinder_GYUS42v2(_state, _params);
|
|
|
|
}
|
2020-06-14 03:11:25 -03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
|
|
|
|
return MAV_DISTANCE_SENSOR_ULTRASOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t initial_baudrate(uint8_t serial_instance) const override {
|
|
|
|
return 9600;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2022-06-22 08:03:22 -03:00
|
|
|
using AP_RangeFinder_Backend_Serial::AP_RangeFinder_Backend_Serial;
|
|
|
|
|
2020-06-14 03:11:25 -03:00
|
|
|
// get a reading
|
2021-10-18 02:45:33 -03:00
|
|
|
bool get_reading(float &reading_m) override;
|
2020-06-14 03:11:25 -03:00
|
|
|
|
|
|
|
// find signature byte in buffer starting at start, moving that
|
|
|
|
// byte and following bytes to start of buffer.
|
|
|
|
bool find_signature_in_buffer(uint8_t start);
|
|
|
|
|
|
|
|
uint8_t buffer[7];
|
|
|
|
uint8_t buffer_used;
|
|
|
|
};
|
2022-03-12 06:37:29 -04:00
|
|
|
|
|
|
|
#endif // AP_RANGEFINDER_GYUS42V2_ENABLED
|