Skip to content

Fix the destructor ioe device assumption #15

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion inventorhatmini/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
Loading