-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu_buttons.py
35 lines (26 loc) · 1011 Bytes
/
menu_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
32
33
34
35
import RPi.GPIO as GPIO
import time
class MenuButtons:
def __init__(self):
self.MENU_PIN = 10
self.SELECT_PIN = 9
self.NEXT_PIN = 11
self.HIGH = 1
GPIO.setmode(GPIO.BCM)
GPIO.setup(self.MENU_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(self.SELECT_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(self.NEXT_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
def is_menu_pressed(self): # White button
return GPIO.input(self.MENU_PIN) == self.HIGH
def is_select_pressed(self): # Green button
return GPIO.input(self.SELECT_PIN) == self.HIGH
def is_next_pressed(self): # Yellow button
return GPIO.input(self.NEXT_PIN) == self.HIGH
#mb = MenuButtons()
#while True:
# if(mb.is_menu_pressed()):
# print("The Menu button was pressed")
# if(mb.is_select_pressed()):
# print("The Select button was pressed")
# if(mb.is_next_pressed()):
# print("The Next button was pressed")