AlphaFilter: prevent setParameters division by zero

This commit is contained in:
Matthias Grob
2020-06-09 22:04:02 +02:00
committed by Daniel Agar
parent b7d54b5477
commit 38cbd1a182
+7 -1
View File
@@ -42,6 +42,8 @@
#pragma once
#include "../ecl.h"
template <typename T>
class AlphaFilter {
public:
@@ -65,7 +67,11 @@ public:
*
* @param alpha [0,1] filter weight for the previous state. High value - long time constant.
*/
void setAlpha(float alpha) { _alpha = alpha; }
void setAlpha(float alpha) {
if (ISFINITE(alpha)) {
_alpha = alpha;
}
}
/**
* Set filter state to an initial value