def setup(**kwargs): gpiocontrol.gpio_setup() qsem = threading.Semaphore(1) autoconq = taskmanage.OperationQueue(1, qsem=qsem) senseconq = taskmanage.OperationQueue(1, qsem=qsem) #0. main mainMenu = menu.Menu("Main", 0) initmod = menu.ExecOption("Init Module", 1, mainMenu, function=modcon.initmodule) controlMenu = menu.SubMenu("Control", 2, mainMenu) monMenu = menu.SubMenu("Monitoring", 3, mainMenu) #1.control targetval = menu.ExecOption("Set target", 1, controlMenu, function=modcon.settarget) actuating = menu.ExecOption("Actuating", 2, controlMenu, function=modcon.actuatemod) #2. monitoring sensorstat = menu.ExecOption("Sensor", 1, monMenu, function=modcon.viewsensingdata) targetstat = menu.ExecOption("Target", 2, monMenu, function=modcon.viewtargetdata) return mainMenu
self.display() self.input_thread = th.Input() self.input_thread.start() self.oled.draw_text(a_right, title_y, "OK", "green", size=size) self.display() title_y += size + 2 # Menu self.in_menu = False self.in_volume = False self.freeze = 0 self.menu = [ menu.SubMenu("player", [ menu.Action("play", self.mpd_thread.play), menu.Action("stop", self.mpd_thread.stop_playing), menu.Action("next", self.mpd_thread.next), menu.Action("previous", self.mpd_thread.prev), menu.Action("sleep", self.mpd_thread.sleep, goback=True), menu.SubMenu("playlist", self.menu_playlist()), ]), menu.Screen("info", self.d_info), menu.Action("alarm 5h00", self.alarm_on, arg="04:45", goback=True), menu.Action("alarm 6h15", self.alarm_on, arg="06:15", goback=True), menu.Action("alarm 7h00", self.alarm_on, arg="07:00", goback=True), menu.Action("alarm off", self.alarm_off, goback=True), menu.Command("shutdown", "poweroff", goback=True), menu.MenuBack("Exit") ] self.menu_sub = [] self.menu_cursor = 0 self.menu_max_items = 5
def setup(**kwargs): gpiocontrol.gpio_setup() qsem = threading.Semaphore(1) autoconq = taskmanage.OperationQueue(1, qsem=qsem) senseconq = taskmanage.OperationQueue(1, qsem=qsem) modcon = modulecontrol.ModuleControl(1) mainMenu = menu.Menu("Main", 0) initmod = menu.ExecOption("Initialize Module", 1, mainMenu, function=modcon.initmodule) controlMenu = menu.SubMenu("Control", 2, mainMenu) monMenu = menu.SubMenu("Monitoring", 3, mainMenu) #1.control ''' setcontrol = menu.ExecOptionList("Module Control Mode", 1, controlMenu, funcdic=modcon.getmodulemode(), mode=True, trueopt='Auto', falseopt='Manual') refreshq = menu.ExecOption("Refresh Auto Queue", 2, controlMenu, function=modcon.initautoQ, opq=autoconq) mancontrol = menu.ExecOptionList("Control Manually", 3, controlMenu, funcdic=modcon.getmodulemode(), mode=False) ''' #================================================== funcdic1 = modcon.getmodulemode(mode=False) #True) setcontrol = menu.ExecOptionList("Module Control Mode", 1, controlMenu, funcdic=funcdic1, trueopt='Auto', falseopt='Manual') refreshq = menu.ExecOption("Refresh Auto Queue", 2, controlMenu, function=modcon.initautoQ, opq=autoconq) funcdic2 = modcon.getmodulemode(mode=True) #False mancontrol = menu.ExecOptionList("Control Manually", 3, controlMenu, funcdic=funcdic2) #================================================== targetval = menu.ExecOption("Set target value", 4, controlMenu, function=modcon.settarget) autocondic = {'run_async': True, 'infinite': True} autocontrol = menu.ToggleOption("control mode", 5, controlMenu, function=autoconq.start, function2=autoconq.stop, trueopt='Running', falseopt='Stopped', funcargs=autocondic) #2. monitoring sensorconfig = menu.ExecOption("Sensor Configuration", 1, monMenu, function=modcon.initfrequency) sensorstat = menu.ExecOption("Sensor Modules", 2, monMenu, function=modcon.viewsensingdata) actustat = menu.ExecOption("Actuator Modules", 3, monMenu, function=modcon.viewactingdata) return mainMenu
Option two will start a digit-collecting sub-menu. We'll tell you if you make an invalid selection here.''', options = [ menu.Option( option='0' ), menu.Option( option='#' ), menu.ExitOn( option='*' ), menu.SubMenu( option='1', menu = menu.Menu( prompt = '/home/mcfletch/starpydemo/soundfiles/menutest-secondlevel', #prompt = 'atlantic', textPrompt = '''A second-level menu in the menu test example Pressing Star will exit this menu at any time. Options zero and pound will exit the whole menu with those options selected. We won't tell you if you make an invalid selection here. ''', tellInvalid = False, # don't report incorrect selections options = [ menu.Option( option='0' ), menu.Option( option='#' ), menu.ExitOn( option='*' ), ], ), ), menu.SubMenu( option='2', menu = menu.CollectDigits( textPrompt = '''Digit collection example, Please enter three to 5 digits. ''',
import menu import tempfile from subprocess import call as os_call m = [ menu.MenuSetup( "set WIFI_EXEC='file:///lib/live/mount/findiso/install_wifi_driver.sh'" ) ] deb_hook = "hooks=$WIFI_EXEC" gentoo_ex = '' # gentoo_ex = 'aufs splash=silent,theme:default console=tty0' m.append(menu.DebianLiveISO(extra=deb_hook)) sm = menu.SubMenu() m.append(sm) sm.AddEntry( menu.DebianLiveISO('/debian-xfce.iso', name='Debian Xfce', extra=deb_hook)) sm.AddEntry(menu.CentOSISO(disk='/dev/sda1')) sm.AddEntry(menu.UbuntuLiveISO()) m.append(menu.GentooISO(extra=gentoo_ex)) st = '' for x in m: st += x.WriteMenu() + '\n' script_check = None # setting text mode here as I don't need binary with tempfile.NamedTemporaryFile(mode='w') as f: d = f.write(st) del d f.flush()