Python RPi.GPIO 模块,RPI_REVISION 实例源码
我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用RPi.GPIO.RPI_REVISION。
def init():
global p, q, a, b
# Initialise the PWM device using the default address
#use physical pin numbering
GPIO.setmode(GPIO.BOARD)
#print GPIO.RPI_REVISION
#set up digital line detectors as inputs
GPIO.setup(lineRight, GPIO.IN) # Right line sensor
GPIO.setup(lineLeft, GPIO.IN) # Left line sensor
#Set up IR obstacle sensors as inputs
GPIO.setup(irFL, GPIO.IN) # Left obstacle sensor
GPIO.setup(irFR, GPIO.IN) # Right obstacle sensor
#use pwm on inputs so motors don't go too fast
GPIO.setup(L1, GPIO.OUT)
p = GPIO.PWM(L1, 20)
p.start(0)
GPIO.setup(L2, GPIO.OUT)
q = GPIO.PWM(L2, 20)
q.start(0)
GPIO.setup(R1, GPIO.OUT)
a = GPIO.PWM(R1, 20)
a.start(0)
GPIO.setup(R2, GPIO.OUT)
b = GPIO.PWM(R2, 20)
b.start(0)
startServos()
# cleanup(). Sets all motors off and sets GPIO to standard values
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]