Skip to content
Snippets Groups Projects
Commit 593787c1 authored by Angel's avatar Angel
Browse files

fixed filter

parent 6070121e
No related branches found
No related tags found
No related merge requests found
...@@ -731,7 +731,6 @@ float movingAverageBatteryFilter(float new_input) ...@@ -731,7 +731,6 @@ float movingAverageBatteryFilter(float new_input)
static float inputs[N]; static float inputs[N];
inputs[0] = new_input;
// imagine an array of an even number of samples, we will output the one in the middle averaged with information from all of them. // imagine an array of an even number of samples, we will output the one in the middle averaged with information from all of them.
// for that, we only need to store some past of the signal // for that, we only need to store some past of the signal
float output = previous_output + new_input/N - inputs[N-1]/N; float output = previous_output + new_input/N - inputs[N-1]/N;
...@@ -741,6 +740,8 @@ float movingAverageBatteryFilter(float new_input) ...@@ -741,6 +740,8 @@ float movingAverageBatteryFilter(float new_input)
{ {
inputs[i] = inputs[i-1]; inputs[i] = inputs[i-1];
} }
inputs[0] = new_input;
// update previous output // update previous output
previous_output = output; previous_output = output;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment