本文整理汇总了Python中RPi.GPIO.RPI_REVISION属性的典型用法代码示例。如果您正苦于以下问题:Python GPIO.RPI_REVISION属性的具体用法?Python GPIO.RPI_REVISION怎么用?Python GPIO.RPI_REVISION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类RPi.GPIO
的用法示例。
在下文中一共展示了GPIO.RPI_REVISION属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RPI_REVISION [as 别名]
def __init__(self, bus=None):
if bus is None:
try:
import RPi.GPIO as GPIO
# use the bus that matches your raspi version
rev = GPIO.RPI_REVISION
except:
rev = 3
if rev == 2 or rev == 3:
bus = 1 # for Pi 2+
else:
bus = 0
if not Bus.instance:
Bus.instance = smbus.SMBus(bus)
self.bus = bus
self.msg = i2c_msg
示例2: _gpio_board_to_bcm
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RPI_REVISION [as 别名]
def _gpio_board_to_bcm(self, pin):
if GPIO.RPI_REVISION == 1:
pin_to_gpio = self._pin_to_gpio_rev1
elif GPIO.RPI_REVISION == 2:
pin_to_gpio = self._pin_to_gpio_rev2
else:
pin_to_gpio = self._pin_to_gpio_rev3
return pin_to_gpio[pin]
示例3: _gpio_bcm_to_board
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RPI_REVISION [as 别名]
def _gpio_bcm_to_board(self, pin):
if GPIO.RPI_REVISION == 1:
pin_to_gpio = self._pin_to_gpio_rev1
elif GPIO.RPI_REVISION == 2:
pin_to_gpio = self._pin_to_gpio_rev2
else:
pin_to_gpio = self._pin_to_gpio_rev3
return pin_to_gpio.index(pin)
示例4: setup
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RPI_REVISION [as 别名]
def setup():
print "GPIO version: " + str(GPIO.VERSION)
print "Pi revision " + str(GPIO.RPI_REVISION)