Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiki Komoda committed Oct 30, 2023
1 parent 78f6e69 commit 5bf85b8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 37 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
CircuitPython helper library for the MPU6886 6-DoF Accelerometer and Gyroscope

## Dependencies

This driver depends on:

* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
* `Register <https://github.com/adafruit/Adafruit_CircuitPython_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)
```
35 changes: 0 additions & 35 deletions mpu6886.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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`"""
Expand Down
16 changes: 16 additions & 0 deletions mpu6886_simpletest.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 5bf85b8

Please sign in to comment.