Exemple #1
0
def run_app(path):
	import buttons
	buttons.init()
	if not buttons.has_interrupt("BTN_MENU"):
		buttons.enable_menu_reset()
	try:
		mod = __import__(path)
		if "main" in dir(mod):
			mod.main()
	except Exception as e:
		import sys
		import uio
		import ugfx
		s = uio.StringIO()
		sys.print_exception(e, s)
		ugfx.clear()
		ugfx.set_default_font(ugfx.FONT_SMALL)
		w=ugfx.Container(0,0,ugfx.width(),ugfx.height())
		ugfx.Label(0,0,ugfx.width(),ugfx.height(),s.getvalue(),parent=w)
		w.show()
		raise(e)
	import stm
	stm.mem8[0x40002850] = 0x9C
	import pyb
	pyb.hard_reset()
Exemple #2
0
def room_7():
	###Room 7 - exits EW
	room=7
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(0,1,0,1)	
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
def drawui():
    ugfx.init()
    buttons.init()
    ugfx.clear(ugfx.html_color(0x87F717))

    ugfx.set_default_font(ugfx.FONT_MEDIUM)

    ugfx.fill_circle(50,50, 20, ugfx.WHITE)
    ugfx.fill_circle(50, 100, 20, ugfx.WHITE)

    ugfx.text(45, 45, "A", ugfx.RED)
    ugfx.text(45, 95, "B", ugfx.RED)

    ugfx.text(95, 45, "Flash the lights", ugfx.WHITE)
    ugfx.text(95, 95, "Disco Inferno", ugfx.WHITE)

    ugfx.fill_polygon(270,50, [ [0,0], [40,0], [40, 175], [0, 175] ], ugfx.RED)#  , [230, 100], [230, 60]
    ugfx.fill_polygon(270,50, [ [0,0], [-20,10], [-20, 50], [0, 40] ], ugfx.RED)#  , [230, 100], [230, 60]

    ugfx.area(283, 61, 14, 10, ugfx.WHITE)
    ugfx.area(283, 79, 14, 10, ugfx.WHITE)
    ugfx.area(283, 97, 14, 10, ugfx.WHITE)
    ugfx.area(283, 115, 14, 10, ugfx.WHITE)
    ugfx.area(283, 133, 14, 10, ugfx.WHITE)
    ugfx.area(283, 151, 14, 10, ugfx.WHITE)
    ugfx.area(283, 169, 14, 10, ugfx.WHITE)
    ugfx.area(283, 187, 14, 10, ugfx.WHITE)
Exemple #4
0
def game_over(reason):
	ugfx.clear(ugfx.BLACK)
	ugfx.set_default_font(ugfx.FONT_TITLE)
	
	ugfx.text(80,40,"Game Over!",ugfx.WHITE)
	ugfx.text(20,100,reason,ugfx.RED)
	playing=0
Exemple #5
0
def room_3():
	###Room 3 - exits north, east
	room=3
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(1,1,0,0)
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
Exemple #6
0
def room_4():
	###Room 4 - exits west
	room=4
	print ("here")
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(0,0,0,1)
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
Exemple #7
0
def room_6():
	###Room 6 - exits EW
	room=6
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(0,1,0,1)
	ugfx.area(90,100,20,20,ugfx.BLUE)
	
	ugfx.fill_circle(80,100,5,ugfx.YELLOW)
Exemple #8
0
def room_9():
	###Room 9 - exits NES
	room=9
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(1,0,0,0)
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
	
	if not haskey1==1:
		ugfx.fill_circle(100,165,5,ugfx.GREEN)
Exemple #9
0
def room_5():
	###Room 5 - exits ES
	room=5
	global btn_a_presses
	btn_a_presses=0
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(0,1,1,0)
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
	if orc2>0:
		ugfx.fill_circle(70,70,10,ugfx.GREEN)
	else:
		ugfx.fill_circle(70,70,10,ugfx.RED)
Exemple #10
0
def room_2():
	###Room 2 - exits south, west, east
	room=2
	
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(0,1,1,1)
	

	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
	if orc1>0:
		ugfx.fill_circle(130,70,10,ugfx.GREEN)
	else:
		ugfx.fill_circle(130,70,10,ugfx.RED)
Exemple #11
0
def room_8():
	###Room 8 - exits WS
	global btn_a_presses
	btn_a_presses=0
	room=8
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(0,0,1,1)
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
	
	if orc3>0:
		ugfx.fill_circle(70,70,20,ugfx.GREEN)
	else:
		ugfx.fill_circle(70,70,30,ugfx.RED)
Exemple #12
0
def do_circle_of_life():
    ugfx.init()
    buttons.init()
    buttons.disable_menu_reset()

    colour = get_colour()
    grid = Grid(ugfx.width(), ugfx.height(), colour_fore = colour, colour_back = COLOUR_BACK)
    grid.randomise()

    ugfx.clear(COLOUR_BACK)

    hash_count = 0
    hash_last = None
    hash_last_last = None
    while True:
        # display
        hash_val = grid.display_badge()

        # randomise, if needed
        if hash_val == hash_last_last:
            hash_count += 1

            if hash_count == HASH_COUNT_LIMIT:
                colour = get_colour(colour)
                grid.set_colour(colour)
                grid.randomise()
                hash_count = 0

        else:
            hash_count = 0

        hash_last_last = hash_last
        hash_last = hash_val

        # process next generation
        grid.next_generation()
        grid.swap_cell_buffers()

        # buttons
        pyb.wfi()
        if buttons.is_triggered("BTN_A") or buttons.is_triggered("BTN_B"):
            colour = get_colour(colour)
            grid.set_colour(colour)
            grid.randomise()

        if buttons.is_triggered("BTN_MENU"):
            break
