2021 NHK B
Diff: OmniPosition.h
- Revision:
- 6:f8dbbe93bc7b
- Parent:
- 5:f8c3aeb4e65f
- Child:
- 7:73e542a88106
--- a/OmniPosition.h Wed Aug 22 20:21:48 2018 +0900 +++ b/OmniPosition.h Fri Aug 24 14:40:25 2018 +0900 @@ -2,8 +2,9 @@ #define OMNI_POSITION_H #include "mbed.h" +#include <vector> -#define OP_SERIAL_BUFFER_SIZE 9 +#define OP_SERIAL_BUFFER_SIZE 8 #define OP_HEADER_FIRST_BYTE 72 #define OP_HEADER_SECOND_BYTE 42 #define OP_RECEIVE_FREQ 0.05 @@ -14,37 +15,27 @@ public : OmniPosition(PinName serialTX, PinName serialRX); - int getX(); - int getY(); - double getTheta(); + int16_t getX(); + int16_t getY(); + float getTheta(); void reset(); private : - void readData(); + void receiveByte(); + void assembleLoop(); void assemble(); void send(); - int incrementCounter(int counter); - - int readCounter; - int takeCounter; - Ticker assembleTicker; + Thread thread; + std::vector<unsigned char> buf; Ticker sendTicker; - int X, bfrX; - int Y, bfrY; - int thetaint; - double theta, bfrTheta; + int16_t X; + int16_t Y; + int16_t theta; - char *buffer; - char *data; - - bool headerCheck; - int headerPoint; bool resetSend; - - uint8_t checksum; }; #endif