from dot3k.menu import Menu import dot3k.backlight import dot3k.lcd import time """ Let there be light! """ dot3k.backlight.rgb(255, 255, 255) """ The menu structure is defined as a nested dictionary, to "install" your plugin, it should be added like so: You will also need to pass Menu a reference to the LCD you wish to draw to. """ menu = Menu(structure={'Hello World': HelloWorld()}, lcd=dot3k.lcd) """ We're not going to handle any input, so go right ahead and virtually press "right" to enter your plugin: """ menu.right() """ You can decide when the menu is redrawn, but you'll usually want to do this: """ while 1: menu.redraw() time.sleep(0.01)
""" The menu structure is defined as a nested dictionary, to "install" your plugin, it should be added like so: You will also need to pass Menu a reference to the LCD you wish to draw to. """ menu = Menu( structure={ 'Hello World': HelloWorld() }, lcd=dot3k.lcd ) """ We're not going to handle any input, so go right ahead and virtually press "right" to enter your plugin: """ menu.right() """ You can decide when the menu is redrawn, but you'll usually want to do this: """ while 1: menu.redraw() time.sleep(0.01)
class MainMenu(): controller = None def __init__(self, repline, controller): self.repline = repline self.controller = controller self.menu = Menu( structure={ 'Record': self.record, 'Settings': { 'Recording': { 'Normalisation': Normalisation(repline) }, 'Track detection': { SilenceThreshold.title: SilenceThreshold(repline), MinSilenceLength.title: MinSilenceLength(repline) }, 'Encoding': { OutputFormat.title: OutputFormat(repline), get_quality_setting(repline).title: get_quality_setting(repline) }, # 'Saving': { # }, 'Hardware': { SetInputDevice.title: SetInputDevice(repline), SetOutputDevice.title: SetOutputDevice(repline), } } }, lcd=lcd) nav.bind_defaults(self.menu) def on_active(self): pass def redraw(self): self.menu.redraw() def record(self): self.controller.open_record_ui() def handle_up(self, ch, evt): self.menu.up() def handle_down(self, ch, evt): self.menu.down() def handle_left(self, ch, evt): self.menu.left() def handle_right(self, ch, evt): self.menu.right() def handle_select(self, ch, evt): self.menu.select() def handle_cancel(self, ch, evt): self.menu.cancel()
mgtext = MGText() menu = Menu( structure = { 'MGText Test': mgtext, }, lcd = lcd, input_handler = mgtext) try: touch.bind_defaults(menu) # Trap the Cancel button for our own purposes (to use as a Delete key). @touch.on(touch.CANCEL) def handle_cancel(ch, evt): mgtext.cancel() backlight.rgb(192, 124, 234) menu.right() # Go straight to text-editing while 1: menu.redraw() time.sleep(0.05) except (KeyboardInterrupt, SystemExit): reset() except: reset() raise
def main(): """ Set up a menu with the Calendar and go straight into it. """ menu = Menu( structure={ 'calendar': GoogleCalendar() }, lcd=lcd ) # Register a function to turn the lights off on script exit. atexit.register(cleanup) # Go straight into out menu plugin, making it an app in this case menu.right() # setup default menu handlers touch.bind_defaults(menu) while 1: menu.redraw() time.sleep(0.02)