2016-02-17 21:25:44 -04:00
|
|
|
#pragma once
|
2013-12-02 07:02:56 -04:00
|
|
|
|
|
|
|
#include "RangeFinder.h"
|
2014-06-27 00:39:52 -03:00
|
|
|
#include "RangeFinder_Backend.h"
|
2016-04-14 17:00:38 -03:00
|
|
|
#include <AP_HAL/I2CDevice.h>
|
2013-12-02 07:02:56 -04:00
|
|
|
|
|
|
|
/* Connection diagram
|
|
|
|
*
|
|
|
|
* ------------------------------------------------------------------------------------
|
2014-04-30 14:35:38 -03:00
|
|
|
* | J2-1(LED) J2-2(5V) J2-3(Enable) J2-4(Ref Clk) J2-5(GND) J2-6(GND) |
|
2013-12-02 07:02:56 -04:00
|
|
|
* | |
|
2014-04-30 14:35:38 -03:00
|
|
|
* | |
|
|
|
|
* | J1-3(I2C Clk) J1-2(I2C Data) J1-1(GND) |
|
2013-12-02 07:02:56 -04:00
|
|
|
* ------------------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
// i2c address
|
2014-10-24 03:00:47 -03:00
|
|
|
#define AP_RANGEFINDER_PULSEDLIGHTLRF_ADDR 0x62
|
2013-12-02 07:02:56 -04:00
|
|
|
|
|
|
|
// min and max distances
|
|
|
|
#define AP_RANGEFINDER_PULSEDLIGHTLRF_MIN_DISTANCE 0
|
2013-12-03 07:26:23 -04:00
|
|
|
#define AP_RANGEFINDER_PULSEDLIGHTLRF_MAX_DISTANCE 1400
|
2013-12-02 07:02:56 -04:00
|
|
|
|
|
|
|
// registers
|
2014-04-30 14:35:38 -03:00
|
|
|
#define AP_RANGEFINDER_PULSEDLIGHTLRF_MEASURE_REG 0x00
|
2014-07-17 11:34:13 -03:00
|
|
|
#define AP_RANGEFINDER_PULSEDLIGHTLRF_DISTHIGH_REG 0x8f // high byte of distance measurement
|
2013-12-02 07:02:56 -04:00
|
|
|
|
|
|
|
// command register values
|
2014-04-30 14:50:12 -03:00
|
|
|
#define AP_RANGEFINDER_PULSEDLIGHTLRF_MSRREG_ACQUIRE 0x04 // Varies based on sensor revision, 0x04 is newest, 0x61 is older
|
2013-12-02 07:02:56 -04:00
|
|
|
|
2014-06-27 00:39:52 -03:00
|
|
|
class AP_RangeFinder_PulsedLightLRF : public AP_RangeFinder_Backend
|
2013-12-02 07:02:56 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2014-06-27 00:39:52 -03:00
|
|
|
// static detection function
|
2016-04-14 17:00:38 -03:00
|
|
|
static AP_RangeFinder_Backend *detect(RangeFinder &ranger, uint8_t instance,
|
|
|
|
RangeFinder::RangeFinder_State &_state);
|
2013-12-02 07:02:56 -04:00
|
|
|
|
2014-06-27 00:39:52 -03:00
|
|
|
// update state
|
|
|
|
void update(void);
|
2013-12-02 07:02:56 -04:00
|
|
|
|
|
|
|
|
2014-06-27 00:39:52 -03:00
|
|
|
private:
|
2016-04-14 17:00:38 -03:00
|
|
|
// constructor
|
|
|
|
AP_RangeFinder_PulsedLightLRF(RangeFinder &ranger, uint8_t instance,
|
|
|
|
RangeFinder::RangeFinder_State &_state);
|
|
|
|
|
2014-06-27 00:39:52 -03:00
|
|
|
// start a reading
|
2016-04-14 17:00:38 -03:00
|
|
|
bool start_reading(void);
|
|
|
|
bool get_reading(uint16_t &reading_cm);
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::I2CDevice> _dev;
|
2013-12-02 07:02:56 -04:00
|
|
|
};
|