#pragma once // Ring buffer for async I/K-Bus message handling // Based on muki01/I-K_Bus RingBuffer (MIT license) #include class RingBuffer { public: RingBuffer(int size); ~RingBuffer(); int available(); int capacity(); // usable slots (size - 1, ring buffer wastes one) int peek(); int peek(int n); void remove(int n); int read(); byte write(int c); private: int _size; unsigned int _head; unsigned int _tail; byte* _buf; };