2016-02-17 21:25:44 -04:00
|
|
|
#pragma once
|
2012-11-11 11:25:29 -04:00
|
|
|
|
2023-07-06 01:25:14 -03:00
|
|
|
#include "AP_RangeFinder_config.h"
|
2022-03-12 06:37:29 -04:00
|
|
|
|
|
|
|
#if AP_RANGEFINDER_MAXSONARI2CXL_ENABLED
|
|
|
|
|
2023-07-06 01:25:14 -03:00
|
|
|
#include "AP_RangeFinder.h"
|
|
|
|
#include "AP_RangeFinder_Backend.h"
|
|
|
|
|
2016-04-14 13:42:06 -03:00
|
|
|
#include <AP_HAL/I2CDevice.h>
|
2012-11-11 11:25:29 -04:00
|
|
|
|
|
|
|
#define AP_RANGE_FINDER_MAXSONARI2CXL_DEFAULT_ADDR 0x70
|
|
|
|
#define AP_RANGE_FINDER_MAXSONARI2CXL_COMMAND_TAKE_RANGE_READING 0x51
|
|
|
|
|
2014-06-27 01:03:47 -03:00
|
|
|
class AP_RangeFinder_MaxsonarI2CXL : public AP_RangeFinder_Backend
|
2012-11-11 11:25:29 -04:00
|
|
|
{
|
|
|
|
public:
|
2014-06-27 01:03:47 -03:00
|
|
|
// static detection function
|
2017-09-23 19:33:04 -03:00
|
|
|
static AP_RangeFinder_Backend *detect(RangeFinder::RangeFinder_State &_state,
|
2019-02-03 22:21:58 -04:00
|
|
|
AP_RangeFinder_Params &_params,
|
2017-09-23 19:33:04 -03:00
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev);
|
2012-11-11 11:25:29 -04:00
|
|
|
|
2014-06-27 01:03:47 -03:00
|
|
|
// update state
|
2018-11-07 07:01:51 -04:00
|
|
|
void update(void) override;
|
2012-11-11 11:25:29 -04:00
|
|
|
|
2017-08-08 04:32:53 -03:00
|
|
|
protected:
|
|
|
|
|
|
|
|
MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
|
|
|
|
return MAV_DISTANCE_SENSOR_ULTRASOUND;
|
|
|
|
}
|
|
|
|
|
2014-06-27 01:03:47 -03:00
|
|
|
private:
|
2016-04-14 13:42:06 -03:00
|
|
|
// constructor
|
2017-09-23 19:33:04 -03:00
|
|
|
AP_RangeFinder_MaxsonarI2CXL(RangeFinder::RangeFinder_State &_state,
|
2018-07-04 11:22:17 -03:00
|
|
|
AP_RangeFinder_Params &_params,
|
2017-09-23 19:33:04 -03:00
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> dev);
|
2016-04-14 13:42:06 -03:00
|
|
|
|
2017-01-13 15:26:14 -04:00
|
|
|
bool _init(void);
|
|
|
|
void _timer(void);
|
2016-11-04 00:35:41 -03:00
|
|
|
|
|
|
|
uint16_t distance;
|
|
|
|
bool new_distance;
|
|
|
|
|
2014-06-27 01:03:47 -03:00
|
|
|
// start a reading
|
2016-04-14 13:42:06 -03:00
|
|
|
bool start_reading(void);
|
|
|
|
bool get_reading(uint16_t &reading_cm);
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> _dev;
|
2012-11-11 11:25:29 -04:00
|
|
|
};
|
2022-03-12 06:37:29 -04:00
|
|
|
|
|
|
|
#endif // AP_RANGEFINDER_MAXSONARI2CXL_ENABLED
|