def uninstall():
	global options
	selected = options.selected_index()
	options.destroy()
	
	global currentListTitles
	global currentListTargets
		
	if currentListTargets[selected]["category"] == "system":
		easydraw.messageCentered("Can not uninstall.\nSystem apps can not be removed!",False)
		time.sleep(2)
		start()
		return
	
	def perform_uninstall(ok):
		global install_path
		if ok:
			easydraw.msg("Removing "+currentListTitles[selected]+"...", "Uninstalling...",True)
			install_path = get_install_path()
			for rm_file in os.listdir("%s/%s" % (install_path, currentListTargets[selected]["file"])):
				easydraw.msg("Deleting '"+rm_file+"'...")
				os.remove("%s/%s/%s" % (install_path, currentListTargets[selected]["file"], rm_file))
			easydraw.msg("Deleting folder...")
			os.rmdir("%s/%s" % (install_path, currentListTargets[selected]["file"]))
			easydraw.msg("Uninstall completed!")
		start()

	dialogs.prompt_boolean('Are you sure you want to remove %s?' % currentListTitles[selected], cb=perform_uninstall, title="UNINSTALL")
Exemple #2
0
def uninstall():
    global options
    selected = options.selected_index()
    options.destroy()
    
    global currentListTitles
    global currentListTargets
        
    if currentListTargets[selected]["category"] == "system":
        #dialogs.notice("System apps can not be removed!","Can not uninstall '"+currentListTitles[selected]+"'")
        easydraw.msg("System apps can not be removed!","Error",True)
        time.sleep(2)
        start()
        return
    
    def perform_uninstall(ok):
        global install_path
        if ok:
            easydraw.msg("Removing "+currentListTitles[selected]+"...", "Removing...",True)
            install_path = get_install_path()
            for rm_file in os.listdir("%s/%s" % (install_path, currentListTargets[selected]["file"])):
                easydraw.msg("Deleting '"+rm_file+"'...")
                os.remove("%s/%s/%s" % (install_path, currentListTargets[selected]["file"], rm_file))
            easydraw.msg("Deleting folder...")
            os.rmdir("%s/%s" % (install_path, currentListTargets[selected]["file"]))
            easydraw.msg("Uninstall completed!")
        start()
	easydraw.msg("","Uninstall",True)
    dialogs.prompt_boolean('Remove %s?' % currentListTitles[selected], cb=perform_uninstall)
Exemple #3
0
def show_std():
    ugfx.display_image(0, 0, LOCAL_FOLDER % "main.gif")
    dialogs.prompt_boolean("Did you have STDs?", title=APP_TITLE)
    ugfx.display_image(0, 0, LOCAL_FOLDER % "main.gif")

    with dialogs.WaitingMessage("Please wait a moment.", title="Processing..."):
        sleep.sleep_ms(6000)

    show_next_step()
Exemple #4
0
def uninstall():
	global options
	selected = options.selected_index()
	options.destroy()
	
	global currentListTitles
	global currentListTargets
		
	if currentListTargets[selected]["category"] == "system":
		#print("System apps can not be removed.")
		dialogs.notice("Can not uninstall '"+currentListTitles[selected]+"'!\nSystem apps can not be removed!","UNINSTALL")
		#easydraw.msg("System apps can not be removed!","Error",True)
		#time.sleep(2)
		#print("Returning to menu.")
		start()
		return
	
	def perform_uninstall(ok):
		global install_path
		if ok:
			easydraw.msg("Removing "+currentListTitles[selected]+"...", "Uninstalling...",True)
			install_path = "/lib" #FIXME
			for rm_file in os.listdir("%s/%s" % (install_path, currentListTargets[selected]["file"])):
				easydraw.msg("Deleting '"+rm_file+"'...")
				os.remove("%s/%s/%s" % (install_path, currentListTargets[selected]["file"], rm_file))
			easydraw.msg("Deleting folder...")
			os.rmdir("%s/%s" % (install_path, currentListTargets[selected]["file"]))
			easydraw.msg("Uninstall completed!")
		start()

	uninstall = dialogs.prompt_boolean('Are you sure you want to remove %s?' % currentListTitles[selected], cb=perform_uninstall, title="UNINSTALL")
