From 707b24dd07236243269cf092728f85172e94e8a4 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 8 Aug 2021 22:02:52 -0400 Subject: initial commit --- templates/6_iir_test.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 templates/6_iir_test.cpp (limited to 'templates/6_iir_test.cpp') diff --git a/templates/6_iir_test.cpp b/templates/6_iir_test.cpp new file mode 100644 index 0000000..cdb4ab3 --- /dev/null +++ b/templates/6_iir_test.cpp @@ -0,0 +1,13 @@ +adcsample_t *process_data(adcsample_t *samples, unsigned int size) +{ + constexpr float alpha = 0.7; + + static adcsample_t prev = 2048; + + samples[0] = (1 - alpha) * samples[0] + alpha * prev; + for (unsigned int i = 1; i < size; i++) + samples[i] = (1 - alpha) * samples[i] + alpha * samples[i - 1]; + prev = samples[size - 1]; + + return samples; +} -- cgit v1.2.3