受信用
Revision 0:dcb57ed979f0, committed 2018-10-12
- Comitter:
- tanabe2000
- Date:
- Fri Oct 12 04:40:32 2018 +0000
- Commit message:
- kinect???
Changed in this revision
fep_kinect.cpp | Show annotated file Show diff for this revision Revisions of this file |
fep_kinect.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r dcb57ed979f0 fep_kinect.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fep_kinect.cpp Fri Oct 12 04:40:32 2018 +0000 @@ -0,0 +1,25 @@ +#include"fep_kinect.h" + +fep_kinect::fep_kinect(PinName tx,PinName rx,uint8_t addr,int baud) : + fep_(tx,rx,addr,baud) +{ + fep_.startReceive(2); +} + + +uint16_t fep_kinect::get_distance() +{ + return data_[0]; +} + +uint16_t fep_kinect::get_mode() +{ + return data_[1]; +} +void fep_kinect::newdata() +{ + fep_.getData(data); + data_[2] = (int(data[0]) << 8) | int(data[1]); + data_[1] = data_[2] % 10; + data_[0] = data_[2] / 10; +} \ No newline at end of file
diff -r 000000000000 -r dcb57ed979f0 fep_kinect.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fep_kinect.h Fri Oct 12 04:40:32 2018 +0000 @@ -0,0 +1,20 @@ +#ifndef FEP_KINECT_H +#define FEP_KINECT_H + +#include"FEP.h" +#include"mbed.h" + +class fep_kinect +{ +public: + fep_kinect(PinName tx, PinName rx, uint8_t addr, int baud=115200); + uint16_t get_distance(void); + uint16_t get_mode(void); + void newdata(void); +private: + FEP fep_; + uint8_t data[2]; + uint16_t data_[3]; +}; + +#endif \ No newline at end of file