Exemple #5
0
def store_details(category, app):
    clear()
    empty_local_app_cache()
    with dialogs.WaitingMessage(text="Fetching app information...", title="TiLDA App Library"):
        app.fetch_api_information()

    clear()
    if dialogs.prompt_boolean(app.description, title = str(app), true_text = "Install", false_text="Back"):
        install(app)
        dialogs.notice("%s has been successfully installed" % app)
Exemple #6
0
def connect(wait=True,
            timeout=10,
            show_wait_message=False,
            prompt_on_fail=True,
            dialog_title='TiLDA'):
    retry_connect = True

    while retry_connect:
        if nic().is_connected():
            return

        details = connection_details()
        if not details:
            if prompt_on_fail:
                choose_wifi(dialog_title=dialog_title)
            else:
                raise OSError("No valid wifi configuration")

        if not wait:
            connect_wifi(details, timeout=None, wait=False)
            return
        else:
            try:
                if show_wait_message:
                    with dialogs.WaitingMessage(
                            text="Connecting to '%s'...\n(%ss timeout)" %
                        (details['ssid'], timeout),
                            title=dialog_title):
                        connect_wifi(details, timeout=timeout, wait=True)
                else:
                    connect_wifi(details, timeout=timeout, wait=True)
            except OSError:
                if prompt_on_fail:
                    retry_connect = dialogs.prompt_boolean(
                        text="Failed to connect to '%s'" % details['ssid'],
                        title=dialog_title,
                        true_text="Try again",
                        false_text="Forget it",
                    )
                    if not retry_connect:
                        os.remove('wifi.json')
                        os.sync()
                        # We would rather let you choose a new network here, but
                        # scanning doesn't work after a connect at the moment
                        pyb.hard_reset()
                else:
                    raise
Exemple #7
0
def connect(wait=True,
            timeout=10,
            show_wait_message=False,
            prompt_on_fail=True,
            dialog_title='TiLDA'):
    while True:
        if nic().isconnected():
            return

        details = connection_details()
        if not details:
            if prompt_on_fail:
                choose_wifi(dialog_title=dialog_title)
            else:
                raise OSError("No valid wifi configuration")

        if not wait:
            connect_wifi(details, timeout=None, wait=False)
            return
        else:
            try:
                if show_wait_message:
                    with dialogs.WaitingMessage(
                            text="Connecting to '%s'...\n(%ss timeout)" %
                        (details['ssid'], timeout),
                            title=dialog_title):
                        connect_wifi(details, timeout=timeout, wait=True)
                else:
                    connect_wifi(details, timeout=timeout, wait=True)
            except OSError:
                if prompt_on_fail:
                    retry_connect = dialogs.prompt_boolean(
                        text="Failed to connect to '%s'" % details['ssid'],
                        title=dialog_title,
                        true_text="Try again",
                        false_text="Change it",
                    )
                    if not retry_connect:
                        os.remove('wifi.json')
                        os.sync()

                else:
                    raise
Exemple #8
0
def connect(wait=True, timeout=10, show_wait_message=False, prompt_on_fail=True, dialog_title='TiLDA'):
    retry_connect = True

    while retry_connect:
        if nic().is_connected():
            return

        details = connection_details()
        if not details:
            if prompt_on_fail:
                choose_wifi(dialog_title=dialog_title)
            else:
                raise OSError("No valid wifi configuration")

        if not wait:
            connect_wifi(details, timeout=None, wait=False)
            return
        else:
            try:
                if show_wait_message:
                    with dialogs.WaitingMessage(text="Connecting to '%s'...\n(%ss timeout)" % (details['ssid'], timeout), title=dialog_title):
                        connect_wifi(details, timeout=timeout, wait=True)
                else:
                    connect_wifi(details, timeout=timeout, wait=True)
            except OSError:
                if prompt_on_fail:
                    retry_connect = dialogs.prompt_boolean(
                        text="Failed to connect to '%s'" % details['ssid'],
                        title=dialog_title,
                        true_text="Try again",
                        false_text="Forget it",
                    )
                    if not retry_connect:
                        os.remove('wifi.json')
                        os.sync()
                        # We would rather let you choose a new network here, but
                        # scanning doesn't work after a connect at the moment
                        pyb.hard_reset()
                else:
                    raise
