Skip to content

changed conditional import for struct and ustruct #2

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 2 commits into from
Oct 3, 2017
Merged
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
8 changes: 5 additions & 3 deletions adafruit_max31855.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
amplifier module.

"""

import ustruct
try:
import struct
except ImportError:
import ustruct as struct

from adafruit_bus_device.spi_device import SPIDevice

Expand All @@ -54,7 +56,7 @@ def _read(self, internal=False):
raise RuntimeError("short circuit to power")
if self.data[1] & 0x01:
raise RuntimeError("faulty reading")
temp, refer = ustruct.unpack('>hh', self.data)
temp, refer = struct.unpack('>hh', self.data)
refer >>= 4
temp >>= 2
if internal:
Expand Down