kinect受信用ライブラリ
Revision 0:cb6fcdae7ecf, committed 2018-08-28
- Comitter:
- skouki
- Date:
- Tue Aug 28 04:43:00 2018 +0000
- Commit message:
- ver2
Changed in this revision
kinectRX.cpp | Show annotated file Show diff for this revision Revisions of this file |
kinectRX.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kinectRX.cpp Tue Aug 28 04:43:00 2018 +0000 @@ -0,0 +1,30 @@ +#include "kinectRX.h" +KinectRX::KinectRX(): + fep(FEP_TX,FEP_RX,FEP_NUM) +{ +} + + +void KinectRX::receive_data(){ + len = 5; + while(true){ + count ++; + temp = fep.read(data,len); + if(temp == 0) { + count = 0; + break; + } + if(count > 10){ + count = 0; + break; + } + } +} + +int KinectRX::get_mode(){ + return(data[4]); +} + +int KinectRX::get_distance(){ + return(data[0] * 1000 + data[1] * 100 + data[2] * 10 + data[3]); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kinectRX.h Tue Aug 28 04:43:00 2018 +0000 @@ -0,0 +1,23 @@ +#ifndef MBED_KINECTRX_H +#define MBED_KINECTRX_H + +#include "mbed.h" +#include "FEP.h" +#include "cstdint" +#include "pin_config.h" + +class KinectRX{ +public: + KinectRX(); + void receive_data(); + int get_mode(); + int get_distance(); + +private: + char data[5]; + FEP fep; + int count; + uint8_t temp,len; +}; + +#endif