Skip to content

Commit f167548

Browse files
authored
Merge pull request #14 from faludi/xbee-implementation
Suggested changes to accommodate XBee Cellular platform
2 parents 333da66 + 4d2412a commit f167548

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

qwiic_i2c/circuitpy_i2c.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ def __init__(self):
110110
def isPlatform(cls):
111111

112112
# circuit py is mostly - for our purposes - on the samd21 or samd51 based boards
113-
return os.uname().sysname in ('samd21', 'samd51')
113+
try:
114+
return os.uname().sysname in ('samd21', 'samd51')
115+
except AttributeError:
116+
return False
114117

115118

116119
#-------------------------------------------------------------------------

qwiic_i2c/i2c_driver.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@
5959
6060
"""
6161

62-
from __future__ import print_function
63-
64-
6562
#-----------------------------------------------------------------------------
6663
# Platform
6764
#

qwiic_i2c/linux_i2c.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
# SOFTWARE.
3737
#==================================================================================
3838

39-
from __future__ import print_function
40-
4139
from .i2c_driver import I2CDriver
4240

4341
import sys

qwiic_i2c/micropython_i2c.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@
4343
def _connectToI2CBus(freq=400000):
4444
try:
4545
from machine import I2C, Pin
46-
# Todo: Don't hard code I2C pin and port!
47-
return I2C(id=1, scl=Pin(19), sda=Pin(18), freq=freq)
46+
if sys.platform == 'rp2':
47+
# Todo: Don't hard code I2C pin and port!
48+
return I2C(id=1, scl=Pin(19), sda=Pin(18), freq=freq)
49+
elif 'xbee' in sys.platform:
50+
return I2C(id=1, freq=freq)
51+
else:
52+
raise Exception("Unknown MicroPython platform: " + sys.platform)
4853
except Exception as e:
4954
print(str(e))
5055
print('error: failed to connect to i2c bus')
@@ -62,7 +67,7 @@ def __init__(self):
6267
@classmethod
6368
def isPlatform(cls):
6469
try:
65-
return sys.implementation.name == 'micropython'
70+
return 'micropython' in sys.implementation
6671
except:
6772
return False
6873

0 commit comments

Comments
 (0)