diff --git a/inventorhatmini/__init__.py b/inventorhatmini/__init__.py index dd776c3..46e7b86 100644 --- a/inventorhatmini/__init__.py +++ b/inventorhatmini/__init__.py @@ -99,6 +99,7 @@ def __init__(self, address=IOE_ADDRESS, motor_gear_ratio=50, init_motors=True, i """ Initialise inventor hat mini's hardware functions """ self.address = address + self.ioe = None gpiodevice.friendly_errors = True @@ -159,7 +160,8 @@ def reinit(self): self.ioe.set_mode(self.IOE_CURRENT_SENSES[1], ADC) def __del__(self): - self.ioe.reset() + if self.ioe is not None: + self.ioe.reset() def switch_pressed(self): return self._read_pin(self._pin_user_sw)