aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-06-02 12:12:47 +0200
committerlonkaars <loek@pipeframe.xyz>2022-06-02 12:12:47 +0200
commitb12d6b2ecee0be03122a4bdba8ebbc91112fae3f (patch)
tree1bcc95eb0c26ffd1fbf23fab79f9ea80f26425b8 /shared
parent139651d45a72d57c5147e2854647d95cb87c9e4e (diff)
dirc working
Diffstat (limited to 'shared')
-rw-r--r--shared/util.c2
-rw-r--r--shared/util.h1
2 files changed, 3 insertions, 0 deletions
diff --git a/shared/util.c b/shared/util.c
index 55f3491..68503e8 100644
--- a/shared/util.c
+++ b/shared/util.c
@@ -4,3 +4,5 @@ unsigned long w2_util_exp_mov_avg(unsigned long current_avg, unsigned long new_m
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); }
diff --git a/shared/util.h b/shared/util.h
index 465e043..230c3e4 100644
--- a/shared/util.h
+++ b/shared/util.h
@@ -7,3 +7,4 @@
#define W2_RANGE(min, val, max) W2_MIN(max, W2_MAX(val, min))
unsigned long w2_util_exp_mov_avg(unsigned long current_avg, unsigned long new_meas);
+int w2_sign(int n);