aiy.board¶
APIs to control the button (and button LED) that’s attached to the Vision Bonnet and Voice Bonnet/HAT’s button connector. For example:
from aiy.board import Board, Led
def main():
print('LED is ON while button is pressed (Ctrl-C for exit).')
with Board() as board:
while True:
board.button.wait_for_press()
print('ON')
board.led.state = Led.ON
board.button.wait_for_release()
print('OFF')
board.led.state = Led.OFF
if __name__ == '__main__':
main()
-
class
aiy.board.
Board
(button_pin=23, led_pin=25)¶ Bases:
object
An interface for the connected AIY board.
Returns a
Button
representing the button connected to the button connector.
-
close
()¶
-
class
aiy.board.
Button
(channel, edge='falling', pull_up_down='up', debounce_time=0.08)¶ Bases:
object
An interface for the button connected to the AIY board’s button connector.
-
close
()¶ Internal method to clean up the object when done.
-
wait_for_press
(timeout=None)¶ Pauses the script until the button is pressed or the timeout is reached.
Parameters: timeout – Seconds to wait before proceeding. By default, this is None
, which means wait indefinitely.
-
wait_for_release
(timeout=None)¶ Pauses the script until the button is released or the timeout is reached.
Parameters: timeout – Seconds to wait before proceeding. By default, this is None
, which means wait indefinitely.
-
when_pressed
¶ A function to run when the button is pressed.
-
when_released
¶ A function to run when the button is released.
-
-
class
aiy.board.
Led
¶ Controls the LED in the button. Get an instance from
Board.led
.This class is primarily intended for compatibility with the Voice HAT (V1 Voice Kit), and it also works on the Voice/Vision Bonnet. However, if you’re using only the Voice/Vision Bonnet, then you should instead use
aiy.leds
, which provides more controls for the button’s unique RGB LED.-
brightness
(value)¶ Sets the button LED brightness
Parameters: value – The brightness, between 0.0 and 1.0
-
state
¶ Sets the button LED state. Can be one of the values below.
-
OFF
¶
-
ON
¶
-
BLINK
¶
-
BLINK_3
¶
-
BEACON
¶
-
BEACON_DARK
¶
-
DECAY
¶
-
PULSE_SLOW
¶
-
PULSE_QUICK
¶
-