Skip to content

Commit 5fb9902

Browse files
nefelim4agKevinOConnor
authored andcommitted
sos_filter: define filtfilt call
To implement host-side analysis of tap data, we need a way to apply the same filtering as on the mcu. As bonus, it cancels the induced signal delay. Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
1 parent dfe6d3f commit 5fb9902

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

klippy/extras/trigger_analog.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(self, sps, cfg_error, highpass=None, highpass_order=1,
3838
return
3939
try:
4040
import scipy.signal as signal
41+
import numpy
4142
except:
4243
raise cfg_error("DigitalFilter require the SciPy module")
4344
if highpass:
@@ -69,6 +70,12 @@ def get_filter_sections(self):
6970
def get_initial_state(self):
7071
return self.initial_state
7172

73+
def filtfilt(self, data):
74+
import scipy.signal as signal
75+
import numpy
76+
data = numpy.array(data)
77+
return signal.sosfiltfilt(self.filter_sections, data)
78+
7279
# Produce sample to sample difference (derivative) of a DigitalFilter
7380
class DerivativeFilter:
7481
def __init__(self, main_filter):

0 commit comments

Comments
 (0)