Skip to content

Commit a173c26

Browse files
committed
adafruit_si4713: prefer 'struct', falling back to 'ustruct'
1 parent 1210a49 commit a173c26

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

adafruit_si4713.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
import time
3333

3434
from micropython import const
35-
import ustruct
35+
try:
36+
import struct
37+
except ImportError:
38+
import ustruct as struct
3639

3740
import adafruit_bus_device.i2c_device as i2c_device
3841

@@ -379,7 +382,7 @@ def input_level(self):
379382
"""
380383
# Perform ASQ request, then parse out 8 bit _signed_ input level value.
381384
self._asq_status()
382-
return ustruct.unpack('bbbbb', self._BUFFER)[4]
385+
return struct.unpack('bbbbb', self._BUFFER)[4]
383386

384387
@property
385388
def audio_signal_status(self):

docs/conf.py

+1-1
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 = ["micropython", "ustruct", "adafruit_bus_device", "adafruit_bus_device.i2c_device"]
21+
autodoc_mock_imports = ["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)