embedded-software
reusable software modules for embedded systems
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
filter.c File Reference
#include "filter.h"
#include <int_def.h>
#include "hal_general.h"
#include <string.h>
#include <stdio.h>
Include dependency graph for filter.c:

Macros

#define MAX   32768
 
#define FILTER_BUFFER_SIZE   10
 

Functions

void Filter_Init (filter_t *f_ptr, int16_t offset, float scale)
 Initializes all struct variables and calculates the shift based on scale input for linear transfer function. new_value = raw_value * scale + offset. More...
 
void Filter_Update (int16_t raw_value, filter_t *f_ptr)
 computes the new value after going through the transfer function and inputs it into filter buffer array More...
 
int16_t Filter_Get (filter_t *f_ptr)
 Filter_Get will retrieve the current value from the filter instance. More...
 
void Filter_SetMin (filter_t *f_ptr, int16_t threshold, void(*callback)(int16_t))
 Filter_SetMin will set the MIN value in the filter to the threshold specified. Calls the callback function with the current value when the value drops below the threshold. More...
 
void Filter_SetMax (filter_t *f_ptr, int16_t threshold, void(*callback)(int16_t))
 Filter_SetMin will set the MAX value in the filter to the threshold specified. Calls the callback function with the current value when the value goes above the threshold. More...
 
int16_t MovingAvgFilter (int16_t *values, uint16_t index, uint16_t size, int16_t Last_Value)
 Moving Average filter - Default filter that adds the previous X values and divides by number of values to compute a rolling mean. More...
 
void Filter_SetFilter (filter_t *f_ptr, int16_t(*new_filter)(int16_t *values, uint16_t index, uint16_t size, int16_t last_value))
 Method that allows user to pass a function to a pointer a different type of filter (i.e IIR, FIR) More...
 

Macro Definition Documentation

#define FILTER_BUFFER_SIZE   10
#define MAX   32768