22 #ifndef bufferDatatype 23 #define bufferDatatype uint16_t 33 #define BUFFER_ENABLE_MEAN 91 #ifdef BUFFER_ENABLE_MEAN
uint16_t length
The number of elements in the buffer.
Definition: kBuffer.h:47
bufferStatus_t bufferAvailable(buffer_t *buffer, uint16_t *available)
return, how many elements are stored and available in the buffer
Definition: kBuffer.c:386
bufferDatatype * data
A pointer to the first element of the buffer. Length * elementLength bytes of memory are allocated af...
Definition: kBuffer.h:53
bufferStatus_t bufferFill(buffer_t *buffer, bufferDatatype data, uint8_t silent)
fill the whole buffer with given dummy data.
Definition: kBuffer.c:359
bufferStatus_t bufferMeanRMS(buffer_t *buffer, bufferDatatype *meanOut)
take the root mean square of the whole buffer
Definition: kBuffer.c:452
uint16_t readPointer
The read pointer of the buffer. At a read procedure, data gets read and the pointer is incremented...
Definition: kBuffer.h:45
bufferStatus_t bufferMean(buffer_t *buffer, bufferDatatype *meanOut)
take the average of the whole buffer
Definition: kBuffer.c:424
bufferStatus_t bufferWrite(buffer_t *buffer, bufferDatatype data)
add data to the end of the ringbuffer
Definition: kBuffer.c:286
uint8_t isInitialized
is 0 if the buffer is not initialized
Definition: kBuffer.h:41
bufferStatus_t bufferPeek(buffer_t *buffer, bufferDatatype *data)
have a look at the next element in the buffer, but do not increase the read pointer ...
Definition: kBuffer.c:404
Struct for buffer handling. If you need a ringbuffer in your software, you should instantiate a buffe...
Definition: kBuffer.h:39
bufferStatus_t bufferWriteOverwrite(buffer_t *buffer, bufferDatatype data)
Add data to the end of the ringbuffer. If the buffer is full, overwrite the first data...
Definition: kBuffer.c:309
bufferStatus_t bufferReadFromIndex(buffer_t *buffer, uint16_t index, bufferDatatype *data)
read data from a specifig index of the buffer WARNING: Take care when using this function, it is against the main concept of a ringbuffer
Definition: kBuffer.c:236
uint16_t datacount
A variable which is increased by one when new data gets written and decremented by one when data is r...
Definition: kBuffer.h:51
bufferStatus_t bufferInit(buffer_t *buffer, uint16_t bufferSize)
init a new buffer This function inits a new buffer_t.
Definition: kBuffer.c:158
bufferStatus_t bufferRead(buffer_t *buffer, bufferDatatype *data)
read data from the beginning of the buffer
Definition: kBuffer.c:335
uint8_t elementLength
The number of bytes of one buffer element. The total memory consumption in Bytes is equal to length *...
Definition: kBuffer.h:49
uint16_t writePointer
The write pointer of the buffer. At a write procedure, data gets written and the pointer is increment...
Definition: kBuffer.h:43
bufferStatus_t
buffer function return codes
Definition: kBuffer.h:60
bufferStatus_t bufferInitStatic(buffer_t *buffer, uint16_t bufferSize, bufferDatatype *bufferArray)
init a new buffer This function inits a new buffer_t, but doesn't allocate the memory dynamically Yo...
Definition: kBuffer.c:187
uint8_t bufferIsEmpty(buffer_t *buffer)
Checks, wheter the buffer is empty.
Definition: kBuffer.c:255
bufferStatus_t bufferWriteToIndex(buffer_t *buffer, uint16_t index, bufferDatatype data)
write data to a specific index of the buffer. WARNING: Take care when using this function, it is against the main concept of a ringbuffer
Definition: kBuffer.c:212
uint8_t bufferIsFull(buffer_t *buffer)
Checks, wheter the buffer is full.
Definition: kBuffer.c:269
#define bufferDatatype
The datatype of one buffer element. As default, it is an 16 bit unsigned integer. Feel free to change...
Definition: kBuffer.h:23