Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    def __init__(self):

        self.structure = {}

        with open('local.json') as f:
            self.cards = json.load(f)
            self.config = self.cards['CONFIG']

        self.cards = self.formatCards(self.cards)
        for subject in self.cards:
            for topic in self.cards[subject]:
                self.cards[subject][topic] = self.CardSession(
                    self, self.cards[subject][topic], subject + "." + topic)

        print(self.config['favorites'])
        self.structure.update({
            'Continue': {},
            'Favorites':
            self.CardSession(self, self.config['favorites'], "favorites"),
            'View All Cards':
            self.cards,
            #'Get More Cards' : self.getCards(),
            #'Save and Exit' : saveAndExit(),
            'Settings': {
                # 'Check Server': line.checkServer()
            }
        })

        self.menu = Menu(structure=self.structure, lcd=lcd, idle_timeout=30)

        self.updateLastSession(self.config['lastSession'])

        touch.bind_defaults(self.menu)
Exemplo n.º 3
0
"bitstamp API url for updated price information"
"added bittrex prices for pairs"
#URL = 'https://www.bitstamp.net/api/ticker/'
URL = "https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-pay"
string = ""
last = 0


class Ticker(MenuOption):
    def redraw(self, menu):
        menu.write_option(row=1, text=string, scroll=True)
        menu.clear_row(2)


menu = Menu(structure={'Bitcoin Ticker': Ticker()}, lcd=lcd)

menu.right()
"""
updates the price string from bitstamp every 5 seconds
sets the HAT LED graph when price changes.
LED 0 is on if up.  LED 5 is on if down
"""


def update():
    while True:
        global string, last
        r = requests.get(URL, verify=False)
        #uncomment to use bitstamp api
        #priceFloat = float(json.loads(r.text)['Last'])
Exemplo n.º 4
0
from plugins.graph import IPAddress, GraphTemp, GraphCPU, GraphNetSpeed
from plugins.wlan import Wlan

print("""
This example uses automation to advance through each menu item.
You should see each menu item appear in turn. However use-input will not be accepted.

Press CTRL+C to exit.
""")

sys.path.append('../../')

menu = Menu(
    {
        'Clock': Clock(),
        'IP': IPAddress(),
        'CPU': GraphCPU(),
        'Temp': GraphTemp()
    }, lcd, None, 30)


def millis():
    return int(round(time.time() * 1000.0))


def advance():
    global last
    if millis() > last + (delay * 1000.0):
        menu.cancel()
        menu.down()
        menu.right()
Exemplo n.º 5
0
#!/usr/bin/env python

import dot3k.joystick as joystick
import dot3k.lcd as lcd
import dot3k.backlight as backlight
from dot3k.menu import Menu
from plugins.utils import Backlight, Contrast
from plugins.debris import Debris
import time

menu = Menu(
    {
        'Debris Game': Debris(),
        'Settings': {
            'Display': {
                'Contrast': Contrast(lcd),
                'Backlight': Backlight(backlight)
            }
        }
    }, lcd)

REPEAT_DELAY = 0.5


@joystick.on(joystick.UP)
def handle_up(pin):
    menu.up()
    joystick.repeat(joystick.UP, menu.up, REPEAT_DELAY, 0.9)


@joystick.on(joystick.DOWN)
Exemplo n.º 6
0
Instances of classes derived from MenuOption can
be used as menu items to show information or change settings.

