From b1bbd6dabeab973aae189a53f3c493f6ea5048bd Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 12 Apr 2026 17:42:29 -0400 Subject: [PATCH] trigger_analog: Implement rounding in to_fixed_32() Round the SOS filter coefficients to the nearest integer (instead of truncating). Signed-off-by: Kevin O'Connor --- klippy/extras/trigger_analog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/klippy/extras/trigger_analog.py b/klippy/extras/trigger_analog.py index 3818926a4..7189c3027 100644 --- a/klippy/extras/trigger_analog.py +++ b/klippy/extras/trigger_analog.py @@ -22,7 +22,7 @@ def assert_is_int32(value, frac_bits): # convert a floating point value to a 32 bit fixed point representation # checks for overflow def to_fixed_32(value, frac_bits=0): - fixed_val = int(value * (2**frac_bits)) + fixed_val = int(round(value * (2**frac_bits))) return assert_is_int32(fixed_val, frac_bits) # Pre-generated SOS filters (avoid Scipy package for common installs)