Raspberry pi 如何为Google Assistant SDK连接Raspberry Pi上的按钮

Raspberry pi 如何为Google Assistant SDK连接Raspberry Pi上的按钮,raspberry-pi,google-assistant-sdk,Raspberry Pi,Google Assistant Sdk,GoogleAssistant SDK示例要求用户在与GoogleAssistant对话之前按enter键 while True: if wait_for_user_trigger: click.pause(info='Press Enter to send a new request...') continue_conversation = assistant.converse() # wait for user tri

GoogleAssistant SDK示例要求用户在与GoogleAssistant对话之前按enter键

 while True:
        if wait_for_user_trigger:
            click.pause(info='Press Enter to send a new request...')
        continue_conversation = assistant.converse()
        # wait for user trigger if there is no follow-up turn in
        # the conversation.
        wait_for_user_trigger = not continue_conversation

        # If we only want one conversation, break.
        if once and (not continue_conversation):
            break
我想知道是否有一种方法可以将一个按钮连接到一个RPI GPIO引脚并触发G.Assistant

 while True:
        if wait_for_user_trigger:
            click.pause(info='Press Enter to send a new request...')
        continue_conversation = assistant.converse()
        # wait for user trigger if there is no follow-up turn in
        # the conversation.
        wait_for_user_trigger = not continue_conversation

        # If we only want one conversation, break.
        if once and (not continue_conversation):
            break
我想这就是我连接GPIO库的地方

我应该如何着手实施它?我是Python和Raspberry Pi的新手。我有Java背景和自动化历史

这可能会有帮助:

...
import os.path
import RPi.GPIO as GPIO
...
CLOSE_MICROPHONE = embbeded_assistant_pb2.ConverseResult.CLOSE_MICROPHONE

GPIO.setmode(GPIO.BMC)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(23, GPIO.OUT)
...
while True:
    if wait_for_user_trigger:
        input_state = GPIO.input(18)
        if input_state == True:
            GPIO.output(23, False)
            continue
        else:
            GPIO.output(23, True)
            pass
        #click.pause(info='Press Enter to send a new request...')

...

参考资料:

谢谢劳尔。就是这样。也许关于Richards review,您可以总结一下步骤。干杯