Impact-Echo / Mbed 2 deprecated LidarLite_Multi-Unit

Dependencies:   mbed

Fork of LidarLite by Akash Vibhute

Committer:
jakelarsen17
Date:
Tue Jan 26 17:55:00 2016 +0000
Revision:
1:a01dc8b52be4
Parent:
0:8e6304ab38d2
Child:
2:917b2a1835b0
Changed some of the code for acquiring distance.  Attempted adding a change address functionality but didn't quite finish it. This code functions with multiple Lidar units without changing or doing any addressing other than using the default address.

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.
jakelarsen17 1:a01dc8b52be4 8 //#define LIDARLite_Adr 0x62
akashvibhute 0:8e6304ab38d2 9
akashvibhute 0:8e6304ab38d2 10 // Commands
akashvibhute 0:8e6304ab38d2 11 #define SET_CommandReg 0x00 // Register to write to initiate ranging
akashvibhute 0:8e6304ab38d2 12 #define AcqMode 0x04 // Value to set in control register to initiate ranging
akashvibhute 0:8e6304ab38d2 13
akashvibhute 0:8e6304ab38d2 14 // Read Registers
akashvibhute 0:8e6304ab38d2 15 #define GET_DistanceHBReg 0x0f // High byte of distance reading data
akashvibhute 0:8e6304ab38d2 16 #define GET_DistanceLBReg 0x10 // Low byte of distance reading data
akashvibhute 0:8e6304ab38d2 17 #define GET_Distance2BReg 0x8f // Register to get both High and Low bytes of distance reading data in 1 call
jakelarsen17 1:a01dc8b52be4 18 #define GET_VelocityReg 0x09 // Velocity measurement data
akashvibhute 0:8e6304ab38d2 19
akashvibhute 0:8e6304ab38d2 20 class LidarLite
akashvibhute 0:8e6304ab38d2 21 {
akashvibhute 0:8e6304ab38d2 22 public:
akashvibhute 0:8e6304ab38d2 23 LidarLite(PinName sda, PinName scl); //Constructor
jakelarsen17 1:a01dc8b52be4 24 int16_t refreshVelocity(char, char); //refreshes velocity data from registers of sensor
jakelarsen17 1:a01dc8b52be4 25 int16_t refreshRange(char, char); //refreshes range data from registers of sensor
jakelarsen17 1:a01dc8b52be4 26 void configure(int, char);
akashvibhute 0:8e6304ab38d2 27 int16_t getRange_cm(); //Read distance in cm from sensor
akashvibhute 0:8e6304ab38d2 28 int16_t getVelocity_cms(); //Read velocity in cm/s from sensor
jakelarsen17 1:a01dc8b52be4 29 void changeAddress(char, bool, char);
jakelarsen17 1:a01dc8b52be4 30 void changeAddressMultiPwrEn(int, DigitalOut*, char*, char);
akashvibhute 0:8e6304ab38d2 31
akashvibhute 0:8e6304ab38d2 32 private:
jakelarsen17 1:a01dc8b52be4 33 Serial debug;
jakelarsen17 1:a01dc8b52be4 34 I2C i2c_;
akashvibhute 0:8e6304ab38d2 35 int16_t distance_LL;
akashvibhute 0:8e6304ab38d2 36 int16_t velocity_LL;
akashvibhute 0:8e6304ab38d2 37 };
akashvibhute 0:8e6304ab38d2 38
akashvibhute 0:8e6304ab38d2 39 #endif /* LidarLite_H */