Exemple #9
0
sty_tb.set_enabled([
    ugfx.WHITE,
    ugfx.html_color(0xA66FB0),
    ugfx.html_color(0x5e5e5e), ugfx.RED
])
sty_tb.set_background(ugfx.html_color(0xA66FB0))

orientation = ugfx.orientation()

with Database() as db:
    if not db.get("home_firstrun"):
        stats_upload = dialogs.prompt_boolean(
            """Press menu to see all the available apps and download more.

This badge can occasionally send anonymous sensor data via the BARMS app powered by Microsoft. See the badge wiki for more information. Are you OK with that?
		""",
            title="Welcome to EMF camp!",
            true_text="That's OK",
            false_text="Please don't",
            width=320,
            height=240)
        db.set("home_firstrun", True)
        db.set("stats_upload", stats_upload)


def home_main():
    global orientation, next_tick, tick

    ugfx.area(0, 0, 320, 240, sty_tb.background())

    ugfx.set_default_font(ugfx.FONT_MEDIUM)
    win_bv = ugfx.Container(0, 0, 80, 25, style=sty_tb)
Exemple #10
0
			pyb.delay(1)


onboard.hide_splash_on_next_boot(False)

ugfx.set_default_style(dialogs.default_style_badge)

sty_tb = ugfx.Style(dialogs.default_style_badge)
sty_tb.set_enabled([ugfx.WHITE, ugfx.html_color(0xA66FB0), ugfx.html_color(0x5e5e5e), ugfx.RED])
sty_tb.set_background(ugfx.html_color(0xA66FB0))

orientation = ugfx.orientation()

with Database() as db:
	if not db.get("home_firstrun"):
		stats_upload = dialogs.prompt_boolean("""Press menu to see all the available apps and download more.""", title="Welcome to the EMF camp badge!", true_text="OK", false_text = None, width = 320, height = 240)
		db.set("home_firstrun", True)
		db.set("stats_upload", stats_upload)

def home_main():
	global orientation, next_tick, tick

	ugfx.area(0,0,320,240,sty_tb.background())

	ugfx.set_default_font(ugfx.FONT_MEDIUM)
	win_bv = ugfx.Container(0,0,80,25, style=sty_tb)
	win_wifi = ugfx.Container(82,0,60,25, style=sty_tb)
	win_name = ugfx.Container(0,25,320,240-25-60, style=dialogs.default_style_badge)
	win_text = ugfx.Container(0,240-60,320,60, style=sty_tb)

	windows = [win_bv, win_wifi, win_text]
Exemple #11
0
sty_tb = ugfx.Style(dialogs.default_style_badge)
sty_tb.set_enabled([
    ugfx.WHITE,
    ugfx.html_color(0xA66FB0),
    ugfx.html_color(0x5e5e5e), ugfx.RED
])
sty_tb.set_background(ugfx.html_color(0xA66FB0))

orientation = ugfx.orientation()

with Database() as db:
    if not db.get("home_firstrun"):
        stats_upload = dialogs.prompt_boolean(
            """Press menu to see all the available apps and download more.""",
            title="Welcome to the EMF camp badge!",
            true_text="A: OK",
            false_text=None,
            width=320,
            height=240)
        db.set("home_firstrun", True)
        db.set("stats_upload", stats_upload)


def home_main():
    global orientation, next_tick, tick

    ugfx.area(0, 0, 320, 240, sty_tb.background())

    ugfx.set_default_font(ugfx.FONT_MEDIUM)
    win_bv = ugfx.Container(0, 0, 80, 25, style=sty_tb)
    win_wifi = ugfx.Container(82, 0, 60, 25, style=sty_tb)
Exemple #12
0

onboard.hide_splash_on_next_boot(False)

ugfx.set_default_style(dialogs.default_style_badge)

