Library for the LidarLite, gets distance in cm using the pwm output
Fork of MaxbotixDriver by
Diff: LidarLitePwm.cpp
- Revision:
- 2:be66a4cd86c0
- Parent:
- 1:32f0a592b9e5
- Child:
- 3:0b1f4404cb21
diff -r 32f0a592b9e5 -r be66a4cd86c0 LidarLitePwm.cpp --- a/LidarLitePwm.cpp Wed Mar 18 08:55:54 2015 +0000 +++ b/LidarLitePwm.cpp Wed Mar 18 09:17:13 2015 +0000 @@ -1,11 +1,16 @@ #include "LidarLitePwm.h" -LidarLitePwm::LidarLitePwm(PinName pin, Timer& timer) : _interrupt(pin), _timer(timer), _pulseStartTime(0), _range(0) +LidarLitePwm::LidarLitePwm(PinName pin) : _interrupt(pin) { + _pulseStartTime = 0; + _range = 0; + _timer.start(); _interrupt.rise(this, &LidarLitePwm::pulseStart); _interrupt.fall(this, &LidarLitePwm::pulseStop); } +LidarLitePwm::~LidarLitePwm(){} + int LidarLitePwm::read() { return _range;