The last version programs
Dependencies: mbed TrapezoidControl Pulse QEI
Diff: CommonLibraries/RingBuffer/RingBuffer.h
- Revision:
- 0:669ef71cba68
diff -r 000000000000 -r 669ef71cba68 CommonLibraries/RingBuffer/RingBuffer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CommonLibraries/RingBuffer/RingBuffer.h Sat Sep 08 06:05:22 2018 +0000 @@ -0,0 +1,49 @@ +/* + * RingBuffer.h + * + * Created: 2016/08/10 12:15:08 + * Author: masuk + */ + + +#ifndef RINGBUFFER_H_ +#define RINGBUFFER_H_ + +#include <stdint.h> + +namespace RINGBUFFER +{ + //循環型バッファ 使用するバッファの配列と大きさを指定してください + class RingBuffer + { + struct + { + char *data; + int size; + uint8_t top; + uint8_t bottom; + uint8_t length; + bool fullup; + }Buffer; + + public: + RingBuffer(char *bufPtr, int size); + + //バッファにデータを追加 + void PutData(char data, bool ASCIItoNum = false); + void PutData(char *data, int length); + void PutData(const char *str); + + //バッファからデータを1byte読み出し + char GetData(); + + //バッファが飽和しているか確認 + bool IsFullup(); + //バッファにデータが存在するか確認 + bool InAnyData(); + }; +} + + + +#endif /* RINGBUFFER_H_ */