TFmini(Micro LiDAR Module) library tested on mbedos5.x

Dependents:   2018NHK_gakugaku_robo 2018NHK_gaku_ver2 2019NHK_A_sensor

Committer:
UCHITAKE
Date:
Tue Aug 21 05:18:03 2018 +0000
Revision:
0:fe2031b62770
Child:
1:12f2bfb3577a
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
UCHITAKE 0:fe2031b62770 1 #ifndef TFMINI_H
UCHITAKE 0:fe2031b62770 2 #define TFMINI_H
UCHITAKE 0:fe2031b62770 3
UCHITAKE 0:fe2031b62770 4 #include "mbed.h"
UCHITAKE 0:fe2031b62770 5 #include "CycleInt.h"
UCHITAKE 0:fe2031b62770 6
UCHITAKE 0:fe2031b62770 7 #define SERIAL_BUFFER_SIZE 9
UCHITAKE 0:fe2031b62770 8 #define HEADER_FIRST_BYTE 0x59
UCHITAKE 0:fe2031b62770 9 #define HEADER_SECOND_BYTE 0x59
UCHITAKE 0:fe2031b62770 10 #define RECEIVE_FREQ 0.01
UCHITAKE 0:fe2031b62770 11 #define DEFAULT_BAUD 115200
UCHITAKE 0:fe2031b62770 12
UCHITAKE 0:fe2031b62770 13 class TFmini : public RawSerial {
UCHITAKE 0:fe2031b62770 14 public :
UCHITAKE 0:fe2031b62770 15 TFmini(PinName serialTX, PinName serialRX);
UCHITAKE 0:fe2031b62770 16
UCHITAKE 0:fe2031b62770 17 int getDistance();
UCHITAKE 0:fe2031b62770 18 int getStrength();
UCHITAKE 0:fe2031b62770 19
UCHITAKE 0:fe2031b62770 20 private :
UCHITAKE 0:fe2031b62770 21 void readData();
UCHITAKE 0:fe2031b62770 22 void assemble();
UCHITAKE 0:fe2031b62770 23
UCHITAKE 0:fe2031b62770 24 CycleInt readCounter;
UCHITAKE 0:fe2031b62770 25 CycleInt takeCounter;
UCHITAKE 0:fe2031b62770 26 Ticker assembleTicker;
UCHITAKE 0:fe2031b62770 27
UCHITAKE 0:fe2031b62770 28 int distance;
UCHITAKE 0:fe2031b62770 29 int strength;
UCHITAKE 0:fe2031b62770 30
UCHITAKE 0:fe2031b62770 31 uint8_t *buffer;
UCHITAKE 0:fe2031b62770 32 uint8_t *data;
UCHITAKE 0:fe2031b62770 33
UCHITAKE 0:fe2031b62770 34 bool headerCheck;
UCHITAKE 0:fe2031b62770 35 int headerPoint;
UCHITAKE 0:fe2031b62770 36 };
UCHITAKE 0:fe2031b62770 37
UCHITAKE 0:fe2031b62770 38 #endif