def set_nickname():
    rgb.clear()
    uinterface.skippabletext('Set nickname:')
    new_name = uinterface.text_input()
    if new_name is not None and new_name != '':
        machine.nvs_setstr('badge', 'nickname', new_name)
    system.start('nickname')
def uninstall(app):
    if app["category"] == "system":
        # dialogs.notice("System apps can not be removed!","Can not uninstall '"+currentListTitles[selected]+"'")
        rgb.clear()
        uinterface.skippabletext("System apps can't be removed")
        render_current_app()
        return

    machine.nvs_setstr('launcher', 'uninstall_name', app['title'])
    machine.nvs_setstr('launcher', 'uninstall_file', app['file'])
    system.start('uninstall')
def uninstall(app):
    global nvs
    if app["category"] == "system":
        # dialogs.notice("System apps can not be removed!","Can not uninstall '"+currentListTitles[selected]+"'")
        rgb.clear()
        uinterface.skippabletext("System apps can't be removed")
        render_current_app()
        return

    nvs.set_blob('uninstall_name', app['title'])
    nvs.set_blob('uninstall_file', app['file'])
    nvs.commit()
    system.start('uninstall')
Beispiel #4
0
def choose_apps():
    try:
        userApps = os.listdir('apps')
        userApps.reverse()
    except OSError:
        userApps = []
    apps = userApps
    apps.extend(['snake', 'clock', 'nickname'])
    prev_selected = store.load('slider', 'apps') or []
    uinterface.skippabletext('< > (de)select, A accept, B cancel')
    selected = uinterface.menu(apps, selected=prev_selected)
    if selected is not None:
        store.save('slider', 'apps', selected)
Beispiel #5
0
def show_names():
    global names
    c = False
    y = 10

    term.header(True, "About")
    print("Developers:")
    for n in range(0, len(names)):
        if (names[n] == " "):
            break
        print(" - " + names[n])

    rgb.clear()
    rgb.scrolltext("Your badge was made possible by:")
    time.sleep(10)

    for n in range(0, len(names)):
        rgb.clear()
        uinterface.skippabletext(names[n])

    rgb.clear()
    rgb.scrolltext("Press A or B to quit")
Beispiel #6
0
def main():
    try:
        _initialize_display()
        latest_update = _retrieve_latest_update()
        if _prompt_user_for_update(latest_update["name"], latest_update["build"]):
            uinterface.skippabletext("Starting update")
            system.ota()
        else:
            uinterface.skippabletext("Cancelled OTA update")

    except Exception as e:
        uinterface.skippabletext(str(e))
    # Make snake loop from one border to the other
    new_x %= rgb.PANEL_WIDTH
    new_y %= rgb.PANEL_HEIGHT
    snake.insert(0, (new_x, new_y))

    # If snake bites itself, the game's over
    if snake[0] in snake[1:]:
        print('dead')
        break

    if snake[0] == food:
        # Snake eats the food
        food = []
        score += 1

        # Spawn new food
        while food == []:
            food = (randint(0, rgb.PANEL_WIDTH - 1),
                    randint(0, rgb.PANEL_HEIGHT - 1))
            if food in snake: food = []
    else:
        # Remove last entry from tail (snake didn't grow)
        last = snake.pop()

    render()
    sleep(0.2)
    can_move = True

rgb.clear()
uinterface.skippabletext("Score - " + str(score))
system.reboot()
    rgb.framerate(3)
    rgb.gif(data, (12, 0), size, frames)

    del data, size, frames, animation_connecting_wifi
    gc.collect()
    wifi.wait()
    wifi.connect()
    wifi.wait()

    if not wifi.status():
        data, frames = icon_no_wifi
        rgb.gif(data, (12, 0), (8, 8), frames)
        time.sleep(3)
        system.reboot()
    ###

    rgb.clear()
    rgb.framerate(20)
    uinterface.loading_text('Installing %s' % to_install)
    del icon_no_wifi
    gc.collect()
    if woezel.install(to_install):
        # Reset launcher's selected index to newly installed app
        machine.nvs_setint('launcher', 'index', 0)
        rgb.clear()
        uinterface.skippabletext('Install succeeded')
    else:
        rgb.clear()
        uinterface.skippabletext('Failed to install "%s"' % to_install)

    system.reboot()
    print("Updating cache failed.")
    wifi.disconnect()
    gc.collect()
    uinterface.connect_wifi()
    retry -= 1
    if retry == 0:
        print("This is not ok, rebooting")
        system.reboot()