Exemple #13
0
def showPage():
    global current_page
    # avoid out of bounds errors
    current_page = max(1, min(current_page, total_pages))
    
    start = (current_page - 1) * APPS_PER_PAGE
    end = start + APPS_PER_PAGE
    apps_on_current_page = all_apps[start:end]

    # Refresh page
    ugfx.clear(ugfx.html_color(EMF_PURPLE))

    # Write current page number and arrows
    ugfx.Label(0, 20, ugfx.width(), 20, "Page {} of {}".format(current_page, total_pages), justification=ugfx.Label.CENTER)

    if current_page > 1:
        ugfx.fill_polygon(10, 16, [[0, 10], [15, 20], [15, 0]], ugfx.WHITE)
        
    if current_page < total_pages:
        ugfx.fill_polygon(ugfx.width() - 30, 16, [[0, 0], [15, 10], [0, 20]], ugfx.WHITE)
    
    # Write app numbers and names
    i = 0
    yOffset = 45
    xOffset = 0
    for a in apps_on_current_page:
        # xOffset = (i % 3) * 8  # offset lines to match the physical layout of the keypad
        ugfx.area(20 + xOffset, yOffset + 2, 20, 20, ugfx.WHITE)
        ugfx.text(23 + xOffset, yOffset + 3, keypadLabels[i] + " ", EMF_PURPLE)

        ugfx.Label(46 + xOffset, yOffset + 3, ugfx.width(), 20, a['title'], justification=ugfx.Label.LEFT)
        yOffset = yOffset + 22
        i = i + 1

    while True:
        for key in keypad:
            keyIndex = keypad.index(key)
            if buttons.is_pressed(key) and (keyIndex < len(apps_on_current_page)):
                apps_on_current_page[keyIndex]['app'].boot()
                break

        if buttons.is_triggered(Buttons.JOY_Right) and (current_page is not total_pages):
            current_page = current_page + 1
            return
        if buttons.is_triggered(Buttons.JOY_Left) and (current_page is not 1):
            current_page = current_page - 1
            return
Exemple #14
0
def messageCentered(message, firstLineTitle=True, png=None):
    try:
        font1 = "Roboto_Regular18"
        font2 = "Roboto_Regular12"
        color = ugfx.BLACK
        ugfx.clear(ugfx.WHITE)
        parts = message.split("\n")
        lines = []
        font = font1
        for part in parts:
            if len(part) < 1:
                lines.append("")
            else:
                lines.extend(lineSplit(part, ugfx.width(), font))
            if firstLineTitle:
                font = font2

        offset_y = int(ugfx.height() / 2)  #Half of the screen height
        offset_y -= 9  #Height of the first line divided by 2
        if firstLineTitle:
            offset_y -= 6 * len(lines) - 1  #Height of font1 divided by 2
        else:
            offset_y -= 9 * len(lines) - 1  #Height of font2 divided by 2

        if png != None:
            try:
                img_info = badge.png_info(png)
                offset_y -= int(img_info[1] / 2) + 4
                img_x = int((ugfx.width() - img_info[0]) / 2)
                ugfx.display_image(img_x, offset_y, png)
                offset_y += img_info[1] + 8
            except:
                pass

        lineCentered(offset_y, lines[0], font1, color)
        offset_y += 18

        for i in range(len(lines) - 1):
            if not firstLineTitle:
                lineCentered(offset_y, lines[i + 1], font1, color)
                offset_y += 18
            else:
                lineCentered(offset_y, lines[i + 1], font2, color)
                offset_y += 12
        ugfx.flush()
    except:
        print("!!! Exception in easydraw.messageCentered !!!")
Exemple #15
0
def setup():
    global background
    badge.init()
    ugfx.init()
    ugfx.input_init()
    ugfx.input_attach(ugfx.BTN_SELECT, reboot)
    ugfx.input_attach(ugfx.BTN_START, reboot)
    ugfx.input_attach(ugfx.JOY_DOWN, invert)
    ugfx.input_attach(ugfx.JOY_UP, invert)
    ugfx.input_attach(ugfx.JOY_RIGHT, invert)
    ugfx.input_attach(ugfx.JOY_LEFT, invert)
    ugfx.input_attach(ugfx.BTN_A, invert)
    ugfx.input_attach(ugfx.BTN_B, invert)
    ugfx.set_lut(ugfx.LUT_NORMAL)
    ugfx.clear(background)
    ugfx.flush()
    flip()
Exemple #16
0
def switchme(pushed):
    global switch
    if (pushed):
        if switch:
            print("ToorCamp")
            switch = False
            #clearGhosting()
            ugfx.clear(ugfx.WHITE)
            badge.eink_png(0, 0, '/lib/toorcamp/toorcamp.png')
            badge.eink_busy_wait()
        else:
            print("ToorCon")
            switch = True
            #clearGhosting()
            ugfx.clear(ugfx.WHITE)
            badge.eink_png(0, 0, '/lib/toorcamp/toorcon.png')
            badge.eink_busy_wait()
Exemple #17
0
def draw(y, sleep=2):
    global message
    enabled = badge.nvs_get_u8("sweary","enable", 0)
    if enabled and seeded and sleep:
        nick = badge.nvs_get_str("owner", "name", 'Offensive Owner')

	ugfx.clear(ugfx.BLACK)
	ugfx.flush()
	ugfx.clear(ugfx.WHITE)
	ugfx.flush()

	ugfx.string_box(0,10,296,26, nick + " says:", "Roboto_BlackItalic24", ugfx.BLACK, ugfx.justifyLeft)
	ugfx.string_box(0,45,296,38, message, "PermanentMarker36", ugfx.BLACK, ugfx.justifyCenter)

	return [interval, 0]

    return [9999999999, 0]
Exemple #18
0
def show_category(pressed=True):
    if not pressed:
        return
    ugfx.clear(ugfx.WHITE)
    global category
    categories_list.visible(False)
    categories_list.enabled(False)
    slug = repo.categories[categories_list.selected_index()]["slug"]
    showMessage("Loading " + slug + "...")
    #Clean up list
    while category_list.count() > 0:
        category_list.remove_item(0)
    try:
        try:
            category = repo.getCategory(slug)
        except:
            showMessage("Failed to open category " + slug + "!", True)
            time.sleep(1)
            show_categories()
        gc.collect()
        for package in category:
            category_list.add_item("%s rev. %s" %
                                   (package["name"], package["revision"]))
        category_list.selected_index(0)
        category_list.visible(True)
        category_list.enabled(True)
        #Input handling
        ugfx.input_attach(ugfx.BTN_START, btn_exit)
        ugfx.input_attach(ugfx.BTN_SELECT, btn_unhandled)
        ugfx.input_attach(ugfx.BTN_A, install_app)
        ugfx.input_attach(ugfx.BTN_B, show_categories)
        ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
        ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
        ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled)
        ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
        #Hint
        easydraw.disp_string_right_bottom(0, "START: Exit")
        easydraw.disp_string_right_bottom(1, "A: Install app")
        easydraw.disp_string_right_bottom(2, "B: Back")
        #Flush screen
        ugfx.flush()
    except BaseException as e:
        sys.print_exception(e)
        showMessage(e, True)
        time.sleep(1)
        show_categories()
