【发布时间】:2019-12-03 02:03:58
【问题描述】:
我尝试在没有 GPIO 的机器上开发一些代码。作为 GPIO 库,我选择了一个 gpiozero 来编写我的代码,而无需访问树莓派的 gpio。 我的问题,我无法在代码中使用 .when_pressed 事件。 我模拟了按钮的状态变化,但是没有调用函数。
Device.pin_factory = MockFactory()
def interrupt_Event(channel):
print("%s puted in the queue", channel)
InputPin.Device.pin_factory.pin(channel)
InputPin.when_pressed = interrupt_Event
def main():
try:
while True:
time.sleep(1)
InputPins[channel].pull=drive_high()
time.sleep(0.1)
print("State CHANNEL %s" % channel)
print(InputPins[channel].state)
InputPins[channel].drive_low()
到现在我都不知道出了什么问题。
【问题讨论】:
标签: python raspberry-pi gpio gpiozero