From b302b3c6d0282aadf3fa13f1b5c0d365551b639c Mon Sep 17 00:00:00 2001 From: DJ Sundog Date: Sun, 2 Aug 2020 12:34:16 -0700 Subject: [PATCH] debug menu toggle --- SoundslabDisplay.py | 4 +++- SoundslabInput.py | 13 +++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/SoundslabDisplay.py b/SoundslabDisplay.py index baa8d44..c3ef969 100644 --- a/SoundslabDisplay.py +++ b/SoundslabDisplay.py @@ -34,6 +34,8 @@ class SoundslabDisplay: self.previous_voltage = 0.0 # track currently playing song's art path to eliminate unnecessary reloads of the same image file self.current_art_path = None + # start with menus hidden + self.show_menu = False def _displayOff(self): self.st7789.set_backlight(0) # turn off the backlight @@ -72,7 +74,7 @@ class SoundslabDisplay: # always start with a transparent menu overlay image im_menu_overlay = Image.new("RGBA", self.screen_size, (0, 0, 0, 0)) menu_overlay = ImageDraw.Draw(im_menu_overlay) - if self.showMenu and menu_data is not None: + if self.show_menu and menu_data is not None: # we have a menu to display # # menu_data is structured as a list of dicts describing the rows to be displayed: diff --git a/SoundslabInput.py b/SoundslabInput.py index b0ca33a..3f8d9a5 100644 --- a/SoundslabInput.py +++ b/SoundslabInput.py @@ -27,9 +27,6 @@ GPIO.setmode(GPIO.BCM) # with a "PULL UP", which weakly pulls the input signal to 3.3V. GPIO.setup(BUTTONS, GPIO.IN, pull_up_down=GPIO.PUD_UP) -# a temporary place to store menu state -show_menu = False - # some button handlers def NE(): # play/pause toggle @@ -60,12 +57,12 @@ def SW(): def NW(): # open menu - global show_menu + global display print("toggling menu") - if show_menu is True: - show_menu = False + if display.show_menu is True: + display.show_menu = False else: - show_menu = True + display.show_menu = True def SE(): # next track @@ -135,7 +132,7 @@ for pin in BUTTONS: GPIO.add_event_detect(pin, GPIO.FALLING, handle_button, bouncetime=100) while True: - if show_menu is True: + if display.show_menu is True: # test menu display.updateMenu( [