summaryrefslogtreecommitdiff
path: root/shared/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared/util.c')
-rw-r--r--shared/util.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/shared/util.c b/shared/util.c
new file mode 100644
index 0000000..55f3491
--- /dev/null
+++ b/shared/util.c
@@ -0,0 +1,6 @@
+#include "consts.h"
+
+unsigned long w2_util_exp_mov_avg(unsigned long current_avg, unsigned long new_meas) {
+ return (unsigned long)((((double)(current_avg)) * ((double)(1.f - W2_EMA_WEIGHT))) +
+ (((double)(new_meas)) * ((double)(W2_EMA_WEIGHT))));
+}