Skip to content

Commit 5084033

Browse files
committed
Use binho connection singleton
1 parent 9c68446 commit 5084033

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

adafruit_platformdetect/chip.py

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ class Chip:
2727
"""Attempt detection of current chip / CPU."""
2828
def __init__(self, detector):
2929
self.detector = detector
30-
try:
31-
os.environ.get('BLINKA_NOVA'):
32-
self._binho = None
33-
except KeyError: # no relevant environment var
34-
pass
3530

3631
@property
3732
def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return-statements
@@ -61,24 +56,12 @@ def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return-s
6156
raise RuntimeError('BLINKA_MCP2221 environment variable ' + \
6257
'set, but no MCP2221 device found')
6358
if os.environ.get('BLINKA_NOVA'):
64-
# Check if we already have a binho instance
65-
if self._binho is not None and self._binho == BINHO:
66-
return self._binho
67-
68-
# import the Binho libraries
69-
from binhoHostAdapter import binhoHostAdapter
70-
from binhoHostAdapter import binhoUtilities
71-
72-
utilities = binhoUtilities.binhoUtilities()
73-
devices = utilities.listAvailableDevices()
74-
75-
count = len(devices)
76-
77-
if count == 0:
78-
self._binho = None
79-
raise RuntimeError('BLINKA_BINHO environment variable' + \
80-
'set, but no Binho host adapter found.')
81-
self._binho = BINHO
59+
# Check for Nova connection
60+
from adafruit_blinka.microcontroller.nova import Connection
61+
binho = Connection.getInstance()
62+
if binho == None:
63+
raise RuntimeError('BLINKA_NOVA environment variable ' + \
64+
'set, but no NOVA device found')
8265
return BINHO
8366

8467
platform = sys.platform

0 commit comments

Comments
 (0)