Exemplo n.º 1
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.º 2
0
print("""
This advanced example uses the menu framework.
It loads the debris game plugin. Your score is time survived in seconds, see how well you can do!

Press CTRL+C to exit.
""")

# Add the root examples dir so Python can find the plugins
sys.path.append("../../")

# 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
nav.bind_defaults(menu)

# Start the menu redraw loop
menu.run()

signal.pause()
Exemplo n.º 3
0
@nav.on(nav.RIGHT)
def handle_right(ch, evt):
	wake_screen()
	menu.right()

@nav.on(nav.BUTTON)
def handle_button(ch, evt):
	wake_screen()
	menu.select()

def my_except_hook(exctype, value, traceback):
	if exctype == KeyboardInterrupt:
		print ("KeyboardInterrupt")
		do_shutdown("")
	else:
		logger.critical("Uncaught exception", exc_info=(exctype, value, traceback))

		print("Cleaning up")
		do_shutdown("")
		sys.__excepthook__(exctype, value, traceback)

sys.excepthook = my_except_hook

print("Waiting for falling edge on unconnected pin")  
wake_screen()
menu.run()  # start the menu
menu_on = True
GPIO.wait_for_edge(spare_pin, GPIO.FALLING)  
print("This should never happen")