Line data Source code
1 : #pragma once 2 : 3 : #include "AP_RangeFinder_config.h" 4 : 5 : #if AP_RANGEFINDER_GYUS42V2_ENABLED 6 : 7 : #include "AP_RangeFinder.h" 8 : #include "AP_RangeFinder_Backend_Serial.h" 9 : 10 : class AP_RangeFinder_GYUS42v2 : public AP_RangeFinder_Backend_Serial 11 : { 12 : 13 : public: 14 : 15 1 : static AP_RangeFinder_Backend_Serial *create( 16 : RangeFinder::RangeFinder_State &_state, 17 : AP_RangeFinder_Params &_params) { 18 1 : return NEW_NOTHROW AP_RangeFinder_GYUS42v2(_state, _params); 19 : } 20 : 21 : protected: 22 : 23 338 : MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override { 24 338 : return MAV_DISTANCE_SENSOR_ULTRASOUND; 25 : } 26 : 27 1 : uint32_t initial_baudrate(uint8_t serial_instance) const override { 28 1 : return 9600; 29 : } 30 : 31 : private: 32 : 33 : using AP_RangeFinder_Backend_Serial::AP_RangeFinder_Backend_Serial; 34 : 35 : // get a reading 36 : bool get_reading(float &reading_m) override; 37 : 38 : // find signature byte in buffer starting at start, moving that 39 : // byte and following bytes to start of buffer. 40 : bool find_signature_in_buffer(uint8_t start); 41 : 42 : uint8_t buffer[7]; 43 : uint8_t buffer_used; 44 : }; 45 : 46 : #endif // AP_RANGEFINDER_GYUS42V2_ENABLED