A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/mofosyne/sensor_smoother.c below:

GitHub - mofosyne/sensor_smoother.c

A small collection of sensor smoothing functions designed for embedded devices and other resource-constrained environments.

Pull requests and contributions are welcome!

The simple moving average function maintains a circular buffer of recent input values and returns their average. The user must allocate and manage this buffer.

sensor_smoother_simple_moving_average_t sma_state = {0};
sma_state.buffer = buffer; // pre-allocated float array
sma_state.buffer_size = sizeof(buffer) / sizeof(buffer[0]);

float smoothed_value = sensor_smoother_simple_moving_average(&sma_state, input);

The function performs runtime validation by default:

Exponential Moving Average

The exponential moving average uses a smoothing factor alpha between 0 (exclusive) and 1 (exclusive) to weight new input values. Smaller alpha values smooth more aggressively.

sensor_smoother_exponential_moving_average_t ema_state = {0};
ema_state.alpha = 0.1f;  // Smoothing factor: 0 < alpha < 1

float smoothed_value = sensor_smoother_exponential_moving_average(&ema_state, input);

The function performs runtime validation by default:

You can install this library using clib:

clib install mofosyne/sensor_smoother.c

This will download sensor_smoother.c and sensor_smoother.h into your project’s deps/ directory that you can then include into your codebase.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4