SoftFilters
0.1.0
Arduino framework and library of software data filters.
|
A filter with a data cache, which is suitable for output that depends on several previous input data. More...
#include <SoftFilters.h>
Public Member Functions | |
CachedFilter (size_t cap) | |
![]() | |
bool | push (void const *const input, void *const output) |
Push a new data through the filter. More... | |
Protected Member Functions | |
virtual bool | update (void const *const input) override |
Internally update the filter output based on the given input. More... | |
virtual bool | refresh (IN_T const *const new_val, IN_T const *const old_val, OUT_T &output)=0 |
Refresh the output value given the new value added to the cache and the old value removed from the cache. More... | |
size_t | get_capacity () |
size_t | get_size () |
![]() | |
virtual void const *const | get_output_val_ptr () final |
Push a new data through the filter. More... | |
virtual void | copy_to_client (void *const output) final |
Copy the output to client memory. | |
Private Attributes | |
size_t | capacity |
The cache capacity, i.e., maximum data it can hold. | |
size_t | size |
The current cache size, i.e., valid data. | |
IN_T * | buffer |
The internal buffer that holds the cached data. | |
int | end |
The position in the internal buffer that points to the end of the cache. More... | |
IN_T | cached_val |
used to temporarily store the old data before overwritten by the new data | |
Additional Inherited Members | |
![]() | |
OUT_T | out_val |
Internally managed storage of the output value. | |
A filter with a data cache, which is suitable for output that depends on several previous input data.
This class is internally implemented as a circular buffer.
IN_T | input data type |
OUT_T | output data type |
|
protectedpure virtual |
Refresh the output value given the new value added to the cache and the old value removed from the cache.
Implemented in MovingVarianceFilter< IN_T, OUT_T, INTERNAL_T >, and MovingAverageFilter< IN_T, OUT_T, INTERNAL_T >.
|
inlineoverrideprotectedvirtual |
Internally update the filter output based on the given input.
This method behaves similarly to the public Filter::push method, but without copying the output to the client memory. This method is for internal workings of the filter framework.
Implements Filter.
|
private |
The position in the internal buffer that points to the end of the cache.
New data will be written at this position and this value will be incremented, wrapping around at the boundary of the internal buffer. When the cache is full, this position points at the oldest data which will be overwritten by the next incoming data.