|
Envorimental Monitoring
|
Circular (ring) buffer for float sensor samples. More...
#include "stdint.h"#include "stdbool.h"Go to the source code of this file.
Data Structures | |
| struct | buf_handle_t |
| Ring buffer control structure. More... | |
Functions | |
| void | buffer_init (buf_handle_t *p_handle, float *p_buffer, uint16_t size) |
| Initialises a ring buffer handle. | |
| bool | buffer_isFull (buf_handle_t *p_handle) |
| Checks whether the buffer is full. | |
| void | buffer_clear (buf_handle_t *p_handle) |
| Resets the buffer to an empty state without clearing storage memory. | |
| bool | buffer_isEmpty (buf_handle_t *p_handle) |
| Checks whether the buffer is empty. | |
| int | buffer_get_value (buf_handle_t *p_handle, float *p_sensor_data) |
| Reads and removes the oldest sample from the buffer (FIFO order). | |
| int | buffer_write_value (buf_handle_t *p_handle, float p_sensor_data) |
| Writes a new sample into the buffer. | |
Circular (ring) buffer for float sensor samples.
Provides a fixed-size, overwrite-on-full circular buffer used to store the most recent RING_BUFFER_SIZE filtered sensor readings. When the buffer is full, the oldest sample is silently overwritten by the newest one.
| void buffer_clear | ( | buf_handle_t * | p_handle | ) |
Resets the buffer to an empty state without clearing storage memory.
| [in,out] | p_handle | Pointer to the buffer handle. |
| int buffer_get_value | ( | buf_handle_t * | p_handle, |
| float * | p_sensor_data ) |
Reads and removes the oldest sample from the buffer (FIFO order).
| [in,out] | p_handle | Pointer to the buffer handle. |
| [out] | p_sensor_data | Pointer to the float that receives the value. |
| void buffer_init | ( | buf_handle_t * | p_handle, |
| float * | p_buffer, | ||
| uint16_t | size ) |
Initialises a ring buffer handle.
Must be called once before any other buffer operation. The caller provides the backing storage array and its capacity.
| [out] | p_handle | Pointer to the buffer handle to initialise. |
| [in] | p_buffer | Pointer to the float array used as storage. |
| [in] | size | Number of elements in p_buffer. |
| bool buffer_isEmpty | ( | buf_handle_t * | p_handle | ) |
Checks whether the buffer is empty.
| [in] | p_handle | Pointer to the buffer handle. |
| bool buffer_isFull | ( | buf_handle_t * | p_handle | ) |
Checks whether the buffer is full.
| [in] | p_handle | Pointer to the buffer handle. |
| int buffer_write_value | ( | buf_handle_t * | p_handle, |
| float | p_sensor_data ) |
Writes a new sample into the buffer.
If the buffer is full the oldest sample is overwritten (count is kept at size). This ensures the buffer always holds the most recent samples.
| [in,out] | p_handle | Pointer to the buffer handle. |
| [in] | p_sensor_data | Float value to store. |