This library uses the power enable pin on the lidar lite unit to enable multi-unit sampling. Attempted to add an additional change address function but didn't quite complete it. Thus, functionality of multiple units at the same time is achieved by the power enable pin and not by addressing the units separately.

Dependencies:   mbed

Fork of LidarLite by Akash Vibhute

Committer:
timmey9
Date:
Sat Feb 27 23:53:25 2016 +0000
Revision:
2:917b2a1835b0
Parent:
1:a01dc8b52be4
Cleaned up and simplified code.  Added change address functionality to speed up reads to LiDARs.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akashvibhute 0:8e6304ab38d2 1
akashvibhute 0:8e6304ab38d2 2 #ifndef LidarLite_H
akashvibhute 0:8e6304ab38d2 3 #define LidarLite_H
akashvibhute 0:8e6304ab38d2 4
jakelarsen17 1:a01dc8b52be4 5 #include "mbed.h"
akashvibhute 0:8e6304ab38d2 6
akashvibhute 0:8e6304ab38d2 7 // Default I2C Address of LIDAR-Lite.
timmey9 2:917b2a1835b0 8 #define LIDAR_LITE_DEFAULT_ADR 0x62
akashvibhute 0:8e6304ab38d2 9
timmey9 2:917b2a1835b0 10
akashvibhute 0:8e6304ab38d2 11
akashvibhute 0:8e6304ab38d2 12 // Read Registers
timmey9 2:917b2a1835b0 13 const char start_acquisition[2] = {0x00, 0x04}; // write 0x04 to control_reg[0x00] to initiate ranging
timmey9 2:917b2a1835b0 14 const char GET_DistanceHBReg = 0x0f; // High byte of distance reading data
timmey9 2:917b2a1835b0 15 const char GET_DistanceLBReg = 0x10; // Low byte of distance reading data
timmey9 2:917b2a1835b0 16 const char GET_VelocityReg = 0x09; // Velocity measurement data
akashvibhute 0:8e6304ab38d2 17
akashvibhute 0:8e6304ab38d2 18 class LidarLite
akashvibhute 0:8e6304ab38d2 19 {
akashvibhute 0:8e6304ab38d2 20 public:
akashvibhute 0:8e6304ab38d2 21 LidarLite(PinName sda, PinName scl); //Constructor
timmey9 2:917b2a1835b0 22 char address();
timmey9 2:917b2a1835b0 23 int16_t getVelocity(); //refreshes velocity data from registers of sensor
timmey9 2:917b2a1835b0 24 int32_t getDistance(); //refreshes range data from registers of sensor
timmey9 2:917b2a1835b0 25 void configure(int);
timmey9 2:917b2a1835b0 26 bool changeAddress(char);
akashvibhute 0:8e6304ab38d2 27
akashvibhute 0:8e6304ab38d2 28 private:
timmey9 2:917b2a1835b0 29 bool read(char, char*, int, bool);
timmey9 2:917b2a1835b0 30 bool write(char*, int);
timmey9 2:917b2a1835b0 31
jakelarsen17 1:a01dc8b52be4 32 I2C i2c_;
timmey9 2:917b2a1835b0 33 Serial debug;
timmey9 2:917b2a1835b0 34 char curr_address;
akashvibhute 0:8e6304ab38d2 35 };
akashvibhute 0:8e6304ab38d2 36
akashvibhute 0:8e6304ab38d2 37 #endif /* LidarLite_H */