TFmini(Micro LiDAR Module) library tested on mbedos5.x
Dependents: 2018NHK_gakugaku_robo 2018NHK_gaku_ver2 2019NHK_A_sensor
TFmini.h@5:eeb0e5bdd8b9, 2018-08-29 (annotated)
- Committer:
- UCHITAKE
- Date:
- Wed Aug 29 09:19:56 2018 +0000
- Revision:
- 5:eeb0e5bdd8b9
- Parent:
- 4:7622beb45675
- Child:
- 6:3651a37efd0e
add checksum
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
UCHITAKE | 0:fe2031b62770 | 1 | #ifndef TFMINI_H |
UCHITAKE | 0:fe2031b62770 | 2 | #define TFMINI_H |
UCHITAKE | 0:fe2031b62770 | 3 | |
UCHITAKE | 4:7622beb45675 | 4 | /** |
UCHITAKE | 4:7622beb45675 | 5 | * Includes |
UCHITAKE | 4:7622beb45675 | 6 | */ |
UCHITAKE | 0:fe2031b62770 | 7 | #include "mbed.h" |
UCHITAKE | 4:7622beb45675 | 8 | #include <vector> |
UCHITAKE | 0:fe2031b62770 | 9 | |
UCHITAKE | 4:7622beb45675 | 10 | /** |
UCHITAKE | 4:7622beb45675 | 11 | * Defines |
UCHITAKE | 4:7622beb45675 | 12 | */ |
takeuchi |
1:12f2bfb3577a | 13 | #define TF_SERIAL_BUFFER_SIZE 9 |
takeuchi |
1:12f2bfb3577a | 14 | #define TF_HEADER_FIRST_BYTE 0x59 |
takeuchi |
1:12f2bfb3577a | 15 | #define TF_HEADER_SECOND_BYTE 0x59 |
takeuchi |
1:12f2bfb3577a | 16 | #define TF_DEFAULT_BAUD 115200 |
UCHITAKE | 0:fe2031b62770 | 17 | |
UCHITAKE | 4:7622beb45675 | 18 | /** |
UCHITAKE | 4:7622beb45675 | 19 | * TFmini(LiDAR snsor)\\ |
UCHITAKE | 4:7622beb45675 | 20 | * sample code is here https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/TFmini_sample/ |
UCHITAKE | 4:7622beb45675 | 21 | */ |
UCHITAKE | 0:fe2031b62770 | 22 | class TFmini : public RawSerial { |
UCHITAKE | 0:fe2031b62770 | 23 | public : |
UCHITAKE | 0:fe2031b62770 | 24 | TFmini(PinName serialTX, PinName serialRX); |
UCHITAKE | 0:fe2031b62770 | 25 | |
UCHITAKE | 0:fe2031b62770 | 26 | int getDistance(); |
UCHITAKE | 0:fe2031b62770 | 27 | int getStrength(); |
UCHITAKE | 5:eeb0e5bdd8b9 | 28 | int getSize(); |
UCHITAKE | 0:fe2031b62770 | 29 | |
UCHITAKE | 0:fe2031b62770 | 30 | private : |
UCHITAKE | 4:7622beb45675 | 31 | void receiveByte(); |
UCHITAKE | 4:7622beb45675 | 32 | void assembleLoop(); |
UCHITAKE | 0:fe2031b62770 | 33 | void assemble(); |
UCHITAKE | 0:fe2031b62770 | 34 | |
UCHITAKE | 4:7622beb45675 | 35 | Thread thread; |
UCHITAKE | 4:7622beb45675 | 36 | std::vector<unsigned char> buf; |
UCHITAKE | 0:fe2031b62770 | 37 | |
UCHITAKE | 0:fe2031b62770 | 38 | int distance; |
UCHITAKE | 0:fe2031b62770 | 39 | int strength; |
UCHITAKE | 0:fe2031b62770 | 40 | }; |
UCHITAKE | 0:fe2031b62770 | 41 | |
takeuchi |
1:12f2bfb3577a | 42 | #endif |