ardupilot/libraries/AP_RangeFinder/AP_RangeFinder_MaxsonarI2CXL.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.3 KiB
C
Raw Normal View History

#pragma once
#include "AP_RangeFinder_config.h"
#if AP_RANGEFINDER_MAXSONARI2CXL_ENABLED
#include "AP_RangeFinder.h"
#include "AP_RangeFinder_Backend.h"
#include <AP_HAL/I2CDevice.h>
#define AP_RANGE_FINDER_MAXSONARI2CXL_DEFAULT_ADDR 0x70
#define AP_RANGE_FINDER_MAXSONARI2CXL_COMMAND_TAKE_RANGE_READING 0x51
class AP_RangeFinder_MaxsonarI2CXL : public AP_RangeFinder_Backend
{
public:
// static detection function
static AP_RangeFinder_Backend *detect(RangeFinder::RangeFinder_State &_state,
2019-02-03 22:21:58 -04:00
AP_RangeFinder_Params &_params,
AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev);
// update state
void update(void) override;
protected:
MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
return MAV_DISTANCE_SENSOR_ULTRASOUND;
}
private:
// constructor
AP_RangeFinder_MaxsonarI2CXL(RangeFinder::RangeFinder_State &_state,
AP_RangeFinder_Params &_params,
AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev);
bool _init(void);
void _timer(void);
uint16_t distance;
bool new_distance;
// start a reading
bool start_reading(void);
bool get_reading(uint16_t &reading_cm);
AP_HAL::OwnPtr<AP_HAL::I2CDevice> _dev;
};
#endif // AP_RANGEFINDER_MAXSONARI2CXL_ENABLED