summaryrefslogtreecommitdiff
path: root/shared/util.c
blob: 68503e8375fdc32dea52e337cf6b9752149f1f74 (plain)
1
2
3
4
5
6
7
8
#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))));
}

int w2_sign(int n) { return (n > 0) - (n < 0); }