See GraphTemp, GraphCPU, Contrast and Backlight for examples.
"""
my_invader = SpaceInvader()

menu = Menu(
    {
        'Space Invader': my_invader,
        'Clock': Clock(),
        'Status': {
            'IP': IPAddress(),
            'CPU': GraphCPU(),
            'Temp': GraphTemp()
        },
        'Settings': {
            'Volume': Volume(),
            'Display': {
                'Contrast': Contrast(lcd),
                'Backlight': Backlight(backlight)
            }
        }
    }, lcd, my_invader, 30)
"""
You can use anything to control dot3k.menu,
but you'll probably want to use dot3k.joystick
"""
REPEAT_DELAY = 0.5

Exemplo n.º 7
0
from plugins.deluge import Deluge
from plugins import Volume, Backlight, Contrast, GraphTemp, GraphCPU, Clock, Radio, Stocks
import time

my_clock = Clock()

menu = Menu(structure={
    'Deluge': Deluge(),
    'Clock': my_clock,
    'Stocks': Stocks(),
    'Radio': Radio(),
    'Status': {
        'CPU': GraphCPU(),
        'Temp': GraphTemp()
    },
    'Settings': {
        'Volume': Volume(),
        'Contrast': Contrast(lcd),
        'Backlight': Backlight(backlight)
    }
},
            lcd=lcd,
            idle_handler=my_clock,
            idle_time=3,
            input_handler=Text())
"""
usbkeyboard provides the same methods as dot3k.joystick
so it's a drop-in replacement!
"""

Exemplo n.º 8
0
Using a set of nested dictionaries you can describe
the menu you want to display on dot3k.

A nested dictionary describes a submenu.
An instance of a plugin class ( derived from MenuOption ) can be used for things like settings, radio, etc
A function name will call that function.
"""
menu = Menu(
    {
        'Clock': clock,
        'Radio Stream': Radio(),
        'Volume': Volume(backlight),
        'Status': {
            'CPU': GraphCPU(),
            'Temp': GraphTemp()
        },
        'Settings': {
            'Contrast': Contrast(lcd),
            'Backlight': Backlight(backlight)
        }
    },
    lcd,  # Draw to dot3k.lcd
    clock,  # Idle with the clock plugin,
    10  # Idle after 10 seconds
)
"""
You can use anything to control dot3k.menu,
but you'll probably want to use dot3k.touch
"""


@nav.on(nav.UP)
Exemplo n.º 9
0
settings = Camerasettings()

menu = Menu(structure={
    'Take Picture': takeshot(settings),
    'Current Time': Clock(backlight),
    'Camera status': {
        'IP': IPAddress()
    },
    'Camera settings': {
        'ISO': ISO(settings),
        'Orientation': {
            'Horizontal Flip': Hflip(settings),
            'Vertical Flip': Vflip(settings)
        }
    },
    'Settings': {
        'WiFi Setup': Wlan(),
        'Display': {
            'Contrast': Contrast(lcd),
            'Backlight': Backlight(backlight)
        }
    }
},
            lcd=lcd,
            idle_handler=my_invader,
            idle_timeout=30,
            input_handler=Text())
