Skip to content

adafruit_mma8451: prefer 'struct', falling back to 'ustruct' #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions adafruit_mma8451.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@

* Author(s): Tony DiCola
"""
import ustruct
try:
import struct
except ImportError:
import ustruct as struct

from micropython import const

Expand Down Expand Up @@ -188,7 +191,7 @@ def acceleration(self):
# Read 6 bytes for 16-bit X, Y, Z values.
self._read_into(_MMA8451_REG_OUT_X_MSB, self._BUFFER, count=6)
# Reconstruct signed 16-bit integers.
x, y, z = ustruct.unpack('>hhh', self._BUFFER)
x, y, z = struct.unpack('>hhh', self._BUFFER)
x >>= 2
y >>= 2
z >>= 2
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
autodoc_mock_imports = ["digitalio", "busio", "ustruct", "micropython", "adafruit_bus_device", "adafruit_bus_device.i2c_device"]
autodoc_mock_imports = ["digitalio", "busio", "micropython", "adafruit_bus_device", "adafruit_bus_device.i2c_device"]

intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/bus_device/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}

Expand Down