Core
Loading...
Searching...
No Matches
filter.h File Reference

Core filter library. More...

#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  core_filter_s
 

Typedefs

typedef struct core_filter_s core_filter_t
 

Functions

float core_filter_update (float x, core_filter_t *filt)
 Get an output value from the filter. This is the primary function being called.
 
bool core_filter_rolling_avg_init (uint8_t order, core_filter_t *filt)
 Initialize a rolling average. This will apply an even coefficient across the last (order) inputs to the filter.
 
bool core_filter_exp_lowpass_init (float a, core_filter_t *filt)
 Initialize an exponential lowpass filter.
 

Detailed Description

Core filter library.

This core library components is used to handle general-purpose digital filters. The filters work via coefficient arrays, which determine the weighting that previous inputs and outputs have on the current output.

These arrays and the corresponding information for them will be set up within the specialized init functions for each filter type.

Function Documentation

◆ core_filter_exp_lowpass_init()

bool core_filter_exp_lowpass_init ( float a,
core_filter_t * filt )

Initialize an exponential lowpass filter.

Parameters
aAlpha value for the filter. This represents the weighting of the current input. The weighting of the previous output is indirectly propertional to (a)
filtFilter object to apply input to
Returns
True if initialized, false if error occured

◆ core_filter_rolling_avg_init()

bool core_filter_rolling_avg_init ( uint8_t order,
core_filter_t * filt )

Initialize a rolling average. This will apply an even coefficient across the last (order) inputs to the filter.

Parameters
orderNumber of inputs to consider in the rolling average (an order of 1 is no filter, the output will be the input)
filtFilter object to apply input to
Returns
True if initialized, false if error occured

◆ core_filter_update()

float core_filter_update ( float x,
core_filter_t * filt )

Get an output value from the filter. This is the primary function being called.

Parameters
xInput to filter
filtFilter object to apply input to
Returns
The filter output