"""
You can use anything to control dot3k.menu,
but you'll probably want to use dot3k.captouch
Exemplo n.º 10
0
lights_control = webiface.lights_control
lights_menu = LightsMenu(lights_control)
#Unordered menu
menu = Menu(structure={
    'Power Options': {
        'Reboot': GraphSysReboot(),
        'Shutdown': GraphSysShutdown(),
    },
    'Aquarium': {
        'Lighting': {
            'Control': lights_menu,
            'Astral Data': AstralMenu.AstralInfo(),
        }
    },
    'Clock': Clock(backlight),
    'Status': {
        'IP': IPAddress(),
        'CPU': GraphCPU(backlight),
        'Temp': GraphTemp()
    },
    'Settings': {
        'Display': {
            'Contrast': Contrast(lcd),
            'Backlight': Backlight(backlight)
        }
    }
},
            lcd=lcd,
            input_handler=Text())

tm = TimeoutManager()
nav.bind_defaults(menu)
Exemplo n.º 11
0
#		self.slowvar = run_cmd("") # runs once per menu change, for slowly updating info
#		
#	def redraw(self,menu):
#	
#		self.fastvar = run_cmd("") # updated every screen refresh, for rapidly changing data
#	
#		lcd_colour(0)	# displays warning colour background, set this to a range 0..100, 0 = green, 100 = red
#		menu.write_row(0,'-= AFP =-')
#		menu.write_row(1,'slow: %s' % self.slowvar)
#		menu.write_row(2,'fast: %s' % self.fastvar)

menu = Menu({
		'1': cpu_info(),
		'2': memory_info(),
		'3': disk_info(),
		'4': network_info('wlan0'),
		'5': network_speed('wlan0'),
		'6': network_info('eth0'),
		'7': network_speed('eth0'),
		},
	lcd, None, 30)

menu_display_time = 4	# in seconds
update_frequency = 5	# hz of screen update
last_cycled = 0			# force immediate update of screen menu

#try:
while True:
	if millis() > last_cycled + (menu_display_time * 1000.0):
		menu.cancel()
		menu.down()
		menu.right()
Exemplo n.º 12
0
		display_show("", "", "", False)

backlight_idle = BacklightIdleTimeout(backlight)

# Initialize display-o-tron
menu = Menu(
	{
		'Display': {
			'Files': MenuActions("display_Files"),
			'Current Rotations': MenuActions("display_CurrentRotations"),
			'Current Distance': MenuActions("display_CurrentDistance"),
			'Total Distance': MenuActions("display_TotalDistance"),
			'Total Rotations': MenuActions("display_TotalRotations"),
			'Average Speed': MenuActions("display_AverageSpeed"),
			'Live Files': MenuActions("display_LiveFiles"),
			'Ready Files': MenuActions("display_ReadyFiles"),
			'Processed Files': MenuActions("display_ProcessedFiles")
		},
		'Shutdown': MenuActions("action_Shutdown"),
		'Restart': MenuActions("action_Restart"),
		'Reset Stats': MenuActions("action_ResetStats")
	},
	lcd,  # Draw to dot3k.lcd
	idle_handler = backlight_idle,
	idle_time = 10
)

backlight_idle.setup(menu.config)

def wake_screen():
	menu.redraw()
Exemplo n.º 13
0
__author__ = "Raphael \"rGunti\" Guntersweiler"
__copyright__ = "Copyright 2017 rGunti"
__credits__ = []

__license__ = "MIT"
__version__ = "0.1"
__maintainer__ = "Raphael \"rGunti\" Guntersweiler"
__email__ = "*****@*****.**"
__status__ = "Development"
"""
:param String s
"""

if __name__ == '__main__':  # code to execute if called from command-line
    menu = Menu(lcd=lcd)

    menu.add_item('Player', MPDPlayer())
    if not DONT_USE_WIFI:
        menu.add_item('WiFi', WiFiApp())
    menu.select()

    if USE_DOTHAT:
        nav.enable_repeat(True)
        nav.bind_defaults(menu)
    else:

        @nav.on(nav.UP)
        def handle_up(pin):
            menu.up()
Exemplo n.º 14
0
        MenuOption.__init__(self)

class State(MenuOption):
    def __init__(self):
        MenuOption.__init__(self)

class Copy(MenuOption):
    def __init__(self):
        MenuOption.__init__(self)

MyIdle = Idle()
MyState = State()
MyCopy = Copy()

# Menu argument: structure, lcd, idle_handler = None, idle_time = 60
menu = Menu(None,lcd,MyIdle,5) #30s initialy

menu.add_item('Etat',MyState)
menu.add_item('Copie',MyCopy)
menu.add_item('Options/Display/Contrast', Contrast(lcd))
menu.add_item('Options/Display/Backlight', Backlight(backlight))

# Menu Command

repeat_delay = 0.5

@nav.on(nav.UP)
def handle_up(pin):
    menu.up()
    nav.repeat(nav.UP, menu.up, repeat_delay, 0.9)
Exemplo n.º 15
0
#idle_handler = IdleDisplay(backlight)

# nested dicts define menus/submenus to display
# instances of classes derived from MenuOption used as menu items
menu = Menu(config_file='/home/dan/displayotron/pi-display/dot3k.cfg',
            structure={
                'Power': {
                    'Restart': lambda: system_power('restart'),
                    'Shutdown': lambda: system_power('shutdown'),
                    'Display Off': IdleDisplay(backlight)
                },
                'Network': NetworkStatus(),
                'Updates': PacmanStats(),
                'Clock': SimpleClock(),
                'Settings': {
                    'Brightness': Brightness(backlight),
                    'Backlight': Backlight(backlight),
                    'Contrast': Contrast(lcd)
                },
                'Disk': DiskUsage(),
                'Status': SystemStatus(),
            },
            lcd=lcd,
            idle_handler=IdleDisplay(backlight),
            idle_time=60)

# use touch module to control menu
touch.bind_defaults(menu)

# set initial backlight brightness
Exemplo n.º 16
0
    def redraw(self, menu):
        now = self.millis()

        x = int((self.start - now) / 200 % 16)
        menu.lcd.create_char(0, self.invader[int((self.start - now) / 400 % 2)])

        menu.write_row(0, 'Space Invader!')
        menu.write_row(1, (' ' * x) + chr(0))
        menu.clear_row(2)


my_invader = SpaceInvader()

menu = Menu(
    None,
    lcd,
    my_invader,
    5)

"""
If you want menu items to appear in a defined order, you must
add them one at a time using 'add_item'. This method accepts
a plugin instance, plus the path where you want it to appear.

