diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 570ca9b..157f2fc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,10 @@ -repos: - - repo: local - hooks: - - id: clang_restage - name: Restage formatted files - entry: clang_restage - language: system - pass_filenames: false - always_run: true +repos: + - repo: local + hooks: + - id: clang_restage + name: Restage formatted files + entry: clang_restage + language: system + pass_filenames: false + always_run: true stages: [pre-commit] \ No newline at end of file diff --git a/middleware/simple_ema.c b/middleware/simple_ema.c new file mode 100644 index 0000000..567b107 --- /dev/null +++ b/middleware/simple_ema.c @@ -0,0 +1,8 @@ +#include +#include "simple_ema.h" + +void ema_filter(float current_value, float *previous_ema, float alpha) +{ + *previous_ema = + (alpha * current_value) + ((1 - alpha) * (*previous_ema)); +} diff --git a/middleware/simple_ema.h b/middleware/simple_ema.h new file mode 100644 index 0000000..a70cc7a --- /dev/null +++ b/middleware/simple_ema.h @@ -0,0 +1,7 @@ +#ifndef SIMPLE_EMA +#define SIMPLE_EMA + +// Exponential Moving Average Lowpass Filter +void ema_filter(float current_value, float *previous_ema, float alpha); + +#endif /* SIMPLE_EMA */ \ No newline at end of file