Exemple #19
0
def cuss():
    t = easyrtc.string()
    ugfx.clear(ugfx.WHITE)

    #ugfx.string(x, y, string, font, colour)
    ugfx.string(10, 5, str(random.choice(first)), "PermanentMarker36",
                ugfx.BLACK)
    ugfx.string(30, 30, str(random.choice(second)), "PermanentMarker36",
                ugfx.BLACK)
    ugfx.string(100, 55, str(random.choice(third)), "PermanentMarker36",
                ugfx.BLACK)
    #    ugfx.string(110, 85, str(herp), "PermanentMarker22", ugfx.BLACK)
    ugfx.string(30, 85, " it's ", "PermanentMarker22", ugfx.BLACK)
    ugfx.string(140, 85, t, "PermanentMarker36", ugfx.BLACK)

    ugfx.flush()
    time.sleep(3)
Exemple #20
0
def main():
    #h = DHT11(machine.Pin(33)) # J8
    h = DHT11(machine.Pin(26))  # J7

    ugfx.set_default_font('IBMPlexMono_Bold24')
    ugfx.clear()
    ugfx.Label(40, 0, 240, 60, text='DHT11/22 Demo')

    ugfx.set_default_font('IBMPlexMono_Regular24')
    l = ugfx.Label(40, 60, 240, 120, text='')

    while True:
        h.measure()
        h.temperature()
        l.text('temperature:{},humidity:{}'.format(h.temperature(),
                                                   h.humidity()))
        time.sleep(1)
Exemple #21
0
def cuss():
##    t = easyrtc.string()
    ugfx.clear(ugfx.WHITE)
    herp = str(random.choice(first))

###ugfx.string(x, y, string, font, colour)
    ugfx.string(10, 5, str(random.choice(first)), "Roboto_BlackItalic24", ugfx.BLACK)
    ugfx.string(30, 25, str(random.choice(second)), "PermanentMarker36", ugfx.BLACK)
    len = ugfx.get_string_width(str(random.choice(second)),"PermanentMarker36")
    ugfx.line(25, 59, 72 + len, 59, ugfx.BLACK)
    ugfx.string(135, 68, str(random.choice(third)), "Roboto_BlackItalic24", ugfx.BLACK)
#    ugfx.string(110, 85, str(herp), "PermanentMarker22", ugfx.BLACK)
    ugfx.string(30, 95, " it's ", "PermanentMarker22", ugfx.BLACK)
##    ugfx.string(140, 85, t, "PermanentMarker36", ugfx.BLACK)

    ugfx.flush()
    time.sleep(3)
Exemple #22
0
def show_category(pressed=True, fromAppInstall=False):
    global lastCategory
    if not pressed:
        return
    ugfx.input_attach(ugfx.BTN_A, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_B, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_C, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_BOOT, btn_unhandled)
    ugfx.clear(ugfx.WHITE)
    global category
    if not fromAppInstall:
        lastCategory = myList.selected_index()
    slug = repo.categories[lastCategory]["slug"]
    showMessage("Loading " + slug + "...")
    display.drawFill()
    myList.clear()
    try:
        try:
            category = repo.getCategory(slug)
        except BaseException as e:
            showMessage("Failed to open category " + slug + "!", True)
            display.drawFill()
            print("CAT OPEN ERR", e)
            time.sleep(1)
            show_categories()
            return
        gc.collect()
        for package in category:
            myList.add_item("%s rev. %s" %
                            (package["name"], package["revision"]))
        myList.visible(True)
        myList.enabled(True)
        #Input handling
        ugfx.input_attach(ugfx.BTN_A, install_app)
        ugfx.input_attach(ugfx.BTN_B, btn_unhandled)
        ugfx.input_attach(ugfx.BTN_C, btn_unhandled)
        ugfx.input_attach(ugfx.BTN_BOOT, show_categories)
        display.flush(display.FLAG_LUT_NORMAL)
    except BaseException as e:
        sys.print_exception(e)
        print("ERROR", e)
        showMessage("Internal error", True)
        display.drawFill()
        time.sleep(1)
        show_categories()
Exemple #23
0
def draw(mode, goingToSleep=False):
    ugfx.orientation(0)
    if mode:
        # We flush the buffer and wait
        ugfx.flush(ugfx.LUT_FULL)
        badge.eink_busy_wait()
    else:
        # We prepare the screen refresh
        ugfx.clear(ugfx.WHITE)
        if goingToSleep:
            info1 = 'Sleeping...'
            info2 = 'Press any key to wake up'
        else:
            info1 = 'Press start to open the launcher'
            if otac.available(False):
                info2 = 'Press select to start OTA update'
            else:
                info2 = ''

        def disp_string_right(y, s):
            l = ugfx.get_string_width(s, "Roboto_Regular12")
            ugfx.string(296 - l, y, s, "Roboto_Regular12", ugfx.BLACK)

        disp_string_right(0, info1)
        disp_string_right(12, info2)

        if badge.safe_mode():
            disp_string_right(92, "Safe Mode - services disabled")
            disp_string_right(104,
                              "Sleep disabled - will drain battery quickly")
            disp_string_right(116, "Press Reset button to exit")

        nickname()

        on_usb = pm.usb_attached()
        vBatt = badge.battery_volt_sense()
        vBatt += vDrop
        charging = badge.battery_charge_status()

        battery(on_usb, vBatt, charging)

        if vBatt > 500:
            ugfx.string(52, 0,
                        str(round(vBatt / 1000, 1)) + 'v', 'Roboto_Regular12',
                        ugfx.BLACK)
