Skip to content

Commit 8c68e71

Browse files
committed
Fix the destructor ioe device assumption
1 parent 653d248 commit 8c68e71

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

inventorhatmini/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def __init__(self, address=IOE_ADDRESS, motor_gear_ratio=50, init_motors=True, i
9999
""" Initialise inventor hat mini's hardware functions
100100
"""
101101
self.address = address
102+
self.ioe = None
102103

103104
gpiodevice.friendly_errors = True
104105

@@ -159,7 +160,8 @@ def reinit(self):
159160
self.ioe.set_mode(self.IOE_CURRENT_SENSES[1], ADC)
160161

161162
def __del__(self):
162-
self.ioe.reset()
163+
if self.ioe is not None:
164+
self.ioe.reset()
163165

164166
def switch_pressed(self):
165167
return self._read_pin(self._pin_user_sw)

0 commit comments

Comments
 (0)