#!/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)
from plugins.utils import Backlight, Contrast 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()