-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathButtons.py
32 lines (21 loc) · 976 Bytes
/
Buttons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'''
The buttons on the front of the Hub are used to navigate the UI in
Selection mode, and can be used to interact with the user in the Run mode.
There are 4 buttons left, center, right, connect
'''
import hub
# can ask if it is currently pressed, was pressed, how many times it has been pressed, and callback
while True:
if hub.button.left.is_pressed():
hub.display.show(hub.Image.YES)
elif hub.button.right.is_pressed():
hub.display.show(hub.Image.NO)
# possible buttons are left, center, right, connect
hub.button.center.is_pressed() # checks current state of center button
hub.button.center.was_pressed() # checks if the center button has been pressed since last checked
hub.button.center.presses() # returns # presses since last call and rezeros
def smile():
hub.display.show(hub.Image.SMILE)
smile()
#This is not working for me for some reason
hub.button.center.on_change(smile()) # smiles when button pressed