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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor committed 2026-04-15 10:13:18 -04:00
1 parent 2a5c2fe35c
commit b1bbd6dabe
1 file changed
+1 -1
+1 -1
View File
@@ -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)