2020-08-03 00:23:10 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "SIM_I2CDevice.h"
|
|
|
|
|
|
|
|
namespace SITL {
|
|
|
|
|
2020-12-03 23:14:59 -04:00
|
|
|
class MaxSonarI2CXL : public I2CDevice, public I2CCommandResponseDevice
|
2020-08-03 00:23:10 -03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2020-12-03 23:14:59 -04:00
|
|
|
// methods to make I2CCommandResponseDevice happy:
|
|
|
|
uint8_t command_take_reading() const override { return 0x51; }
|
|
|
|
uint16_t reading() const override {
|
|
|
|
return rangefinder_range * 100;
|
|
|
|
};
|
|
|
|
|
|
|
|
void update(const class Aircraft &aircraft) override {
|
|
|
|
rangefinder_range = aircraft.rangefinder_range();
|
|
|
|
}
|
|
|
|
|
|
|
|
int rdwr(I2C::i2c_rdwr_ioctl_data *&data) override {
|
|
|
|
return I2CCommandResponseDevice::rdwr(data);
|
|
|
|
}
|
2020-08-03 00:23:10 -03:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
float rangefinder_range;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace SITL
|