aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/mpu9250.py
Commit message (Collapse)AuthorAgeFilesLines
* Isort all klippy codeTomasz Kramkowski2025-08-151-1/+2
|
* Run black on all first party python codeTomasz Kramkowski2025-08-061-49/+75
|
* adxl345: Fix read_axes_map() for non-adxl345 accelerometersKevin O'Connor2024-04-291-1/+1
| | | | | | | | | | | Commit 3f845019 unified the reading of the axes_map configuration variable, but broke the per-sensor scaling capabilities. Pass the scale parameters to read_axes_map() so that it can be implemented per-sensor. Reported by @Neko-vecter. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* bulk_sensor: Rework ChipClockUpdater class into FixedFreqReaderKevin O'Connor2024-04-201-20/+10
| | | | | | | Move the sensor_bulk_data message queuing into the class, and then rename that class. This simplifies the users of the code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* bulk_sensor: Refactor ChipClockUpdater constructorKevin O'Connor2024-04-201-9/+5
| | | | | | | Build the clock_sync and struct.Struct() in the ChipClockUpdater constructor. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mpu9250: Use extract_samples() for sample timestamp calculationKevin O'Connor2024-04-201-30/+11
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sensor_mpu9250: No need to schedule start of bulk readingKevin O'Connor2024-01-191-10/+16
| | | | | | It's simpler and faster to enable the mpu9250 in the python code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* bulk_sensor: Don't assume chip_clock is zero on start of queriesKevin O'Connor2024-01-191-1/+1
| | | | | | | Send an explicit clock query in ChipClockUpdater to seed the initial clock. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sensor_bulk: New C file with helper code for sending bulk sensor measurementsKevin O'Connor2024-01-191-16/+6
| | | | | | | | | | Refactor the low-level "bulk sensor" management code in the mcu. This updates the sensor_adxl345.c, sensor_mpu9250.c, sensor_lis2dw.c, and sensor_angle.c code to use the same "bulk sensor" messages. All of these sensors will now send "sensor_bulk_data" and "sensor_bulk_status" messages. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sensor_mpu9250: No need to send messages when stopping queriesKevin O'Connor2024-01-191-6/+2
| | | | | | Simplify the mcu code as any messages are ignored by the host anyway. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mpu9250: Fix incorrect use of time.sleep()Kevin O'Connor2024-01-071-3/+7
| | | | | | | | | | | It is not valid to call time.sleep() in the host python code (it could causes glitches in other processing, and it does not ensure there is a pause between operations on the mcu). Use minclock instead of time.sleep() to ensure there is a sufficient pause during chip startup. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* bulk_sensor: Simplify the registration of internal clients in BatchBulkHelperKevin O'Connor2023-12-261-2/+3
| | | | | | | | | | | | | | | Previously, the BatchBulkHelper class was designed primarily to register webhook clients, and internal clients used a wrapper class that emulated a webhooks client. Change BatchBulkHelper to support regular internal callbacks, and introduce a new BatchWebhooksClient class that can translate these internal callback to webhooks client messages. This makes it easier to register internal clients that can process the bulk messages every batch interval. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* bulk_sensor: Rework APIDumpHelper() to BatchBulkHelper()Kevin O'Connor2023-12-261-21/+14
| | | | | | | The APIDumpHelper class is mainly intended to help process messages in batches. Rework the class methods to make that more clear. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* bulk_sensor: New add_mux_endpoint() helper function in APIDumpHelperKevin O'Connor2023-12-261-7/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* bulk_sensor: Move APIDumpHelper() from motion_report.py to bulk_sensor.pyKevin O'Connor2023-12-261-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* adxl345: Add a read_axes_map() helper functionKevin O'Connor2023-12-261-6/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* adxl345: No need to implement is_measuring()Kevin O'Connor2023-12-261-9/+0
| | | | | | | The APIDumpHelper class already ensures that the start/stop callbacks will only be called when needed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* bulk_sensor: Add new ChipClockUpdater helper classKevin O'Connor2023-12-261-38/+11
| | | | | | | All the accelerometers use a standard response for their query_status messages. Create a common helper class to process those responses. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* bulk_sensor: Add new BulkDataQueue classKevin O'Connor2023-12-261-16/+5
| | | | | | | Move the bulk sample queue collection to a new helper class in bulk_sensor.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* bulk_sensor: New file with helper code for reading bulk sensorsKevin O'Connor2023-12-261-7/+7
| | | | | | | Move the ClockSyncRegression class from adxl345.py to a new bulk_sensors.py file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* adxl345: Simplify sequence and limit_count upconversionKevin O'Connor2023-12-101-11/+7
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sensor_mpu9250: Fix or improve reliability (#6170)Dr. Matthew Swabey2023-04-191-1/+1
| | | | | | | | | | | | | | | | | | | Fixes common MPU-9250 accelerometer issues for RPi Linux MCU and improves reliability on all other architectures by adjusting the MPU-* reading algorithm to only read whole Klipper messages' worth of data from MPU-* and eliminating many unnecessary checks of the MPU FIFO fill-level that consumed bus bandwidth needed for data transfer. Fixes intermittent "Lost communication with MCU 'rpi'" due to "Timer too close" and transposed / corrupted data due to FIFO overrun/data loss when using MPU-* accelerometers. In addition FIFO overrun checks are performed by testing the MPU interrupt flag vs. inferring from the FIFO fill level. Stress tested for 13hrs with two MPU-6500 attached to one I2C bus on RPi and one on a PR2040 Stress tested for 23hrs with two MPU-6500 attached to one I2C bus on RPi and one on a ATmega328P (Seeduino Nano) Signed-off-by: Matthew Swabey <matthew@swabey.org>
* mpu9250: add MPU6500 (#5767)Yifei Ding2022-11-191-4/+14
| | | Signed-off-by: Yifei Ding <yifeiding@protonmail.com>
* mpu9250: Inline twos_complement() codeKevin O'Connor2022-06-201-10/+5
| | | | | | | Calling python functions can have high overhead. Inline the twos_complement code in the _extract_samples() inner loop. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mpu9250: Use adxl345.AccelCommandHelper directlyKevin O'Connor2022-06-201-70/+1
| | | | | | | | | The MPU9250CommandHelper() class is nearly a duplicate of ADXL345CommandHelper(). Rename ADXL345QueryHelper() to AccelCommandHelper and remove user facing references to "adxl345". Use it directly from mpu9250.py . Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mpu9250: Use adxl345.ClockSyncRegression directlyKevin O'Connor2022-06-201-49/+1
| | | | | | | | The mpu9250.ClockSyncRegression() class is a duplicate of adxl345.ClockSyncRegression(). Remove the duplicate copy and use the code from adxl345.py . Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mpu9250: Use adxl345.AccelQueryHelper directlyKevin O'Connor2022-06-201-73/+2
| | | | | | | | The MPU9250QueryHelper() class is a duplicate of ADXL345QueryHelper(). Rename ADXL345QueryHelper() to AccelQueryHelper() and use it directly from mpu9250.py . Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mpu9250: Adding support for MPU-9250 (and MPU-6050) accelerometerbluesforte2022-06-161-0/+461
Add support for mpu9250 accelerometer over I2C bus. Signed-off-by: Harry Beyel <harry3b9@gmail.com>