Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
TFmini.h@13:89b65bfe6dda, 2020-04-06 (annotated)
- Committer:
- pmic
- Date:
- Mon Apr 06 05:57:56 2020 +0000
- Revision:
- 13:89b65bfe6dda
- Parent:
- 5:d97332d7f812
Change receiving driver and firmware. Data latency now 2.4 ms faster.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pmic | 5:d97332d7f812 | 1 | #ifndef TFMINI_H |
pmic | 5:d97332d7f812 | 2 | #define TFMINI_H |
pmic | 5:d97332d7f812 | 3 | |
pmic | 5:d97332d7f812 | 4 | #include <mbed.h> |
pmic | 5:d97332d7f812 | 5 | |
pmic | 5:d97332d7f812 | 6 | /** |
pmic | 5:d97332d7f812 | 7 | * This is a device driver class for the TFmini LiDAR. |
pmic | 5:d97332d7f812 | 8 | */ |
pmic | 5:d97332d7f812 | 9 | class TFmini |
pmic | 5:d97332d7f812 | 10 | { |
pmic | 5:d97332d7f812 | 11 | public: |
pmic | 5:d97332d7f812 | 12 | |
pmic | 5:d97332d7f812 | 13 | TFmini(RawSerial& serial); |
pmic | 5:d97332d7f812 | 14 | |
pmic | 5:d97332d7f812 | 15 | /** Return the distance to the nearest object, or -1.0 if not valid. |
pmic | 5:d97332d7f812 | 16 | */ |
pmic | 5:d97332d7f812 | 17 | float operator()() { |
pmic | 5:d97332d7f812 | 18 | return readDistance(); |
pmic | 5:d97332d7f812 | 19 | } |
pmic | 5:d97332d7f812 | 20 | |
pmic | 5:d97332d7f812 | 21 | virtual ~TFmini(); |
pmic | 5:d97332d7f812 | 22 | |
pmic | 5:d97332d7f812 | 23 | float readDistance(); |
pmic | 5:d97332d7f812 | 24 | float readStrength(); |
pmic | 5:d97332d7f812 | 25 | |
pmic | 5:d97332d7f812 | 26 | private: |
pmic | 5:d97332d7f812 | 27 | |
pmic | 5:d97332d7f812 | 28 | RawSerial& serial; // reference to serial interface for communication |
pmic | 5:d97332d7f812 | 29 | |
pmic | 5:d97332d7f812 | 30 | int16_t dist; // actual distance measurements of LiDAR |
pmic | 5:d97332d7f812 | 31 | int16_t strength; // signal strength of LiDAR |
pmic | 5:d97332d7f812 | 32 | uint16_t checksum; // save check value |
pmic | 5:d97332d7f812 | 33 | |
pmic | 5:d97332d7f812 | 34 | uint8_t uartData[9]; // buffer for seriel uart LiDar data |
pmic | 5:d97332d7f812 | 35 | uint8_t cnt; // dataCounter |
pmic | 5:d97332d7f812 | 36 | |
pmic | 5:d97332d7f812 | 37 | static const uint8_t HEADER = 0x59; //frame header of data package |
pmic | 5:d97332d7f812 | 38 | |
pmic | 5:d97332d7f812 | 39 | void receive(); |
pmic | 5:d97332d7f812 | 40 | |
pmic | 5:d97332d7f812 | 41 | }; |
pmic | 5:d97332d7f812 | 42 | |
pmic | 5:d97332d7f812 | 43 | #endif |