diff --git a/adafruit_mma8451.py b/adafruit_mma8451.py index aa31fd7..5dfc29b 100644 --- a/adafruit_mma8451.py +++ b/adafruit_mma8451.py @@ -28,7 +28,10 @@ * Author(s): Tony DiCola """ -import ustruct +try: + import struct +except ImportError: + import ustruct as struct from micropython import const @@ -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 diff --git a/docs/conf.py b/docs/conf.py index 071b26a..2261eed 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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)}