Esempio n. 1
0
        if returncode is None:
            # process is still running
            screen.text('Expanding SD card...',
                        font_size=12,
                        xy=(160, 180),
                        color='white')
        elif returncode != 0:
            screen.text('Expand rootfs failed with error %i' % returncode,
                        font_size=12,
                        xy=(160, 180),
                        color='white')
        else:
            screen.text('Success. Tingbot is rebooting...',
                        font_size=12,
                        xy=(160, 180),
                        color='white')

            if not state['finish_called']:
                once(seconds=5)(finish)
                state['finish_called'] = True


def finish():
    # update the startup link to point back at springboard
    subprocess.check_call('ln -snf home /apps/startup', shell=True)
    subprocess.check_call(['reboot'])


# run the app
tingbot.run(loop)
Esempio n. 2
0
playlist_button = gui.ToggleButton((160,0),NOTEBOOK_BUTTON_SIZE,align="top",label="Playlist")
playlist_panel = playlist.PlaylistPanel(current_panel)

lib_button = gui.ToggleButton((310,0),NOTEBOOK_BUTTON_SIZE,align="topright",label="Library")
lib_panel = library.LibraryPanel(playlist_panel)

nb = gui.NoteBook([(lib_button,lib_panel),(playlist_button,playlist_panel),(current_button,current_panel)])
gui.get_root_widget().update(downwards=True)

#set up twisted
def setUp():
    control_point = ControlPoint(Coherence({'logmode':'warning'}),
                                 auto_client=['MediaRenderer', 'MediaServer'])
    control_point.connect(lib_panel.add_library, 'Coherence.UPnP.ControlPoint.MediaServer.detected')
    control_point.connect(current_panel.add_renderer, 'Coherence.UPnP.ControlPoint.MediaRenderer.detected')
    
from twisted.internet import reactor
reactor.callWhenRunning(setUp)
reactor.interleave(tingbot.main_run_loop.callAfter)
try:
    tingbot.run()
finally:
    print "closing server"
    reactor.stop()
    print "clearing the queue"
    for i in range(30):
        time.sleep(0.03)
        tingbot.main_run_loop.clearQueue()
    print "exiting"
Esempio n. 3
0
        joystick_img = 'Gamepad-1.png'
    else:
        joystick_img = 'Gamepad-2.png'
    screen.image(iconise(state['network']), xy=(309, 0), align='top')
    screen.image(iconise(joystick_img), xy=(298, 0), align='topright')
    screen.image(iconise(mouse_img), xy=(277, 0), align='topright')
    screen.image(iconise(kbd_img), xy=(266, 0), align='topright')
    draw_dots()

    scroll_position = state['scroll_position']
    app_index = state['app_index']
    scroll_position += (app_index-scroll_position)*0.2

    if math.floor(scroll_position) != math.ceil(scroll_position):
        draw_app_at_index(
            int(math.floor(scroll_position)),
            scroll_position)

    draw_app_at_index(
        int(math.ceil(scroll_position)),
        scroll_position)

    state['scroll_position'] = scroll_position

# run the app
finder = PeripheralFinder(1.0)
try:
    tingbot.run(loop)
except SystemExit:
    finder.stop()
Esempio n. 4
0
import tingbot
from tingbot import *

# setup code here

@every(seconds=1.0/30)
def loop():
    # drawing code here
    screen.fill(color='black')
    screen.text('Hello world!')

tingbot.run()
Esempio n. 5
0
    
def remove_all():
    cb("Remove dynamic items",'all')
    scroller.scrolled_area.remove_all()
    scroller.resize_canvas((135,10))
    button_list[:] = []
    scroller.update(downwards=True)

gui.Button((0,0),(90,25),align="topleft",parent=dynamic_panel,
           label="Add item",callback=add_item)
gui.Button((0,30),(90,25),align="topleft",parent=dynamic_panel,
           label="Del last",callback=remove_last_item)
gui.Button((0,60),(90,25),align="topleft",parent=dynamic_panel,
           label="Del all",callback=remove_all)


def nb_cb(button,panel):
    print "Notebook panel changed: " +button.label

notebook_panels = [basic_panel,slider_panel,text_panel,
                   button_panel,dialog_panel,dynamic_panel]
nb = gui.NoteBook(zip(notebook_buttons,notebook_panels),callback = nb_cb)
print "Current notebook tab: " + nb.selected.label

gui.get_root_widget().fill(notebook_style.bg_color)
gui.show_all()
def loop():
    pass

run(loop)
Esempio n. 6
0

button = gui.Button((240, 200), (80, 30), align="top", label="Display", callback=display)

gui.StaticText((190, 0), (50, 20), align="top", label="Red")
gui.StaticText((240, 0), (50, 20), align="top", label="Green")
gui.StaticText((290, 0), (50, 20), align="top", label="Blue")

red_label = gui.StaticText((190, 180), (50, 20), label="0")
green_label = gui.StaticText((240, 180), (50, 20), label="0")
blue_label = gui.StaticText((290, 180), (50, 20), label="0")


def update_label(label, value):
    label.label = str(int(value))
    label.update()


red.callback = lambda x: update_label(red_label, x)
green.callback = lambda x: update_label(green_label, x)
blue.callback = lambda x: update_label(blue_label, x)


def loop():
    pass


screen.fill("black")
gui.show_all()
run(loop)
Esempio n. 7
0
                    on_press=lambda: arm.base.rotate_clock(None),
                    on_release=lambda: arm.base.stop())
    MomentaryButton(xy=(115, 190),
                    size=(85, 40),
                    label="Right",
                    on_press=lambda: arm.base.rotate_counter(None),
                    on_release=lambda: arm.base.stop())

    gui.ToggleButton(xy=(220, 130),
                     size=(85, 100),
                     label="Light",
                     align="topleft",
                     callback=light_on)


def run_setup():
    global arm
    if arm is None:
        try:
            arm = roboarm.Arm()
        except Exception as e:
            print e
            gui.message_box(message="No arm found, please connect")
        else:
            make_buttons(arm)
            tingbot.screen.fill("black")
            gui.get_root_widget().update(downwards=True)


tingbot.run(run_setup)