ESP-LiveControl
1.99.1
HTTP server, AJAX API backend and Vue.js web application implementing self-contained, zero-install WiFi remote control of hardware modules attached to the Espressif ESP32 SoC
|
Does a recursive moving average over N values. More...
#include <adc_filter_interpolation.hpp>
Public Member Functions | |
MovingAverageUInt16 (uint16_t init_value) | |
void | initialize (uint16_t init_value) |
Initializes the moving average filter with a start value. More... | |
void | input_data (uint16_t value_in) |
Read in a new datum and update the filter. More... | |
uint16_t | get_result () |
Get filter output value. More... | |
Protected Attributes | |
size_t | current_index = 0 |
std::array< uint16_t, N > | input_buffer |
uint32_t | result_sum |
Does a recursive moving average over N values.
Filter length must be power of two and smaller than 2^16
This is a template class to have a compile-time-known fixed divisor, allowing the compiler to use fast bit shift operation instead of int division.
|
inline |
Get filter output value.
|
inline |
Initializes the moving average filter with a start value.
Called from constructor but can also be called on demand.
init_value | Initial value |
|
inline |
Read in a new datum and update the filter.
value_in | Input datum, unsigned 16 bit |