mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-05-06 19:07:00 +02:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user