sty_tb = ugfx.Style(dialogs.default_style_badge)
sty_tb.set_enabled([ugfx.WHITE, ugfx.html_color(0xA66FB0), ugfx.html_color(0x5e5e5e), ugfx.RED])
sty_tb.set_background(ugfx.html_color(0xA66FB0))

orientation = ugfx.orientation()

with Database() as db:
	if not db.get("home_firstrun"):
		stats_upload = dialogs.prompt_boolean("""Press menu to see all the available apps and download more.

This badge can occasionally send anonymous sensor data via the BARMS app powered by Microsoft. See the badge wiki for more information. Are you OK with that?
		""", title="Welcome to EMF camp!", true_text="That's OK", false_text="Please don't", width = 320, height = 240)
		db.set("home_firstrun", True)
		db.set("stats_upload", stats_upload)

def home_main():
	global orientation, next_tick, tick

	ugfx.area(0,0,320,240,sty_tb.background())

	ugfx.set_default_font(ugfx.FONT_MEDIUM)
	win_bv = ugfx.Container(0,0,80,25, style=sty_tb)
	win_wifi = ugfx.Container(82,0,60,25, style=sty_tb)
	win_name = ugfx.Container(0,25,320,240-25-60, style=dialogs.default_style_badge)
	win_text = ugfx.Container(0,240-60,320,60, style=sty_tb)
Exemple #13
0
""" Catalin's App
"""
___title___ = "Catalin's App"
___license___ = "MIT"
___dependencies___ = ["ugfx_helper", "sleep", "dialogs", "database"]
___categories___ = ["Other"]
___bootstrapped___ = False

import dialogs, ugfx_helper, ugfx, app, sleep
from tilda import Buttons

# initialize screen
ugfx_helper.init()
ugfx.clear()

# show text
ugfx.text(5, 5, "Hello World :)", ugfx.BLACK)

# waiting until a button has been pressed
while (not Buttons.is_pressed(Buttons.BTN_A)) and (not Buttons.is_pressed(
        Buttons.BTN_B)) and (not Buttons.is_pressed(Buttons.BTN_Menu)):
    sleep.wfi()

# closing
ugfx.clear()

dialogs.prompt_boolean("Is this a great device Y/N? :D")

app.restart_to_default()
Exemple #14
0
			count = surrounding(x, y)
			if grid[y][x]:
				grid_next[y][x] = count > 1 and count < 4
			else:
				grid_next[y][x] = count == 3
	for y in range(h):
		for x in range(w):
			grid[y][x] = grid_next[y][x]


## Running the main code

playing = dialogs.prompt_boolean("""
button A\t: next step
button B\t: run/pause
joystick\t: resets the game
menu\t: quits app
Shall we play a game professor Falken?
""", title='Conway\'s Game of Life', true_text="Play", false_text="Quit")

random_grid()
draw_grid()


running = False

while playing:
	while True:
		# pyb.wfi() # Some low power stuff
		if buttons.is_triggered('BTN_A'):
			update()
    lives = 3
    redraw_whole_bg()
    award_points(0)
    move_crosshair(0, 0)
    while lives >= 0:
        if buttons.is_pressed("BTN_MENU"):
            break
        if buttons.is_pressed("JOY_LEFT"):
            move_crosshair(-5, 0)
        if buttons.is_pressed("JOY_RIGHT"):
            move_crosshair(5, 0)
        if buttons.is_pressed("JOY_UP"):
            move_crosshair(0, -5)
        if buttons.is_pressed("JOY_DOWN"):
            move_crosshair(0, 5)
        if buttons.is_pressed("JOY_CENTER") or buttons.is_pressed("BTN_A") or buttons.is_pressed("BTN_B"):
            shoot()
        if pyb.millis() > next_change:
            next_change = pyb.millis() + SCREEN_DURATION
            frame_times.append(pyb.millis())
            frame_times = frame_times[-50:]
            #print(pixels)
            #pixels = 0
            animate_quadcopters()
        if pyb.millis() > next_enemy:
            spawn_enemy()
            next_enemy = pyb.millis () + ENEMY_FREQUENCY - (level * 300)
        maybe_advance_level()
        refresh_score()
    playing = prompt_boolean("You scored %d. Try again?" % score, title="Game over!")