first pass at handling display lock/unlock
This commit is contained in:
parent
3e46566f4d
commit
be449fc957
|
@ -20,6 +20,7 @@ class SoundslabDisplay:
|
||||||
backlight=13,
|
backlight=13,
|
||||||
spi_speed_hz=self.spi_speed_mhz * 1000 * 1000
|
spi_speed_hz=self.spi_speed_mhz * 1000 * 1000
|
||||||
)
|
)
|
||||||
|
self.displayOn = True
|
||||||
self.current_background = Image.new("RGBA", self.screen_size, (0, 0, 255, 255))
|
self.current_background = Image.new("RGBA", self.screen_size, (0, 0, 255, 255))
|
||||||
self.current_overlay = Image.new("RGBA", self.screen_size, (0, 0, 0, 0))
|
self.current_overlay = Image.new("RGBA", self.screen_size, (0, 0, 0, 0))
|
||||||
self.current_menu = Image.new("RGBA", self.screen_size, (0, 0, 0, 0))
|
self.current_menu = Image.new("RGBA", self.screen_size, (0, 0, 0, 0))
|
||||||
|
@ -34,6 +35,22 @@ class SoundslabDisplay:
|
||||||
# track currently playing song's art path to eliminate unnecessary reloads of the same image file
|
# track currently playing song's art path to eliminate unnecessary reloads of the same image file
|
||||||
self.current_art_path = None
|
self.current_art_path = None
|
||||||
|
|
||||||
|
def _displayOff(self):
|
||||||
|
self.st7789.set_backlight(0) # turn off the backlight
|
||||||
|
self.st7789.command(0x28) # turn off the display itself
|
||||||
|
self.displayOn = False
|
||||||
|
|
||||||
|
def _displayOn(self):
|
||||||
|
self.st7789.command(0x29) # turn on the display itself
|
||||||
|
self.st7789.set_backlight(1) # turn on the backlight
|
||||||
|
self.displayOn = True
|
||||||
|
|
||||||
|
def toggleDisplayOnOff(self):
|
||||||
|
if self.displayOn:
|
||||||
|
self._displayOff()
|
||||||
|
else:
|
||||||
|
self._displayOn()
|
||||||
|
|
||||||
def getBatteryState(self):
|
def getBatteryState(self):
|
||||||
bus = smbus.SMBus(1)
|
bus = smbus.SMBus(1)
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@ from math import floor
|
||||||
player_client = musicpd.MPDClient()
|
player_client = musicpd.MPDClient()
|
||||||
player_client.connect()
|
player_client.connect()
|
||||||
|
|
||||||
|
# initialize connection to display
|
||||||
|
display = SoundslabDisplay(player_client)
|
||||||
|
|
||||||
# The buttons on Pirate Audio are connected to pins 5, 6, 16 and 24
|
# The buttons on Pirate Audio are connected to pins 5, 6, 16 and 24
|
||||||
# Boards prior to 23 January 2020 used 5, 6, 16 and 20
|
# Boards prior to 23 January 2020 used 5, 6, 16 and 20
|
||||||
# try changing 24 to 20 if your Y button doesn't work.
|
# try changing 24 to 20 if your Y button doesn't work.
|
||||||
|
@ -94,7 +97,7 @@ def RT():
|
||||||
|
|
||||||
def SELECT():
|
def SELECT():
|
||||||
# display lock/unlock
|
# display lock/unlock
|
||||||
pass
|
display.toggleDisplayOnOff()
|
||||||
|
|
||||||
# This is a dictionary of the combination of pins and labels
|
# This is a dictionary of the combination of pins and labels
|
||||||
LABELLED_BUTTONS = {
|
LABELLED_BUTTONS = {
|
||||||
|
@ -123,9 +126,6 @@ def handle_button(pin):
|
||||||
for pin in BUTTONS:
|
for pin in BUTTONS:
|
||||||
GPIO.add_event_detect(pin, GPIO.FALLING, handle_button, bouncetime=100)
|
GPIO.add_event_detect(pin, GPIO.FALLING, handle_button, bouncetime=100)
|
||||||
|
|
||||||
# initialize the display
|
|
||||||
display = SoundslabDisplay(player_client)
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# test album art
|
# test album art
|
||||||
display.updateAlbumArt()
|
display.updateAlbumArt()
|
||||||
|
|
Loading…
Reference in New Issue