174 return sizeof(T) +
size() - 1;
216 int32_t diff = (int32_t)value -
_lastVal;
217 if (diff > 127 || diff < -127) {
Differential Buffer implementation.
Definition: cs_CircularDifferentialBuffer.h:27
uint16_t _contentSize
Number of elements stored in the buffer.
Definition: cs_CircularDifferentialBuffer.h:247
uint16_t _tail
Index of the tail (where the next element will be inserted)
Definition: cs_CircularDifferentialBuffer.h:244
uint16_t _capacity
The capacity of the buffer (maximum number of elements)
Definition: cs_CircularDifferentialBuffer.h:238
T pop()
Get and remove the oldest element.
Definition: cs_CircularDifferentialBuffer.h:192
bool getFirstElement(T &val)
Get the first element of the buffer @val the value of the oldest element.
Definition: cs_CircularDifferentialBuffer.h:125
uint16_t capacity() const
Returns the capacity of the buffer.
Definition: cs_CircularDifferentialBuffer.h:96
uint16_t _readIdx
Index of the last read value, used in getNextElement()
Definition: cs_CircularDifferentialBuffer.h:256
T _lastVal
Value of the newest element in the buffer.
Definition: cs_CircularDifferentialBuffer.h:253
bool empty() const
Checks if the buffer is empty.
Definition: cs_CircularDifferentialBuffer.h:102
CircularDifferentialBuffer(uint16_t capacity=32, bool initialize=false)
Default constructor @capacity the size with which the buffer should be initialized.
Definition: cs_CircularDifferentialBuffer.h:40
uint16_t _head
Index of the head (next element to be removed)
Definition: cs_CircularDifferentialBuffer.h:241
T _firstVal
Value of the oldest element in the buffer.
Definition: cs_CircularDifferentialBuffer.h:250
uint16_t size() const
Returns the number of elements stored.
Definition: cs_CircularDifferentialBuffer.h:87
void incTail()
Increases the tail.
Definition: cs_CircularDifferentialBuffer.h:263
bool init()
Initializes and allocates memory for the buffer based on the capacity used with the constructor.
Definition: cs_CircularDifferentialBuffer.h:61
void serialize(uint8_t *buffer)
Write all elements to a buffer @buffer buffer to which to write the elements.
void incHead()
Increases the head.
Definition: cs_CircularDifferentialBuffer.h:274
T peek() const
Peek at the oldest element without removing it.
Definition: cs_CircularDifferentialBuffer.h:118
void clear()
Clears the buffer.
Definition: cs_CircularDifferentialBuffer.h:77
int8_t * _array
Pointer to the array storing the difference of elements compared to the previous element.
Definition: cs_CircularDifferentialBuffer.h:235
bool getNextElement(T &val)
Get the next value of the buffer, after calling <CircularDifferentialBuffer>>getFirstElement()>
Definition: cs_CircularDifferentialBuffer.h:141
bool full() const
Checks if the buffer is full.
Definition: cs_CircularDifferentialBuffer.h:108
bool push(T value)
Add an element to the end of the buffer @value the element to be added.
Definition: cs_CircularDifferentialBuffer.h:208
bool getLastElement(T &val)
Get the first element of the buffer @val the value of the oldest element.
Definition: cs_CircularDifferentialBuffer.h:158
uint16_t getSerializedLength() const
Get the serialized length.
Definition: cs_CircularDifferentialBuffer.h:170
virtual ~CircularDifferentialBuffer()
Default destructor.
Definition: cs_CircularDifferentialBuffer.h:51