klipper
klipper copied to clipboard
accelerometer: Fix LIS2DW and MPU9250 abnormal reading
Fix abnormal reading when using ACCELEROMETER_QUERY
and MEASURE_AXES_NOISE
.
Below is what happen after commit 43ce7c0b9ad4f30277c10b086b86a0937dbfebbc
. The ACCELEROMETER_QUERY
and MEASURE_AXES_NOISE
reading are abnormal. It around 7 times larger than normal value.
line 40 in lis2dw.py
self.axes_map = adxl345.read_axes_map(config)
The LIS2DW and MCP9250 are using the ADXL345 SCALE
value.
After change self.axes_map
using the LIS2DW SCALE
value.
am = {'x': (0, SCALE), 'y': (1, SCALE), 'z': (2, SCALE),
'-x': (0, -SCALE), '-y': (1, -SCALE), '-z': (2, -SCALE)}
axes_map = config.getlist('axes_map', ('x','y','z'), count=3)
if any([a not in am for a in axes_map]):
raise config.error("Invalid lis2dw axes_map parameter")
self.axes_map = [am[a.strip()] for a in axes_map]
Below is the result after using LIS2DW SCALE
value.
Signed-off-by: Vecter Fang [email protected]
Thanks. Good catch. I implemented a slightly different fix (commit d8d072b3).
-Kevin
This ticket is being closed because the underlying issue is now thought to be resolved.
Best regards, ~ Your friendly GitIssueBot
PS: I'm just an automated script, not a human being.