Library for the LidarLite, gets distance in cm using the pwm output
Fork of MaxbotixDriver by
LidarLitePwm.h@1:32f0a592b9e5, 2015-03-18 (annotated)
- Committer:
- joe4465
- Date:
- Wed Mar 18 08:55:54 2015 +0000
- Revision:
- 1:32f0a592b9e5
- Child:
- 2:be66a4cd86c0
V1.0 Works
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joe4465 | 1:32f0a592b9e5 | 1 | #include "mbed.h" |
joe4465 | 1:32f0a592b9e5 | 2 | |
joe4465 | 1:32f0a592b9e5 | 3 | #ifndef LidarLitePwm_H |
joe4465 | 1:32f0a592b9e5 | 4 | #define LidarLitePwm_H |
joe4465 | 1:32f0a592b9e5 | 5 | |
joe4465 | 1:32f0a592b9e5 | 6 | class LidarLitePwm |
joe4465 | 1:32f0a592b9e5 | 7 | { |
joe4465 | 1:32f0a592b9e5 | 8 | public: |
joe4465 | 1:32f0a592b9e5 | 9 | LidarLitePwm(PinName input, Timer& timer); |
joe4465 | 1:32f0a592b9e5 | 10 | |
joe4465 | 1:32f0a592b9e5 | 11 | /// Returns range in cm as int |
joe4465 | 1:32f0a592b9e5 | 12 | int read(); |
joe4465 | 1:32f0a592b9e5 | 13 | |
joe4465 | 1:32f0a592b9e5 | 14 | /// Returns the range in CM as an int |
joe4465 | 1:32f0a592b9e5 | 15 | operator int(); |
joe4465 | 1:32f0a592b9e5 | 16 | |
joe4465 | 1:32f0a592b9e5 | 17 | private: |
joe4465 | 1:32f0a592b9e5 | 18 | /// Inturrupt at start of pulse |
joe4465 | 1:32f0a592b9e5 | 19 | void pulseStart(); |
joe4465 | 1:32f0a592b9e5 | 20 | /// Interrupt at end of pulse |
joe4465 | 1:32f0a592b9e5 | 21 | void pulseStop(); |
joe4465 | 1:32f0a592b9e5 | 22 | |
joe4465 | 1:32f0a592b9e5 | 23 | /// Interrupt driver for the input pin |
joe4465 | 1:32f0a592b9e5 | 24 | InterruptIn _interrupt; |
joe4465 | 1:32f0a592b9e5 | 25 | /// Reference to global timer instance |
joe4465 | 1:32f0a592b9e5 | 26 | Timer& _timer; |
joe4465 | 1:32f0a592b9e5 | 27 | /// Time of the start of the current pulse |
joe4465 | 1:32f0a592b9e5 | 28 | int _pulseStartTime; |
joe4465 | 1:32f0a592b9e5 | 29 | /// The most recent sample |
joe4465 | 1:32f0a592b9e5 | 30 | int _range; |
joe4465 | 1:32f0a592b9e5 | 31 | }; |
joe4465 | 1:32f0a592b9e5 | 32 | |
joe4465 | 1:32f0a592b9e5 | 33 | #endif |