Ejemplo n.º 1
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)
        return [(ap[0].decode("utf-8", "ignore"), ap[5]) for ap in ap_result]

def prompt_message(message):
        rgb.clear()
        rgb.framerate(20)
        rgb.setfont(rgb.FONT_7x5)
        uinterface.skippabletext(message)

def ap_requires_password(ap_type):
        return "OPEN" != ap_type

ap_list = scan_access_point_list()
ssids = [ap[0] for ap in ap_list]
prompt_message("Select network")

choice = uinterface.menu(ssids)
if not (choice is None):
        chosen_ssid, chosen_ap_type = ap_list[choice]

        pw_required = ap_requires_password(chosen_ap_type)
        if pw_required:
                prompt_message("Enter password")

        chosen_pass = uinterface.text_input() if pw_required else ''
        if not pw_required or chosen_pass:
                # For OTA
                nvs = esp32.NVS("system")
                nvs.set_blob("wifi.ssid", chosen_ssid)
                nvs.set_blob("wifi.password", chosen_pass)
                nvs.commit()
                # For apps
    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'])
Ejemplo n.º 4
0
    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)


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))


while True:
    function_index = uinterface.menu(
        ['Choose slider apps', 'Set app slide time'])

    if function_index == 0:
        choose_apps()
    elif function_index == 1:
        set_slider_time()
    else:
        # B was pressed
        system.reboot()

    time.sleep(0.01)
Ejemplo n.º 5
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()