37template <
typename T, u
int16_t S>
67 uint16_t
getMaxSize(uint16_t byteSize) {
return byteSize - 2 - 2 *
sizeof(T) + 1; }
76 LOGw(
"Could not allocate memory");
97 LOGd(
"Could not assign at %u", buffer);
140 int32_t diff = (int32_t)value -
_buffer->lastVal;
142 if (diff > 127 || diff < -127) {
143 LOGw(
"diff too large! %u - %u", value,
_buffer->lastVal);
175 bool getValue(T& value,
const uint16_t index)
const {
176 if (index >=
size()) {
185 value +=
_buffer->array[index - 1];
Differential Buffer implementation.
Definition: cs_DifferentialBuffer.h:59
uint16_t getMaxByteSize(uint16_t capacity)
Definition: cs_DifferentialBuffer.h:65
DifferentialBuffer(uint16_t capacity)
Definition: cs_DifferentialBuffer.h:61
bool deinit()
Definition: cs_DifferentialBuffer.h:86
uint16_t size() const
Definition: cs_DifferentialBuffer.h:120
bool push(T value)
Definition: cs_DifferentialBuffer.h:128
bool full() const
Definition: cs_DifferentialBuffer.h:126
bool release()
Definition: cs_DifferentialBuffer.h:108
T peekFront() const
Definition: cs_DifferentialBuffer.h:170
bool _allocatedSelf
Definition: cs_DifferentialBuffer.h:192
uint16_t _capacity
Definition: cs_DifferentialBuffer.h:191
bool getValue(T &value, const uint16_t index) const
Definition: cs_DifferentialBuffer.h:175
virtual ~DifferentialBuffer()
Definition: cs_DifferentialBuffer.h:63
bool empty() const
Definition: cs_DifferentialBuffer.h:124
T pop()
Definition: cs_DifferentialBuffer.h:153
void clear()
Definition: cs_DifferentialBuffer.h:118
uint16_t capacity() const
Definition: cs_DifferentialBuffer.h:122
T peekBack() const
Definition: cs_DifferentialBuffer.h:165
uint16_t getMaxByteSize()
Definition: cs_DifferentialBuffer.h:66
differential_buffer_t< T > * _buffer
Definition: cs_DifferentialBuffer.h:190
bool assign(buffer_ptr_t buffer, uint16_t bufferSize)
Definition: cs_DifferentialBuffer.h:95
uint16_t getMaxSize(uint16_t byteSize)
Definition: cs_DifferentialBuffer.h:67
differential_buffer_t< T > * getBuffer()
Definition: cs_DifferentialBuffer.h:116
bool init()
Definition: cs_DifferentialBuffer.h:69
#define assert(expr, message)
Author: Crownstone Team Date: 21 Sep., 2013 License: LGPLv3+, Apache License 2.0, and/or MIT (triple-...
Definition: cs_Error.h:22
#define LOGw(fmt,...)
Definition: cs_Logger.h:92
#define LOGd(fmt,...)
Definition: cs_Logger.h:90
uint8_t * buffer_ptr_t
Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: 10 May....
Definition: cs_Typedefs.h:19
Struct with fixed length, useful when sending as payload.
Definition: cs_DifferentialBuffer.h:38
T firstVal
Value of the oldest element in the buffer.
Definition: cs_DifferentialBuffer.h:43
T lastVal
Value of the newest element in the buffer.
Definition: cs_DifferentialBuffer.h:46
uint16_t length
Number of elements stored in this struct.
Definition: cs_DifferentialBuffer.h:40
Struct with dynamic length, used by StackBuffer class.
Definition: cs_DifferentialBuffer.h:20
uint16_t length
Number of elements stored in this struct.
Definition: cs_DifferentialBuffer.h:22
T firstVal
Value of the oldest element in the buffer.
Definition: cs_DifferentialBuffer.h:25
T lastVal
Value of the newest element in the buffer.
Definition: cs_DifferentialBuffer.h:28