categories = woezel.get_categories()
active_categories = [cat for cat in categories if cat['eggs'] > 0]

if len(active_categories) == 0:
    rgb.clear()
    rgb.framerate(20)
    uinterface.skippabletext('Error loading')
    system.start("appstore")

while True:
    chosen_index = uinterface.menu([app['name'] for app in active_categories])
    if chosen_index is None:
        system.reboot()
    category = active_categories[chosen_index]

    apps = woezel.get_category(category['slug'])
    chosen_index = uinterface.menu([app['name'] for app in apps])
    if chosen_index is None:
        continue
    app = apps[chosen_index]

    uinstaller.install(app['slug'])
    print("Updating cache failed.")
    wifi.disconnect()
    gc.collect()
    uinterface.connect_wifi()
    retry -= 1
    if retry == 0:
        print("This is not ok, rebooting")
        system.reboot()

categories = woezel.get_categories()
active_categories = [cat for cat in categories if cat['eggs'] > 0]

if len(active_categories) == 0:
    rgb.clear()
    rgb.framerate(20)
    uinterface.skippabletext('Error loading')
    system.start("appstore")

while True:
    chosen_index = uinterface.menu([app['name'] for app in active_categories])
    if chosen_index is None:
        system.reboot()
    category = active_categories[chosen_index]

    apps = woezel.get_category(category['slug'])
    chosen_index = uinterface.menu([app['name'] for app in apps])
    if chosen_index is None:
        continue
    app = apps[chosen_index]

    # WiFi could have been disconnected by now
Beispiel #11
0
def skippabletext(text, color=(255, 255, 255), pos=None, width=-1):
    return uinterface.skippabletext(text, color=color, pos=pos, width=width)
import system, time, uos as os, gc
import woezel, rgb, uinterface

if not uinterface.connect_wifi():
    print("Error connecting to wifi")
    system.reboot()

try:
    apps = os.listdir('apps')
except OSError:
    apps = []

rgb.clear()
uinterface.loading_text('Updating:')
time.sleep(4)

for app in apps:
    rgb.clear()
    uinterface.loading_text(app)
    gc.collect()
    woezel.install(app)

rgb.clear()
uinterface.skippabletext('Done updating')
system.reboot()
Beispiel #13
0
    menu = []
    rgb.clear()
    # if not daysindex in days or 'date' not in days[daysindex]:
    #     system.start('activities')
    rgb.text(days[daysindex]['date'], (0, 255, 255), (6, 1))
    rgb.setfont(rgb.FONT_6x3)
    utime.sleep(0.5)
    for event in days[daysindex]['events']:
        time_utc = int(event['time'])
        time_local = time_utc + 60 * 60 * 2
        hour = str(utime.localtime(time_local)[3])
        minute = str(utime.localtime(time_local)[4])
        if len(minute) != 2:
            minute = '0' + minute

        menu.append(hour + ':' + minute + ' ' + event['name'])
    eventindex = uinterface.menu(menu, 0, call_left, call_right)
    print(eventindex)
    if eventindex != None:
        event = days[daysindex]['events'][eventindex]
        eventtext = 'Type: ' + eventtype[int(event['type'])]
        eventtext += ' - Location: ' + event['location']

        rgb.clear()
        rgb.scrolltext(eventtext, (255, 0, 0), (0, 0))
        uinterface.skippabletext(eventtext)
    elif has_switched:
        has_switched = False
    else:
        system.reboot()
