@dot3k.joystick.on(dot3k.joystick.LEFT)
def handle_left(pin):
    menu.left()

@dot3k.joystick.on(dot3k.joystick.RIGHT)
def handle_right(pin):
    menu.right()

def exit():
	print "Bye ;)"
	lcd.clear()
	lcd.set_cursor_position(4,1)
	lcd.write("Bye Bye!")
	time.sleep(2)
	lcd.clear()
	backlight.rgb(0,0,0)
	sys.exit()

# move menu for modules default selection
menu.up()
menu.up()

while 1:
	try:	
	    menu.redraw()
            time.sleep(0.01)
	except KeyboardInterrupt:
	    print 
	    exit()

Exemplo n.º 2
0
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()