当前位置: 首页>>代码示例>>Python>>正文


Python Platform.pi_revision方法代码示例

本文整理汇总了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)
开发者ID:andysmithfal,项目名称:Adafruit_Python_GPIO,代码行数:13,代码来源:test_Platform.py

示例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.')
开发者ID:AntonisVafeas,项目名称:Adafruit_Python_GPIO,代码行数:20,代码来源:I2C.py

示例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.")
开发者ID:xtacocorex,项目名称:Adafruit_Python_GPIO,代码行数:25,代码来源:I2C.py

示例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)
开发者ID:kenpi2b,项目名称:RaspberryPi-WeatherPiArduino,代码行数:8,代码来源:test_Platform.py


注:本文中的Adafruit_GPIO.Platform.pi_revision方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。