Line data Source code
1 : #pragma once 2 : 3 : #include "AP_RangeFinder_config.h" 4 : 5 : #if HAL_MSP_RANGEFINDER_ENABLED 6 : 7 : #include "AP_RangeFinder.h" 8 : #include "AP_RangeFinder_Backend.h" 9 : 10 : // Data timeout 11 : #define AP_RANGEFINDER_MSP_TIMEOUT_MS 500 12 : 13 : class AP_RangeFinder_MSP : public AP_RangeFinder_Backend 14 : { 15 : 16 : public: 17 : // constructor 18 : AP_RangeFinder_MSP(RangeFinder::RangeFinder_State &_state, AP_RangeFinder_Params &_params); 19 : 20 : // static detection function 21 : static bool detect(); 22 : 23 : // update state 24 : void update(void) override; 25 : 26 : // Get update from msp 27 : void handle_msp(const MSP::msp_rangefinder_data_message_t &pkt) override; 28 : 29 : protected: 30 : 31 0 : MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override { 32 0 : return MAV_DISTANCE_SENSOR_UNKNOWN; 33 : } 34 : 35 : private: 36 : uint16_t distance_cm; 37 : 38 : // start a reading 39 : static bool start_reading(void); 40 : static bool get_reading(uint16_t &reading_cm); 41 : }; 42 : 43 : #endif //HAL_MSP_RANGEFINDER_ENABLED 44 :