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
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.º 4
0
from dot3k.menu import Menu

# Use "captouch" for dot4k
import dothat.touch as touch

# Use "hatbacklight" for dot4k
import dothat.backlight as backlight

# Import some plugins
from plugins.utils import Backlight, Contrast
from plugins.debris import Debris

import signal

# Build your menu!
menu = Menu(
    {
        "Debris Game": Debris(backlight),
        "Settings": {"Display": {"Contrast": Contrast(lcd), "Backlight": Backlight(backlight)}},
    },
    lcd,
)

# Hook captouch into menu with default settings
touch.bind_defaults(menu)

# Start the menu redraw loop
menu.run()

signal.pause()
Exemplo n.º 5
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)
Exemplo n.º 6
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.º 7
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.º 8
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.º 9
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.º 10
0
		else:
			dotc += 1
		
		lcd.set_cursor_position(6,2)
		for i in range(dotc / 10):
			lcd.write(".")

	lcd.clear()
def shutdown_animation():
	lcd.set_cursor_position(3,1)
	lcd.write("Bye (^_^)/")
	for x in reversed(range(127)):
		backlight.rgb(x, x * 2, x)
	lcd.clear()

menu = Menu({}, lcd, 30)
Menu.add_item(menu, 'Music Player', MusicPlayer())
Menu.add_item(menu, 'Clock', Clock())

# System
# System/Networking
Menu.add_item(menu, 'Networking/System/Show IPs', IPViewer())
Menu.add_item(menu, 'Networking/System/Scan WiFi', WiFiScan())
Menu.add_item(menu, 'Networking/System/WiFi Hotspot', WiFiHotspot())

# System/CPU
Menu.add_item(menu, 'CPU/System/Usage', GraphCPU())
Menu.add_item(menu, 'CPU/System/Temprature', GraphTemp())

# System/Shutdown
Menu.add_item(menu, 'Shutdown/System/Reboot', Reboot())
Exemplo n.º 11
0
class App:
    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)

    class CardSession(MenuOption):
        def __init__(self, app, cards, name, cont=False):
            self.cards = cards
            self.name = name
            self.cont = cont
            self.app = app

            self.currentIndex = 0
            self.indices = [i for i in cards]

            self.back = False
            self.lastUpdate = 0
            self.running = False

            MenuOption.__init__(self)

        def begin(self):
            self.running = False
            self.reset()

            if not self.cont:
                self.app.setLastSession(self.name)

        def reset(self):

            self.running = True
            lcd.clear()

        def right(self):
            if not self.running:
                return True
            self.reset()
            self.currentIndex += 1
            self.back = False

            if self.currentIndex == len(self.indices):
                self.currentIndex = 0
            return True

        def left(self):
            if not self.running:
                return False
            self.reset()
            self.currentIndex -= 1
            self.back = False

            if self.currentIndex == -1:
                self.currentIndex = len(self.indices) - 1
            return True

        def up(self):
            self.app.favoriteCard(self.indices[self.currentIndex],
                                  self.cards[self.indices[self.currentIndex]])

            return True

        def down(self):
            self.app.unfavoriteCard(
                self.indices[self.currentIndex],
                self.cards[self.indices[self.currentIndex]])

            return True

        def select(self):
            self.reset()
            self.back = not self.back

        def redraw(self, menu):

            if self.millis() - self.lastUpdate <= 250:
                return

            if not self.running:
                return False

            self.lastUpdate = self.millis()

            lcd.set_cursor_position(0, 1)
            if not self.back:
                lcd.write(self.indices[self.currentIndex])
            else:
                lcd.write(self.cards[self.indices[self.currentIndex]])

    def formatCards(self, toLoad):
        cards = {}
        for pack in toLoad:
            if pack.split(".")[0] != "CONFIG":
                packContents = toLoad[pack]
                pack = pack.split(".")
                subject = pack[0]
                topic = pack[1]

                try:
                    cards[subject]
                except KeyError:
                    cards[subject] = {}

                cards[subject][topic] = packContents

        return cards

    def setLastSession(self, name):
        with open('local.json', "r+") as f:
            data = json.load(f)
            data['CONFIG']['lastSession'] = name
            self.config = data['CONFIG']
            f.seek(0)
            json.dump(data, f)
            f.truncate()

        self.updateLastSession(name)

    def updateLastSession(self, name):
        print(name)
        if name == "favorites":
            self.menu.menu_options['Continue'] = self.CardSession(
                self, self.config["favorites"], name, True)
            print("wut")
            print(self.menu.menu_options['Continue'].cards)
        else:
            subject = name.split('.')[0]
            topic = name.split('.')[1]
            self.menu.menu_options['Continue'] = self.cards[subject][topic]

    def favoriteCard(self, cardFront, cardBack):
        if cardFront not in self.config['favorites']:
            with open('local.json', "r+") as f:
                data = json.load(f)
                data['CONFIG']['favorites'].update({cardFront: cardBack})
                self.config = data['CONFIG']
                f.seek(0)
                json.dump(data, f)
                f.truncate()

    def unfavoriteCard(self, cardFront, cardBack):
        if cardFront in self.config['favorites']:
            with open('local.json', "r+") as f:
                data = json.load(f)
                data['CONFIG']['favorites'].pop(cardFront)
                self.config = data['CONFIG']
                f.seek(0)
                json.dump(data, f)
                f.truncate()

        self.menu.menu_options['Favorites'] = self.CardSession(
            self, self.config["favorites"], 'favorites')

        print(self.config['favorites'])

    def saveAndExit(self):
        pass

    def getCards(self):
        pass

    def update(self):
        self.menu.redraw()
Exemplo n.º 12
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.º 13
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.º 14
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()
Exemplo n.º 15
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.º 16
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.º 17
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.º 18
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)
Exemplo n.º 19
0
"""
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:
"""
Exemplo n.º 20
0
Arquivo: radio.py Projeto: akx/dot3k
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(backlight),
            '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.joystick

Repeat delay determines how quickly holding the joystick
in a direction will start to trigger repeats
Exemplo n.º 21
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
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,
    print "Site: " + cm.BOLD + "http://www.fruitywifi.com" + cm.ENDC
    print "Twitter: " + cm.BOLD + "@fruitywifi @xtr4nge @HA1pe" + cm.ENDC
    print 

show_banner()

# menu struct
menu = Menu(
    structure={
        'Modules': Modules(),
        'Commands': Commandz(),
        'About': {
            'This App': About(),
            'FruityWifi': AboutFruityWifi(__FRUITYWIFI__, __FIRMWARE__)
        },
        'IP': IPAddress(), 
        'Settings': {
            'Contrast': Contrast(lcd),
            'Randomlight': Randomlight(backlight)            
        },
        'Quit': QuitProgramm()
    },
    lcd=lcd
)

def showWelcomeMessage():
    lcd.clear()
    lcd.set_cursor_position(0,0)
    lcd.write("Welcome!")
    lcd.set_cursor_position(0,1)
    lcd.write("FruityWiFi " +  __FRUITYWIFI__)
Exemplo n.º 24
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.º 25
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.º 26
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.º 27
0
import dothat.lcd as lcd
import dothat.backlight as backlight
from dot3k.menu import Menu, MenuOption
from mgtext import MGText
import time

def reset():
	lcd.clear()
	backlight.graph_off()
	backlight.off()

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:
Exemplo n.º 28
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.º 29
-1
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)