Skip to content

Commit

Permalink
Feature/lowpass filter (#210)
Browse files Browse the repository at this point in the history
* #173: casual lowpass filter

* #173: finalized file location

* #173: Added a simple_ema.h file

* added void to function line
  • Loading branch information
DimitryP6 authored Jan 14, 2025
1 parent e02f66b commit 94c5d89
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
8 changes: 8 additions & 0 deletions middleware/simple_ema.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <stdio.h>
#include "simple_ema.h"

void ema_filter(float current_value, float *previous_ema, float alpha)
{
*previous_ema =
(alpha * current_value) + ((1 - alpha) * (*previous_ema));
}
7 changes: 7 additions & 0 deletions middleware/simple_ema.h
Original file line number Diff line number Diff line change
@@ -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 */

0 comments on commit 94c5d89

Please sign in to comment.