aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/mpu9250.py
diff options
context:
space:
mode:
Diffstat (limited to 'klippy/extras/mpu9250.py')
-rw-r--r--klippy/extras/mpu9250.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/klippy/extras/mpu9250.py b/klippy/extras/mpu9250.py
index 72c1f681..204ca870 100644
--- a/klippy/extras/mpu9250.py
+++ b/klippy/extras/mpu9250.py
@@ -4,8 +4,8 @@
# Copyright (C) 2020-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import logging, time, collections, threading, multiprocessing, os
-from . import bus, motion_report, adxl345
+import logging, time, threading, multiprocessing, os
+from . import bus, motion_report, adxl345, bulk_sensor
MPU9250_ADDR = 0x68
@@ -47,14 +47,13 @@ SCALE = 0.000244140625 * FREEFALL_ACCEL
FIFO_SIZE = 512
-Accel_Measurement = collections.namedtuple(
- 'Accel_Measurement', ('time', 'accel_x', 'accel_y', 'accel_z'))
-
MIN_MSG_TIME = 0.100
BYTES_PER_SAMPLE = 6
SAMPLES_PER_BLOCK = 8
+API_UPDATES = 0.100
+
# Printer class that controls MPU9250 chip
class MPU9250:
def __init__(self, config):
@@ -86,10 +85,11 @@ class MPU9250:
# Clock tracking
self.last_sequence = self.max_query_duration = 0
self.last_limit_count = self.last_error_count = 0
- self.clock_sync = adxl345.ClockSyncRegression(self.mcu, 640)
+ chip_smooth = self.data_rate * API_UPDATES * 2
+ self.clock_sync = bulk_sensor.ClockSyncRegression(mcu, chip_smooth)
# API server endpoints
self.api_dump = motion_report.APIDumpHelper(
- self.printer, self._api_update, self._api_startstop, 0.100)
+ self.printer, self._api_update, self._api_startstop, API_UPDATES)
self.name = config.get_name().split()[-1]
wh = self.printer.lookup_object('webhooks')
wh.register_mux_endpoint("mpu9250/dump_mpu9250", "sensor", self.name,