Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: X_NUCLEO_53L0A1 mbed
Fork of 53L0A1_HandGestureRecognition by
Ring Buffer
[Misc]
Simple ring buffer implementation. More...
Data Structures | |
| struct | ring_buffer |
| Simple ring buffer of int with a programmable size (max size is RB_MAX_SIZE) More... | |
Functions | |
| int | RB_init (ring_buffer *rb, int size) |
| Initialize Ring Buffer. | |
| int | RB_push (ring_buffer *rb, int data) |
| Push one element in Ring Buffer (after the last element) | |
| int | RB_pop (ring_buffer *rb) |
| pop one element in Ring Buffer (the last element) | |
| bool | RB_full (ring_buffer *rb) |
| Check if ring buffer is full. | |
| void | RB_trace (ring_buffer *rb) |
| print/trace all elements in the ring buffer | |
| int | RB_sum (ring_buffer *rb) |
| Return the sum of elements in the ring buffer. | |
| int | RB_mean (ring_buffer *rb) |
| Return the mean of all elements in the ring buffer. | |
| int | RB_mad (ring_buffer *rb) |
| Return the mean of the absolute differences of each element with the mean. | |
| int | RB_dir (ring_buffer *rb) |
| Return the direction of the curve of points stored in the buffer. | |
Detailed Description
Simple ring buffer implementation.
- Description
- Ring buffer is implemented as a static array of integers of size RB_MAX_SIZE. The functional size of the ring buffer is programmable. When the ring_buffer is full, new elements added are replacing the older elements. This is typically used to keep an history of the last ranging values measured from the ToF device.
Function Documentation
| int RB_dir | ( | ring_buffer * | rb ) |
Return the direction of the curve of points stored in the buffer.
- Parameters:
-
rb Ring Buffer pointer
- Returns:
- 1 if constantly increase, -1 if constantly decrease, 0 otherwise
Definition at line 150 of file ring_buffer.c.
| bool RB_full | ( | ring_buffer * | rb ) |
Check if ring buffer is full.
- Parameters:
-
rb Ring Buffer pointer
- Returns:
- true if full else false
Definition at line 87 of file ring_buffer.c.
| int RB_init | ( | ring_buffer * | rb, |
| int | size | ||
| ) |
Initialize Ring Buffer.
- Parameters:
-
rb Ring Buffer pointer size Number of int elements (max size is RB_MAX_SIZE)
- Returns:
- 0 on success or -1 if size is greater than RB_MAX_SIZE
Definition at line 41 of file ring_buffer.c.
| int RB_mad | ( | ring_buffer * | rb ) |
Return the mean of the absolute differences of each element with the mean.
- Parameters:
-
rb Ring Buffer pointer
- Returns:
- The mad (rounded to integer)
Definition at line 129 of file ring_buffer.c.
| int RB_mean | ( | ring_buffer * | rb ) |
Return the mean of all elements in the ring buffer.
- Parameters:
-
rb Ring Buffer pointer
- Returns:
- The mean (rounded to integer)
Definition at line 124 of file ring_buffer.c.
| int RB_pop | ( | ring_buffer * | rb ) |
pop one element in Ring Buffer (the last element)
- Parameters:
-
rb Ring Buffer pointer
- Returns:
- element
Definition at line 73 of file ring_buffer.c.
| int RB_push | ( | ring_buffer * | rb, |
| int | data | ||
| ) |
Push one element in Ring Buffer (after the last element)
- Function Description
- If ring buffer is full, added element is replacing the oldest element in the ring buffer
- Parameters:
-
rb Ring Buffer pointer data Element to add
- Returns:
- 0 on success
Definition at line 51 of file ring_buffer.c.
| int RB_sum | ( | ring_buffer * | rb ) |
Return the sum of elements in the ring buffer.
- Parameters:
-
rb Ring Buffer pointer
- Returns:
- The sum
Definition at line 108 of file ring_buffer.c.
| void RB_trace | ( | ring_buffer * | rb ) |
print/trace all elements in the ring buffer
- Parameters:
-
rb Ring Buffer pointer
- Note:
- The TRACE key must be defined in the project
Definition at line 92 of file ring_buffer.c.
Generated on Wed Jul 13 2022 14:16:16 by
1.7.2
