From 5bf85b860e0b947e8798083d02a798bd9e79b484 Mon Sep 17 00:00:00 2001 From: Taiki Komoda Date: Mon, 30 Oct 2023 20:34:52 +0900 Subject: [PATCH] updated --- LICENSE | 21 +++++++++++++++++++++ README.md | 32 ++++++++++++++++++++++++++++++-- mpu6886.py | 35 ----------------------------------- mpu6886_simpletest.py | 16 ++++++++++++++++ 4 files changed, 67 insertions(+), 37 deletions(-) create mode 100644 LICENSE create mode 100644 mpu6886_simpletest.py diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9adde91 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2022 JG for Cedar Grove Maker Studios + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 7234dc4..12f970b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,33 @@ # Circuitpython_MPU6886 -This repo is only copy of https://github.com/adafruit/Adafruit_CircuitPython_MPU6050 and changed minimally for minimum verification. +## Introduction -Not all functions is confirmed functional. \ No newline at end of file +CircuitPython helper library for the MPU6886 6-DoF Accelerometer and Gyroscope + +## Dependencies + +This driver depends on: + +* `Adafruit CircuitPython `_ +* `Bus Device `_ +* `Register `_ + +Please ensure all dependencies are available on the CircuitPython filesystem. + +## Usage Example + +``` +import time +import board +import mpu6886 + +i2c = board.I2C() # uses board.SCL and board.SDA +mpu = mpu6886.MPU6886(i2c) + +while True: + print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2"%(mpu.acceleration)) + print("Gyro X:%.2f, Y: %.2f, Z: %.2f degrees/s"%(mpu.gyro)) + print("Temperature: %.2f C"%mpu.temperature) + print("") + time.sleep(1) +``` diff --git a/mpu6886.py b/mpu6886.py index f6504b9..110ecb3 100755 --- a/mpu6886.py +++ b/mpu6886.py @@ -107,28 +107,6 @@ class GyroRange: # pylint: disable=too-few-public-methods RANGE_2000_DPS = 3 # +/- 2000 deg/s -class Bandwidth: # pylint: disable=too-few-public-methods - """Allowed values for :py:attr:`filter_bandwidth`. - - * :py:attr:`Bandwidth.BAND_260_HZ` - * :py:attr:`Bandwidth.BAND_184_HZ` - * :py:attr:`Bandwidth.BAND_94_HZ` - * :py:attr:`Bandwidth.BAND_44_HZ` - * :py:attr:`Bandwidth.BAND_21_HZ` - * :py:attr:`Bandwidth.BAND_10_HZ` - * :py:attr:`Bandwidth.BAND_5_HZ` - - """ - - BAND_260_HZ = 0 # Docs imply this disables the filter - BAND_184_HZ = 1 # 184 Hz - BAND_94_HZ = 2 # 94 Hz - BAND_44_HZ = 3 # 44 Hz - BAND_21_HZ = 4 # 21 Hz - BAND_10_HZ = 5 # 10 Hz - BAND_5_HZ = 6 # 5 Hz - - class Rate: # pylint: disable=too-few-public-methods """Allowed values for :py:attr:`cycle_rate`. @@ -187,7 +165,6 @@ def __init__(self, i2c_bus: I2C, address: int = _MPU6886_DEFAULT_ADDRESS) -> Non self.reset() self._sample_rate_divisor = 0 - self._filter_bandwidth = Bandwidth.BAND_260_HZ self._gyro_range = GyroRange.RANGE_500_DPS self._accel_range = Range.RANGE_2_G sleep(0.100) @@ -328,18 +305,6 @@ def accelerometer_range(self, value: int) -> None: self._accel_range = value sleep(0.01) - @property - def filter_bandwidth(self) -> int: - """The bandwidth of the gyroscope Digital Low Pass Filter. Must be a `GyroRange`""" - return self._filter_bandwidth - - @filter_bandwidth.setter - def filter_bandwidth(self, value: int) -> None: - if (value < 0) or (value > 6): - raise ValueError("filter_bandwidth must be a Bandwidth") - self._filter_bandwidth = value - sleep(0.01) - @property def cycle_rate(self) -> int: """The rate that measurements are taken while in `cycle` mode. Must be a `Rate`""" diff --git a/mpu6886_simpletest.py b/mpu6886_simpletest.py new file mode 100644 index 0000000..b52941a --- /dev/null +++ b/mpu6886_simpletest.py @@ -0,0 +1,16 @@ +#Sample script for MPU6886 + +import time +import board +from busio import I2C +import mpu6886 + +i2c = I2C(board.IMU_SCL, board.IMU_SDA) +mpu = mpu6886.MPU6886(i2c) + +while True: + print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2"%(mpu.acceleration)) + print("Gyro X:%.2f, Y: %.2f, Z: %.2f degrees/s"%(mpu.gyro)) + print("Temperature: %.2f C"%mpu.temperature) + print("") + time.sleep(1)