本文整理汇总了Python中Adafruit_GPIO.Platform.pi_revision方法的典型用法代码示例。如果您正苦于以下问题:Python Platform.pi_revision方法的具体用法?Python Platform.pi_revision怎么用?Python Platform.pi_revision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Adafruit_GPIO.Platform
的用法示例。
在下文中一共展示了Platform.pi_revision方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_revision_1
# 需要导入模块: from Adafruit_GPIO import Platform [as 别名]
# 或者: from Adafruit_GPIO.Platform import pi_revision [as 别名]
def test_revision_1(self):
with patch('__builtin__.open') as mock_open:
handle = mock_open.return_value.__enter__.return_value
handle.__iter__.return_value = iter(['Revision : 0002'])
rev = Platform.pi_revision()
self.assertEquals(rev, 1)
with patch('__builtin__.open') as mock_open:
handle = mock_open.return_value.__enter__.return_value
handle.__iter__.return_value = iter(['Revision : 0003'])
rev = Platform.pi_revision()
self.assertEquals(rev, 1)
示例2: get_default_bus
# 需要导入模块: from Adafruit_GPIO import Platform [as 别名]
# 或者: from Adafruit_GPIO.Platform import pi_revision [as 别名]
def get_default_bus():
"""Return the default bus number based on the device platform. For a
Raspberry Pi either bus 0 or 1 (based on the Pi revision) will be returned.
For a Beaglebone Black the first user accessible bus, 1, will be returned.
"""
plat = Platform.platform_detect()
if plat == Platform.RASPBERRY_PI:
if Platform.pi_revision() == 1:
# Revision 1 Pi uses I2C bus 0.
return 0
else:
# Revision 2 Pi uses I2C bus 1.
return 1
elif plat == Platform.BEAGLEBONE_BLACK:
# Beaglebone Black has multiple I2C buses, default to 1 (P9_19 and P9_20).
return 1
else:
raise RuntimeError('Could not determine default I2C bus for platform.')
示例3: get_default_bus
# 需要导入模块: from Adafruit_GPIO import Platform [as 别名]
# 或者: from Adafruit_GPIO.Platform import pi_revision [as 别名]
def get_default_bus():
"""Return the default bus number based on the device platform. For a
Raspberry Pi either bus 0 or 1 (based on the Pi revision) will be returned.
For a Beaglebone Black the first user accessible bus, 1, will be returned.
"""
plat = Platform.platform_detect()
if plat == Platform.RASPBERRY_PI:
if Platform.pi_revision() == 1:
# Revision 1 Pi uses I2C bus 0.
return 0
else:
# Revision 2 Pi uses I2C bus 1.
return 1
elif plat == Platform.BEAGLEBONE_BLACK:
# Beaglebone Black has multiple I2C buses, default to 1 (P9_19 and P9_20).
return 1
elif plat == Platform.CHIP:
# CHIP has 2 user accessible I2C busses, default to 2 (U1425 and U14_26)
# The 4.4 Kernel CHIPs remove i2c-1 for the ability to set with a dtb overlay
# and therefore isn't accessible without one
return 2
else:
raise RuntimeError("Could not determine default I2C bus for platform.")
示例4: test_revision_2
# 需要导入模块: from Adafruit_GPIO import Platform [as 别名]
# 或者: from Adafruit_GPIO.Platform import pi_revision [as 别名]
def test_revision_2(self):
with patch("__builtin__.open") as mock_open:
handle = mock_open.return_value.__enter__.return_value
handle.__iter__.return_value = iter(["Revision : 000e"])
rev = Platform.pi_revision()
self.assertEquals(rev, 2)