Instances of classes derived from MenuOption can
be used as menu items to show information or change settings.

See GraphTemp, GraphCPU, Contrast and Backlight for examples.
"""

menu.add_item('Space Invader', my_invader)
See GraphTemp, GraphCPU, Contrast and Backlight for examples.
"""

backlight_idle = BacklightIdleTimeout(backlight)

menu = Menu(structure={
    'WiFi': Wlan(),
    'Clock': Clock(backlight),
    'Status': {
        'IP': IPAddress(),
        'CPU': GraphCPU(backlight),
        'Temp': GraphTemp()
    },
    'Settings': {
        'Display': {
            'Contrast': Contrast(lcd),
            'Backlight': Backlight(backlight)
        }
    }
},
            lcd=lcd,
            idle_handler=backlight_idle,
            idle_time=5,
            input_handler=Text())

# Pass the configuration into the idle handler,
# since the menu class does not do this!
backlight_idle.setup(menu.config)
"""
You can use anything to control dot3k.menu,
Exemplo n.º 18
0
menu = Menu(
    structure={
        #'WiFi': Wlan(),
        'Clock': Clock(),
        'Status': {
            'IP': IPAddress(),
            'CPU Load': GraphCPU(),
            'CPU Load & Temp': cpu_info(),
            'CPU & GPU Temp': GraphTemp(),
            'NetSpeed': GraphNetSpeed(),
            'NetTrans': GraphNetTrans(),
            'Disk Usage': disk_info(),
            'RAM': memory_info()
        },
        'Display': {
            'Backlight Off': lightsoff,
            'Backlight On': lightson,
            'Contrast': Contrast(lcd),
            'Colour': Backlight(backlight),
            'Cycle RGB': cyclelights
        },
        'Power': {
            'Reboot': GraphSysReboot(),
            'Shutdown': GraphSysShutdown()
        },
        'Cam stream': {
            'Start Stream': camon,
            'Stop Stream': camoff
        }
    },
    lcd=lcd,
    idle_handler=lightsoff,
    idle_timeout=1,
    input_handler=Text())
Exemplo n.º 19
0
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)
Exemplo n.º 20
0
from plugins.text import Text
from plugins.utils import Contrast, Backlight

picecold = PiceCold("picecold.ini")

menu = Menu(
    structure={
        'System': {
            'Boot Options': {
                'Shutdown': GraphSysShutdown(),
                'Reboot': GraphSysReboot()
            },
            'Settings': {
                'Display': {
                    'Contrast': Contrast(picecold.lcd),
                    'Backlight': Backlight(picecold.backlight)
                }
            }
        },
        'Status': {
            'IP': IPAddress(),
            'CPU': GraphCPU(picecold.backlight),
            'Temp': GraphTemp()
        }
    },
    lcd=picecold.lcd,
    input_handler=Text())

picecold.add_to_menu(menu)

# nav.enable_repeat(True)