def cbSleep(_):
    rgb.clear()
    term.header(True, "Going to sleep...")
    uinterface.skippabletext('ZzZz')
    buttons.register(defines.BTN_UP, input_up)
    buttons.register(defines.BTN_DOWN, input_down)
    buttons.register(defines.BTN_LEFT, input_left)
    buttons.register(defines.BTN_RIGHT, input_right)

    populate_apps()
    render_current_app()


start()
init_power_management()

# Install CZ countdown app to replace activities app
if not machine.nvs_getint('system', 'czcount_inst'):
    import uinterface
    if uinterface.connect_wifi():
        import woezel
        uinterface.loading_text('Installing CZ20 countdown')
        if woezel.is_installed('campzone_2020_countdown') or woezel.install(
                'campzone_2020_countdown'):
            machine.nvs_setint('system', 'czcount_inst', 1)
            system.reboot()
        else:
            rgb.clear()
            uinterface.skippabletext('Installation failed')

    render_current_app()

menu = term_menu.UartMenu(deepsleep.start_sleeping, pm)
menu.main()
Beispiel #16
0
def set_slider_time():
    uinterface.skippabletext('Set seconds to show each app')
    seconds = uinterface.text_input(uinterface.NUMERIC_CHARSET)
    if seconds is not None and seconds != '':
        store.save('slider', 'time', int(seconds))
import uos as os, time, machine, system
import uinterface, woezel, rgb

app = machine.nvs_getstr('launcher', 'uninstall_name')
app_file = machine.nvs_getstr('launcher', 'uninstall_file')

if (not app) or not (app_file):
    system.home()

agreed = uinterface.confirmation_dialog('Uninstall \'%s\'?' % app)
if not agreed:
    system.home()

uinterface.loading_text("Removing " + app + "...")
install_path = woezel.get_install_path()
print(app)
print(app_file)
print(install_path)
for rm_file in os.listdir("%s/%s" % (install_path, app_file)):
    os.remove("%s/%s/%s" % (install_path, app_file, rm_file))
os.rmdir("%s/%s" % (install_path, app_file))

machine.nvs_setstr('launcher', 'uninstall_name', '')
machine.nvs_setstr('launcher', 'uninstall_file', '')

rgb.clear()
uinterface.skippabletext("Uninstall completed!")
system.home()

def mqtt_cb(topic, msg):
    print("New MQTT msg")
    rgb.clear()
    uinterface.skippabletext(msg)


uinterface.connect_wifi()

import valuestore
settings = valuestore.load('mqttclient', 'settings')
if settings is None:
    settings = {"client_id": "badge"}
if "mqtt_server" not in settings:
    uinterface.skippabletext("Specify MQTT host")
    settings["mqtt_server"] = uinterface.text_input(
        "abcdefghijklmnopqrstuvwxzy.0123456789")
    valuestore.save('mqttclient', 'settings', settings)

client_id = settings['client_id']
try:
    mqttc = MQTTClient(client_id, settings["mqtt_server"])
    mqttc.set_callback(mqtt_cb)
    mqttc.connect()
except:
    # Maybe wrong hostname
    del settings["mqtt_server"]
    valuestore.save('mqttclient', 'settings', settings)
    # Might be something different, rethrow to restart...
    raise
def mqtt_cb(topic, msg):
    print("New MQTT msg")
    rgb.clear()
    uinterface.skippabletext(msg)
def prompt_message(message):
        rgb.clear()
        rgb.framerate(20)
        rgb.setfont(rgb.FONT_7x5)
        uinterface.skippabletext(message)
Beispiel #21
0
import uinterface

uinterface.skippabletext('Recovery mode: attach USB')
print(
    'Recovery mode activated. You can debug your badge via Python shell, and reboot with system.reboot().'
)
__import__('shell')