def button_pressed(self, channel):
# Debouncing
time.sleep(0.05)
if (GPIO.input(channel) == 0):
# Find out which button was pressed
for button in self.buttons:
if (channel == self.buttons[button]):
# Change screen
if (button == 'MODE_BUTTON'):
if (self.display != False):
self.display.change_screen()
# Toggle backlight
elif (button == 'PAUSE_BUTTON'):
if (self.display != False):
self.display.toggle_backlight()
# Send command to MPD client
elif (self.mpd != False):
self.mpd.commands(button.replace('_BUTTON', ''))
评论列表
文章目录