Exemple #24
0
 def render(self):
     global game_state
     print('render '+game_state)
     ugfx.clear()
     if game_state == 'SEARCH':
         ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
         ugfx.Label(5, 5, ugfx.width(), 20, "Scanning for hackers!...")
         ugfx.set_default_font(ugfx.FONT_NAME)
         ugfx.Label(5, 30, ugfx.width(), 40, self.current_battle.status())
         ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
         ugfx.Label(5, 100, ugfx.width(), 20, "Press (A) to battle, (B) to try to escape")
     elif game_state == 'BATTLE':
         ugfx.set_default_font(ugfx.FONT_NAME)
         ugfx.Label(5, 30, ugfx.width(), 40, self.current_battle.status())
         ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
         ugfx.Label(5, 100, ugfx.width(), 20, "Press (A) to continue, (B) to try to escape")
     elif game_state == 'ATTACK':
         ugfx.set_default_font(ugfx.FONT_NAME)
         ugfx.Label(5, 30, ugfx.width(), 40, self.current_battle.status())
         ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
         ugfx.Label(5, 100, ugfx.width(), 20, "Press (A) to continue, (B) to try to escape")
     elif game_state == 'ESCAPE':
         ugfx.set_default_font(ugfx.FONT_NAME)
         ugfx.Label(5, 30, ugfx.width(), 40, self.current_battle.status())
         ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
         ugfx.Label(5, 100, ugfx.width(), 20, "Press (A) to continue, (B) to try to escape")
     elif game_state == 'WIN':
         ugfx.set_default_font(ugfx.FONT_NAME)
         ugfx.Label(5, 30, ugfx.width(), 40, self.current_battle.status())
         ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
         ugfx.Label(5, 100, ugfx.width(), 20, "Press (A) to continue, (B) to try to escape")
     elif game_state == 'LOSE':
         ugfx.set_default_font(ugfx.FONT_NAME)
         ugfx.Label(5, 30, ugfx.width(), 40, self.current_battle.status())
         ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
         ugfx.Label(5, 100, ugfx.width(), 20, "Press (A) to continue, (B) to try to escape")
     elif game_state == 'INACTIVE':
         ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD)
         ugfx.Label(5, 5, ugfx.width(), 25, "Hello agent,")
         ugfx.Label(5, 25, ugfx.width(), 25, "Captures: %i" % self.gumshoe.captures)
         ugfx.Label(5, 50, ugfx.width(), 25, "XP: %i" % self.gumshoe.xp)
         ugfx.Label(5, 75, ugfx.width(), 25, "Instructions:")
         ugfx.Label(5, 100, ugfx.width(), 25, "(1) Explore the EMF site")
         ugfx.Label(5, 125, ugfx.width(), 50, "(2) When in position, press A to start a search for nearby hackers...")
         ugfx.Label(5, 175, ugfx.width(), 50, "Beware of confronting more experienced hackers!")
Exemple #25
0
def draw_screen():
    global bar, stock

    ugfx.clear(ugfx.BLACK)
    ugfx.text(65, 5, "what's on tap?", ugfx.RED)
    ugfx.line(5, 20, ugfx.width(), 20, ugfx.GREY)

    for idx, beer in enumerate(bar['location']):

        remaining = 0

        for item in stock['stock']:
            if item['description'] == beer['description']:
                remaining = float(item['remaining'])

        ugfx.text(5, 22 + idx*15, beer['description'][:28], ugfx.WHITE)
        ugfx.text(202, 22 + idx*15, '!' if (remaining < 30) else ' ', ugfx.RED)
        ugfx.text(210, 22 + idx*15, "{:>4}".format(beer['price']), ugfx.WHITE)
def attempt_unlock_secret_entered(secret):
    ugfx.clear(ugfx.WHITE)
    ugfx.string(15, 10, "SHA2017 - Ransomware", "Roboto_BlackItalic24",
                ugfx.BLACK)

    if secret == ransom_secret:
        badge.nvs_set_str('boot', 'splash', 'splash')
        cry = __import__("/lib/ascii_porn/wannacry")
        cry.restore()
        write(40, "Dobby is free!")
        ugfx.flush()
        time.sleep(4)
        appglue.home()
    else:
        write(40, "INVALID RANSOM SECRET!")
        ugfx.flush()
        time.sleep(4)
        write_lock()
Exemple #27
0
    def draw_ship(self):
        ugfx.clear(ugfx.WHITE)

        ugfx.string(10, SCREEN_Y-15, "You are playing on a "+self.wrapper.name(),
                        "RobotoRegular12", ugfx.BLACK)
        #ugfx.string(10, SCREEN_Y-28, "r: "+str(self.r),
        #                "RobotoRegular12", ugfx.BLACK)
        #ugfx.string(10, SCREEN_Y-41, "y: "+str(self.y),
        #                "RobotoRegular12", ugfx.BLACK)
        #ugfx.string(10, SCREEN_Y-54, "x: "+str(self.x),
        #                "RobotoRegular12", ugfx.BLACK)

        self.draw_line(self.x+4*self.size, self.y, self.x-6*self.size, self.y-5*self.size)
        self.draw_line(self.x+4*self.size, self.y, self.x-6*self.size, self.y+5*self.size)
        self.draw_line(self.x-3*self.size, self.y, self.x-6*self.size, self.y-5*self.size)
        self.draw_line(self.x-3*self.size, self.y, self.x-6*self.size, self.y+5*self.size)

        ugfx.flush()
Exemple #28
0
def room_1():
	### Room 1 - exit north
	room=1
	
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	
	build_room_walls(1,0,0,0)

	
	#corridor N
	ugfx.thickline(90,34,90,0,ugfx.WHITE,7,0)
	ugfx.thickline(110,34,110,0,ugfx.WHITE,7,0)

	#door
	ugfx.thickline(90,180,110,180,ugfx.BLUE,7,0)
	#PC
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
Exemple #29
0
def start_launcher(pushed):
    global splashTimer
    if (pushed):
        splashTimer.deinit()

        #By importing it...
        #import launcher

        #Or by sleeping...
        ugfx.clear(ugfx.WHITE)
        ugfx.string(0, 0, "Starting launcher...", "Roboto_Regular12",
                    ugfx.BLACK)
        ugfx.flush()
        import time
        time.sleep(0.5)
        import esp
        esp.rtcmem_write_string("launcher")
        esp.start_sleeping(1)
Exemple #30
0
def draw(mode, goingToSleep=False):
	info1 = ''
	info2 = ''
	if mode:
		# We flush the buffer and wait
		ugfx.flush(ugfx.GREYSCALE)
	else:
		# We prepare the screen refresh
		ugfx.clear(ugfx.WHITE)
		easydraw.nickname()
		if goingToSleep:
			info = 'Sleeping...'
		elif badge.safe_mode():
			info = "(Services disabled!)"
		elif otac.available(False):
			info = 'Update available!'
		else:
			info = ''
		easydraw.disp_string_right_bottom(0, info)
Exemple #31
0
def show_categories(pressed=True, fromAppInstall=False):
    if not pressed:
        return
    ugfx.input_attach(ugfx.BTN_A, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_B, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_C, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_BOOT, btn_unhandled)
    ugfx.clear(ugfx.WHITE)
    myList.clear()
    for category in repo.categories:
        myList.add_item("%s (%d) >" % (category["name"], category["eggs"]))
    myList.enabled(True)
    myList.visible(True)
    #Input handling
    ugfx.input_attach(ugfx.BTN_A, show_category)
    ugfx.input_attach(ugfx.BTN_B, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_C, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_BOOT, btn_exit)
    display.flush(display.FLAG_LUT_NORMAL)
