LidarLitev2 Library for distance reading. Capable of both single distance reads and continuous distance read setup.
Dependents: Lidar_Distance Lidar_DistanceContinuous Lidar_2D_Mapping Motions_Secure_Server_IUPUI ... more
Diff: LidarLitev2.h
- Revision:
- 1:238f6a0108e7
- Parent:
- 0:7e6c07be1754
- Child:
- 2:b0deebd36eb3
diff -r 7e6c07be1754 -r 238f6a0108e7 LidarLitev2.h --- a/LidarLitev2.h Thu Oct 22 18:52:54 2015 +0000 +++ b/LidarLitev2.h Thu Oct 22 23:49:53 2015 +0000 @@ -1,25 +1,59 @@ #ifndef LidarLitev2_H -#define LidarLitev2_H +#define LidarLitev2_H #include "mbed.h" +/** My LidarLite class +* Used for controlling and interacting with the LidarLitev2 +Example: +* @code +* //Measures distance from the lidarlite and prints it through serial +* #include "LidarLitev2.h" +* LidarLitev2 Lidar(p28, p27); +* Serial pc(USBTX,USBRX); +* +* +* Timer dt; +* int main() +* { +* +* pc.baud(115200); +* Lidar.configure(); +* dt.start(); +* while(1){ +* pc.printf("distance = %d cm frequency = %.2f Hz\n", Lidar.distance(), 1/dt.read()); +* dt.reset(); +* } +* } +* @endcode +* +* +*/ class LidarLitev2 { public: LidarLitev2(PinName sda, PinName scl, bool = true); // Constructor iniates I2C setup - void configure(int = 0, int = 0xc4); // Configure the mode and slave address + + /** Configure the different modes of the Lidar */ + void configure(int = 0, int = 0xc4); // Configure the mode and slave address + + /** Sets the Lidar to read continuously, indicating its ready to be read from by the modepin pulling down, a cerntain amount of times */ void beginContinuous(bool = true, char = 0x04, char = 0xff, int = 0xc4); //Enable if using continous setup with mode from Lidar and pulldown + + int distance(bool = true, bool = true, int = 0xc4); //Calclulates distance through I2C protocol of activating sensor with a write, then a write for the register, and a read. // Returns distance as a integer in cm + - int distanceContinuous(int = 0xc4); // 1.) Set Lidar circuit for continuous mode - // 2.) utilize the beginContinous function and configure as desired - // This function returns distance without any need to activate the lidar senore through a write command, - // instead the mode pin pulls down when the lidar is ready for a read + int distanceContinuous(int = 0xc4); + // 1.) Set Lidar circuit for continuous mode + // 2.) utilize the beginContinous function and configure as desired + // This function returns distance without any need to activate the lidar senore through a write command, + // instead the mode pin pulls down when the lidar is ready for a read // Returns distance as a integer in cm - + private: // I2C Functions // ///////////////////