Skip to content

Commit 999a4a1

Browse files
committed
adafruit_si4713: prefer 'struct', falling back to 'ustruct'
1 parent f389f1f commit 999a4a1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

adafruit_mma8451.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
2929
* Author(s): Tony DiCola
3030
"""
31-
import ustruct
31+
try:
32+
import struct
33+
except ImportError:
34+
import ustruct as struct
3235

3336
from micropython import const
3437

@@ -188,7 +191,7 @@ def acceleration(self):
188191
# Read 6 bytes for 16-bit X, Y, Z values.
189192
self._read_into(_MMA8451_REG_OUT_X_MSB, self._BUFFER, count=6)
190193
# Reconstruct signed 16-bit integers.
191-
x, y, z = ustruct.unpack('>hhh', self._BUFFER)
194+
x, y, z = struct.unpack('>hhh', self._BUFFER)
192195
x >>= 2
193196
y >>= 2
194197
z >>= 2

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Uncomment the below if you use native CircuitPython modules such as
1919
# digitalio, micropython and busio. List the modules you use. Without it, the
2020
# autodoc module docs will fail to generate with a warning.
21-
autodoc_mock_imports = ["digitalio", "busio", "ustruct", "micropython", "adafruit_bus_device", "adafruit_bus_device.i2c_device"]
21+
autodoc_mock_imports = ["digitalio", "busio", "micropython", "adafruit_bus_device", "adafruit_bus_device.i2c_device"]
2222

2323
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)}
2424

0 commit comments

Comments
 (0)