Exemple #32
0
def main():
    print("emf_hub_mon: Starting emf_hub_mon")

    # Init GFX and Buttons
    ugfx.init()
    buttons.init()

    # Config
    config = database.Database(filename='apps/emf_hub_mon/emf_hub_mon.json')

    # Status bar service
    status_service = status_bar(config)

    # LED service
    led_service = led(config)

    # Display service
    mon_service = mon_display(config, status_service, led_service)

    # Display welcome screen on first boot
    if config.get('first_boot'):
        mon_service.welcome()

    # MQTT service
    mqtt_service = mqtt_handler(config, mon_service)

    # Initialise the monitor display
    mon_service.init()

    while True:
        # Handle MQTT operations
        mqtt_service.handle()

        # Handle Display operations
        mon_service.update()

        # Give the CPU a break
        pyb.delay(200)

    # clean up some stuff, not sure if this is required but w/e
    ugfx.clear()
    led_service.off()
def show_category(pressed=True, fromAppInstall=False):
    global lastCategory
    if not pressed:
        return
    ugfx.input_attach(ugfx.BTN_BACK, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_OK, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
    ugfx.clear(ugfx.WHITE)
    global category
    if not fromAppInstall:
        lastCategory = selectBox.selected_index()
    slug = repo.categories[lastCategory]["slug"]
    easydraw.messageCentered("Loading category...\n" + slug, True,
                             "/media/busy.png")
    display.drawFill()
    selectBox.clear()
    try:
        category = repo.getCategory(slug)
        gc.collect()
        for package in category:
            selectBox.add_item(package["name"])
        selectBox.visible(True)
        selectBox.enabled(True)
        #Input handling
        ugfx.input_attach(ugfx.BTN_OK, install_app)
        ugfx.input_attach(ugfx.BTN_BACK, show_categories)
        ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
        ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
        ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled)
        ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
        #Flush screen
        display.flush(display.FLAG_LUT_NORMAL)
    except BaseException as e:
        sys.print_exception(e)
        easydraw.messageCentered("An error occured!", False,
                                 "/media/alert.png")
        display.drawFill()
        time.sleep(1)
        show_categories()
def show_names():
	global names
	c = False
	y = 10
	ugfx.clear()
	
	term.header(True, "About")
	print("Developers:")
	for n in range(0, len(names)):
		if (names[n]==" "):
			break
		print(" - "+names[n])
	
	easydraw.msg("Your badge has been made possible by the following people:", "About", True)
	
	for n in range(0, len(names)):
		if easydraw.msg(names[n]):
			time.sleep(0.5)
	
	easydraw.msg("Press back or start to quit!")
Exemple #35
0
def show_manual():
    ugfx.clear(APP_COLOUR)
    window = ugfx.Container(0, 0, ugfx.width(), ugfx.height())
    window.show()
    window.text(5, 10, "TiNDA: Dating app for TiLDA", ugfx.BLACK)
    window.text(5, 30, "Find your perfect EMF match", ugfx.BLACK)
    window.line(0, 50, ugfx.width(), 50, ugfx.BLACK)

    window.text(5, 60, "Step 1: Answer all questions", ugfx.BLACK)
    window.text(5, 80, "and receive an emoji card.", ugfx.BLACK)

    window.text(5, 110, "Step 2: Compare cards with", ugfx.BLACK)
    window.text(5, 130, "other people and count", ugfx.BLACK)
    window.text(5, 150, "matching emoji.", ugfx.BLACK)

    window.text(5, 180, "Step 3: <3", ugfx.BLACK)

    while ((not Buttons.is_pressed(Buttons.BTN_B))
           and (not Buttons.is_pressed(Buttons.BTN_Menu))):
        sleep.wfi()
Exemple #36
0
def start():
	ugfx.input_init()
	ugfx.set_lut(ugfx.LUT_FASTER)
	ugfx.clear(ugfx.WHITE)

	# Instructions
	if orientation.isLandscape():
		ugfx.line(148, 78, 296, 78, ugfx.BLACK)
		ugfx.string_box(148,78,148,18, " A: Run", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft)
		ugfx.string_box(148,78,148,18, " B: Return to home", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyRight)
		ugfx.string_box(148,92,148,18, " SELECT: Uninstall", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft)
		ugfx.line(148, 110, 296, 110, ugfx.BLACK)
		ugfx.string_box(148,110,148,18, " " + version.name, "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft)
	else:
		ugfx.line(0, ugfx.height()-18*4, ugfx.width(), ugfx.height()-18*4, ugfx.BLACK)
		ugfx.string_box(0,ugfx.height()-18*4,ugfx.width(),18, " A: Run", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft)
		ugfx.string_box(0,ugfx.height()-18*3,ugfx.width(),18, " B: Return to home", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft)
		ugfx.string_box(0,ugfx.height()-18*2,ugfx.width(),18, " SELECT: Uninstall", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft)
		ugfx.line(0, ugfx.height()-18*1, ugfx.width(), ugfx.height()-18*1, ugfx.BLACK)
		ugfx.string_box(0,ugfx.height()-18*1,ugfx.width(),18, " " + version.name, "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft)

	global options
	global install_path
	options = None
	install_path = None

	ugfx.input_attach(ugfx.BTN_A, input_a)
	ugfx.input_attach(ugfx.BTN_B, input_b)
	ugfx.input_attach(ugfx.BTN_SELECT, input_select)
	ugfx.input_attach(ugfx.JOY_UP, input_other)
	ugfx.input_attach(ugfx.JOY_DOWN, input_other)
	ugfx.input_attach(ugfx.JOY_LEFT, input_other)
	ugfx.input_attach(ugfx.JOY_RIGHT, input_other)
	ugfx.input_attach(ugfx.BTN_START, input_other)

	populate_apps()
	populate_category()
	populate_options()

	# do a greyscale flush on start
	ugfx.flush(ugfx.GREYSCALE)
Exemple #37
0
def draw_home(percent, cstate, status):
    ugfx.clear(ugfx.WHITE)
    if (cstate):
        ugfx.string(0, 0,
                    str(percent) + "% & Charging... | " + status,
                    "Roboto_Regular12", ugfx.BLACK)
    else:
        ugfx.string(0, 0,
                    str(percent) + "% | " + status, "Roboto_Regular12",
                    ugfx.BLACK)

    htext = badge.nvs_get_str("owner", "htext", "")
    if (htext != ""):
        draw_logo(160, 25, htext)

    nick = badge.nvs_get_str("owner", "name", "Anonymous")
    ugfx.string(0, 40, nick, "PermanentMarker36", ugfx.BLACK)

    ugfx.set_lut(ugfx.LUT_FULL)
    ugfx.flush()
    ugfx.set_lut(ugfx.LUT_FASTER)
Exemple #38
0
    def print_page(self):
        self.content = ["xxxxxxxxxxxxxxxxxxx             xxxxxxxxx       xxxxxxxxx",
                        "xxxxxxxxxxxx      x               x     x         x     x",
                        "xxxxxxxxxxxx  xxxxx xxxxxxxxxxxxx x  xxxx xxxxxxx x  x  x xxxxxxxxxxxxxxxxxxxxxx",
                        "xxxxxxxxxxxx    xxx x    xxx    x x    xx x     x x     x x  x  xxxxxxxxxxxxxxxx",
                        "xxxxxxxxxxxx  xxxxx x  x  x  x  x x  xxxx x  xxxx x  x  x x  x  xxxxxxxxxxxxxxxx",
                        "xxxxxxxxxxxx      x x  xx   xx  x x  xxxx x    xx x  x  x xx   xxxxxxxxxxxxxxxxx",
                        "xxxxxxxxxxxxxxxxxxx x  xxxxxxx  x xxxxxxx x  xxxx xxxxxxx x  x  xxxxxxxxxxxxxxxx",
                        "                    x  xxxxxxx  x         x  xxxx         x  x  xxxxxxxxxxxxxxxx",
                        "                  xxxxxxxxxxxxxxx       xxxxxxxxx       xxxxxxxxxxxxxxxxxxxxxxxx"]

        ugfx.clear(ugfx.BLACK)
        ugfx.area(0, 5, 320, 45, ugfx.BLUE)
        
        for i,line in enumerate(self.content):
            for j,c in enumerate(line):
                if c=="x":
                    ugfx.area(4*j, 5*i+5, 4, 5, ugfx.YELLOW)
        
        ugfx.area(0, 220, 320, 15, ugfx.YELLOW)
        ugfx.text(35, 221, "EMFFAX: The World at Your Fingertips", ugfx.BLUE)
Exemple #39
0
def show_shift_list():
    ugfx.clear(ugfx.WHITE)
    ugfx.flush()
    global shift_list
    global shifts
    shift_list = ugfx.List(0, 0, ugfx.width(), ugfx.height())
    if not shifts:
        shifts = get_shifts(api_key)
    for shift in shifts:
        shift_list.add_item("{} - {}, {}".format(
            generate_timedelta_text(int(shift['start']), int(shift['end'])),
            shift['name'], shift["Name"]))
    ugfx.flush(ugfx.LUT_NORMAL)
    ugfx.input_attach(ugfx.JOY_UP, nothing)
    ugfx.input_attach(ugfx.JOY_DOWN, nothing)
    ugfx.input_attach(ugfx.JOY_LEFT, nothing)
    ugfx.input_attach(ugfx.JOY_RIGHT, nothing)
    ugfx.input_attach(ugfx.BTN_A, lambda pressed: show_shift_detail()
                      if pressed else None)
    ugfx.input_attach(ugfx.BTN_B, lambda pressed: appglue.home()
                      if pressed else None)
Exemple #40
0
def install_app(active):
    if active:
        global options
        global text
        global packages
        global selected_app

        index = options.selected_index()

        ugfx.input_attach(ugfx.JOY_UP, 0)
        ugfx.input_attach(ugfx.JOY_DOWN, 0)
        ugfx.input_attach(ugfx.BTN_A, 0)
        ugfx.input_attach(ugfx.BTN_B, 0)
        ugfx.input_attach(ugfx.BTN_START, 0)

        ugfx.clear(ugfx.BLACK)
        ugfx.string(40, 25, "Installing:", "Roboto_BlackItalic24", ugfx.WHITE)
        ugfx.string(100, 55, packages[index]["name"], "PermanentMarker22",
                    ugfx.WHITE)
        ugfx.flush()

        import woezel
        selected_app = packages[index]["slug"]
        woezel.install(selected_app)

        ugfx.clear(ugfx.WHITE)
        ugfx.string(40, 25, "Installed:", "Roboto_BlackItalic24", ugfx.BLACK)
        ugfx.string(100, 55, packages[index]["name"], "PermanentMarker22",
                    ugfx.BLACK)
        ugfx.string(0, 115, "[ A: START | B: BACK ]", "Roboto_Regular12",
                    ugfx.BLACK)

        ugfx.input_attach(ugfx.BTN_A, start_app)
        ugfx.input_attach(ugfx.BTN_B, start_categories)
        ugfx.input_attach(
            ugfx.BTN_START, lambda pushed: appglue.start_app("")
            if pushed else False)

        ugfx.flush()
        gc.collect()
Exemple #41
0
def download_avatar():
    avatar_url = db.get("avatar_url", "")
    if avatar_url:
        if (avatar_url.endswith(".png") or avatar_url.startswith("http")):
            try:
                image = http.get(avatar_url).raise_for_status().content
                ugfx.orientation(90)
                ugfx.display_image(0, 0, bytearray(image))
                #f = open(avatar_file_name, 'w')
                #f.write(image)
                #f.close()
                #ugfx.display_image(0,0,bytearray(image))
            except:
                ugfx.clear(ugfx.html_color(0x000000))
                ugfx.orientation(270)
                ugfx.text(3, 65, "Couldn't download the avatar.", ugfx.RED)
                return False
        else:
            ugfx.clear(ugfx.html_color(0x000000))
            ugfx.orientation(270)
            ugfx.text(3, 65, "Invalid avatar url.", ugfx.RED)
            return False
    else:
        ugfx.clear(ugfx.html_color(0x000000))
        ugfx.orientation(270)
        ugfx.text(3, 65, "No avatar url.", ugfx.RED)
    return True
def show_categories(pressed=True, fromAppInstall=False):
    if not pressed:
        return
    ugfx.input_attach(ugfx.BTN_BACK, btn_unhandled)
    ugfx.input_attach(ugfx.BTN_OK, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_LEFT, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
    ugfx.clear(ugfx.WHITE)
    selectBox.clear()
    for category in repo.categories:
        selectBox.add_item(category["name"])
    selectBox.enabled(True)
    selectBox.visible(True)
    ugfx.input_attach(ugfx.BTN_BACK, btn_exit)
    ugfx.input_attach(ugfx.BTN_OK, show_category)
    ugfx.input_attach(ugfx.JOY_UP, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_DOWN, btn_unhandled)
    ugfx.input_attach(ugfx.JOY_LEFT, btn_update)
    ugfx.input_attach(ugfx.JOY_RIGHT, btn_unhandled)
    display.flush(display.FLAG_LUT_NORMAL)
    def show_trains(self):
        ugfx.clear()
        ugfx.area(0, 0, 240, 25, ugfx.RED if self.has_error else ugfx.GRAY)
        title = get_title(self.station_data['locationName'], self.has_error)
        ugfx.text(5, 5, title, ugfx.WHITE if self.has_error else ugfx.BLACK)
        ugfx.text(195, 5, time_as_string(), ugfx.BLUE)

        names = self._get_names_container()
        names.show()
        row_num = 0
        for service in self.station_data['trainServices']:
            departure = get_departure(service)
            if departure:
                names.text(5, 15 * row_num,
                           service['destination'][0]['locationName'],
                           ugfx.BLACK)
                ugfx.text(195, 25 + (15 * row_num), departure,
                          ugfx.RED if is_red(service) else ugfx.BLUE)
                row_num += 1

        ugfx.display_image(0, 300, 'trains/bottom.gif')
        self.should_redraw = False
Exemple #44
0
    def __init__(self):
        # initialize ugfx
        ugfx.init()
        ugfx.clear(ugfx.WHITE)

        # Buttons
        ugfx.input_init()
        self.init_buttons()

        # Container
        width = ugfx.width()
        height = ugfx.height()
        ind_height = 46
        container_height = height - ind_height

        self.indicator = ugfx.Container(0,
                                        0,
                                        width,
                                        ind_height,
                                        style=styles.ibm_st)
        self.container = ugfx.Container(0,
                                        ind_height,
                                        width,
                                        container_height,
                                        style=styles.ibm_st)

        self.graph_basepos = container_height - 5

        # Sensor
        self.gas_sensor = ADC(Pin(34))
        self.gas_sensor.atten(ADC.ATTN_11DB)
        self.gas_sensor.width(ADC.WIDTH_12BIT)

        # Smooth
        self.Vos = 0

        # Buzzer
        self.buzzer = Buzzer()
def list_categories():
    global options
    global categories

    try:
        categories
    except:
        ugfx.input_init()
        easydraw.msg('Getting categories', "Loading...", True)
        try:
            f = urequests.get("https://badge.disobey.fi/eggs/categories/json",
                              timeout=30)
            categories = f.json()
        except:
            easydraw.msg('Failed :(')
            appglue.start_app('launcher', False)

            f.close()
        easydraw.msg('Success :)')
        options = ugfx.List(0, 0, int(ugfx.width()), ugfx.height())

    ugfx.input_attach(ugfx.JOY_UP, dummy_button_cb)
    ugfx.input_attach(ugfx.JOY_DOWN, dummy_button_cb)
    ugfx.input_attach(ugfx.BTN_START, select_category)
    ugfx.input_attach(
        ugfx.BTN_B, lambda pushed: appglue.start_app("launcher", False)
        if pushed else False)

    ugfx.clear(ugfx.WHITE)
    ugfx.flush()

    while options.count() > 0:
        options.remove_item(0)
    for category in categories:
        options.add_item("%s (%d) >" % (category["name"], category["eggs"]))
    options.selected_index(0)
    ugfx.flush(ugfx.LUT_FULL)
    gc.collect()
Exemple #46
0
import pyb
import ugfx
import buttons

imu = IMU()

buttons.init()

ugfx.init()
h = ugfx.height()
w = ugfx.width()

bgcolor = ugfx.BLACK    # foreground colour
fgcolor = ugfx.WHITE    # background colour

ugfx.clear(bgcolor)

pw = 40     # progress bar width
ph = h - 20 # progress bar height
pm = 5      # progress bar margin

# draw the boxes for the progress bars
ugfx.box((w//2)-(w//4)-(pw//2), (h//2)-(ph//2), pw, ph, fgcolor)
ugfx.box((w//2)-(pw//2), (h//2)-(ph//2), pw, ph, fgcolor)
ugfx.box((w//2)+(w//4)-(pw//2), (h//2)-(ph//2), pw, ph, fgcolor)

# label the progress bars
ugfx.text((w//2)-(w//4)-(pw//2)-15, (h//2), 'x', fgcolor)
ugfx.text((w//2)-(pw//2)-15,        (h//2), 'y', fgcolor)
ugfx.text((w//2)+(w//4)-(pw//2)-15, (h//2), 'z', fgcolor)
Exemple #47
0
def get_color(val):
	return ((val & 0x1f) << 11) | ((val & 0x1f) << 6) | (val & 0x1f)

def m(x, y):
	# Normalised coordinates
	a = 4.0 * (x/size[0] - 0.66)
	b = 3.0 * (y/size[1] - 0.50)

	z = 0
	for n in range(32):
		z = z**2 + a + b*1j
		if abs(z) > 4:
			break
	return 31-n

ugfx.clear(ugfx.GREY)
ugfx.text(30, int(size[1])-30, 'Computing...', ugfx.BLACK)

for y in range(size[1]):
	for x in range(size[0]):
		c = m(x, y)
		ugfx.area(x, y, 1, 1, get_color(c))

	if buttons.is_triggered("BTN_B"):
		break

while playing:
	ugfx.text(30, int(size[1])-30, 'Mandelbrot done :)', ugfx.WHITE)

	while True:
		# pyb.wfi() # Some low power stuff
def redraw_whole_bg():
    ugfx.clear(SKIES[level])
    ugfx.area(0, 191, 320, 10, GRASS)
    ugfx.area(0, 201, 320, 40, GROUND_2)
    redraw_bg_range(0, 201, 320, 240)
Exemple #49
0
 def print_page(self):
     ugfx.clear(ugfx.BLACK)
     ugfx.area(0, 5, 320, 45, ugfx.BLUE)
     
     ugfx.area(0, 220, 320, 15, ugfx.YELLOW)
     ugfx.text(35, 221, "EMFFAX: The World at Your Fingertips", ugfx.BLUE)
Exemple #50
0
# uses the accelerator for input of the buzzer and displays a circle

from imu import IMU
import pyb
import ugfx
import buttons

imu = IMU()


ugfx.init()

bgcolor = ugfx.BLACK
fgcolor = ugfx.YELLOW

ugfx.clear(bgcolor)
ugfx.backlight(20)

buttons.init()

t4 = pyb.Timer(4, freq=100, mode=pyb.Timer.CENTER)


while not buttons.is_pressed("BTN_MENU"):
    accel = imu.get_acceleration()
    accel_x = accel.get('x')
    accel_y = accel.get('y')
    accel_z = accel.get('z')
    accel_use = accel_y
    t4.freq(700 + accel_use * 200)
    ch1 = t4.channel(1, pyb.Timer.PWM, pin=pyb.Pin("BUZZ"), pulse_width=(t4.period() + 1) // 2)
Exemple #51
0
    tone(d,bp,pp)
    tone(d,bp,pp)
    tone(d,bp,pp)
    tone(g,bp*4,pp)
    
    tone(d,bp,pp)
    tone(d,bp,pp)
    tone(d,bp,pp)
    tone(g,bp*4,pp)

	
			

ugfx.set_default_font(ugfx.FONT_TITLE)

ugfx.clear(ugfx.BLACK)
ugfx.text(80,40,"Adventure!",ugfx.WHITE)
ugfx.text(20,100,"Escape from the Castle!",ugfx.RED)
play_theme()
pyb.delay(2000)
room_1()
###start at this room


while True:
	playing=1

	while playing:
	
		if buttons.is_triggered("JOY_UP"):
			if room == 1:
Exemple #52
0
    while True:

        # set orientation
        flip = 1
        ival = imu.get_acceleration()
        if ival['y'] < 0:
        	ugfx.orientation(0)
        else:
        	ugfx.orientation(180)

        if ival['y'] < 0:
            flip = -1

        # estimate 10 characters per screen...
        ugfx.clear(backgrounds[colorIndex])
        colorIndex += 1
        colorIndex %= len(backgrounds)
        accel = ival['x']*flip # -1 to 1

        # Center middle
        # estimate 32px per character... ugly
        position += int(accel*speed)
        if (position > name_len):
            position = -name_len
        if (position < -name_len):
            position = name_len

        ugfx.text(position-name_len, cy, name, ugfx.BLACK)
        ugfx.text(position, cy, name, ugfx.WHITE)
        ugfx.text(position+name_len, cy, name, ugfx.BLACK)
Exemple #53
0
def screen_3():
    ugfx.clear(ugfx.html_color(0x7c1143))
    ugfx.text(27, 90, "Thank you!", ugfx.WHITE)
Exemple #54
0
### Description: Wearables Controller
### Category: Flashy
### License: MIT
### Appname : Wearables
### Built-in: no

import ugfx
from database import *
import dialogs
import buttons

buttons.init()
buttons.disable_menu_reset()

ugfx.init()
ugfx.clear(ugfx.html_color(0x7c1143))

pin_options = [
	{"title": "Onboard NeoPixel", "value":"PB13"},
	{"title": "Servo Header 2", "value":"X2"},
]

led_pin_name = database_get("led-port", "PB13")
pinnm = dialogs.prompt_option(pin_options, text="What connector are your neopixels on?", title="Wearables Controller")
if pinnm:
	database_set("led-port", pinnm['value'])

menu_items = [
	{"title": "Rainbow", "value":"rainbow"},
	{"title": "Matrix", "value":"matrix"},
	{"title": "Colour", "value":"colour"},
        tone(150,50,30)
        tone(180,50,30)
        tone(100,250,30)
        redraw_whole_bg()
        for copter in quadcopters:
            copter.draw()


A = 880
AS = 932.33
C = 1046.50
CS = 1108.73
D = 1174.66
SPEED = 500

ugfx.clear(SKIES[level])
ugfx.set_default_font(ugfx.FONT_NAME)
ugfx.text(110, 10, "EMF", ugfx.WHITE)
ugfx.set_default_font(ugfx.FONT_MEDIUM)
ugfx.text(100, 80, "It's unbelievable!", ugfx.WHITE)

ugfx.text(15, 140, "There are too many toys in the skies.", ugfx.WHITE)
ugfx.text(95, 160, "Shoot them down.", ugfx.WHITE)


tone(A, SPEED*0.75, SPEED*0.25)
tone(A, SPEED*0.5, SPEED*0.5)
tone(C, SPEED*0.2, SPEED*0.1)
tone(A, SPEED*0.3, SPEED*0.3)
tone(C, SPEED*0.4, SPEED*0.25)
tone(C, SPEED*0.5, SPEED*0.4)
Exemple #56
0
			buf = file.read(128)
			while len(buf) > 0:
				sha256.update(buf)
				buf = file.read(128)
			return str(binascii.hexlify(sha256.digest()), "utf8")
	except:
		return "ERR"

def download(url, target, expected_hash):
	while True:
		get(url).raise_for_status().download_to(target)
		if calculate_hash(target) == expected_hash:
			break

ugfx.init()
ugfx.clear(ugfx.WHITE)
ugfx.text(5, 5, "Downloading TiLDA software", ugfx.BLACK)
label = ugfx.Label(5, 30, ugfx.width() - 10, ugfx.height() - 60, "Please wait")
ugfx.Label(5, ugfx.height() - 30, ugfx.width() - 10, 30, "If nothing happens for 2 minutes please press the reset button on the back")

w = {}
try:
	if "wifi.json" in os.listdir():
		with open("wifi.json") as f:
			w = json.loads(f.read())
except ValueError as e:
	print(e)

if type(w) is dict:
	# convert original format json (dict, one network) to new (list, many networks)
	w = [w]
Exemple #57
0
def clear():
    ugfx.clear(ugfx.html_color(0x7c1143))
Exemple #58
0
import pyb
import stm
import buttons
import dialogs
from database import *
from filesystem import *
import uio
import sys
import gc
import onboard
from app import *

ugfx.init()
buttons.init()
ugfx.set_default_style(dialogs.default_style_badge)
ugfx.clear(ugfx.html_color(dialogs.default_style_badge.background()))

def update_options(options, category, pinned):
	options.disable_draw()
	apps = get_local_apps(category)
	out = []
	while options.count():
		options.remove_item(0)

	for app in apps:
		if app.get_attribute("built-in") == "hide":
			continue # No need to show the home app

		if app.folder_name in pinned:
			options.add_item("*%s" % app.title)
		else:
Exemple #59
0
### Author: core
### Description: Simple visual morse widget
### Category: morse
### License: MIT
### Appname: cw_flash

import ugfx, pyb, buttons

ugfx.init()
ugfx.clear()
ugfx.area(0,0,320,240,ugfx.html_color(0x00FF00))
buttons.init()
ugfx.set_default_font(ugfx.FONT_NAME)

t4 = pyb.Timer(4, freq=300, mode=pyb.Timer.CENTER)

SIGN_SCALING = 100
DOT = 1
DASH = 3
PAUSE_ELEMENT = DOT
PAUSE_CHARACTER = 3 * DOT - DOT
PAUSE_WORD = 7 * DOT - DOT

AF = True

def dot():
    if AF:
        ch1 = t4.channel(1, pyb.Timer.PWM, pin=pyb.Pin("BUZZ"), pulse_width=(t4.period() + 1) // 2)
    ugfx.area(100,75,90,90,ugfx.BLACK)
    pyb.delay(SIGN_SCALING*DOT)
    if AF: