def connect_wifi(duration=None): if wifi.status(): return True rgb.clear() data, size, frames = animation_connecting_wifi rgb.framerate(3) rgb.gif(data, (12, 0), size, frames) wifi.connect() if duration is not None: wifi.wait(duration=duration) else: wifi.wait() if not wifi.status(): data, frames = icon_no_wifi rgb.gif(data, (12, 0), (8, 8), frames) time.sleep(3) rgb.clear() rgb.framerate(20) del data, size, frames gc.collect() return wifi.status()
def woezel_callback(text, error): global category_stats rgb.clear() rgb.framerate(20) rgb.setfont(rgb.FONT_7x5) print(text) if 'Connecting to WiFi' in text: data, size, frames = animation_connecting_wifi rgb.framerate(3) rgb.gif(data, (12, 0), size, frames) elif 'Failed to connect to WiFi' in text: data, frames = icon_no_wifi rgb.gif(data, (12, 0), (8, 8), frames) time.sleep(3) system.reboot() elif 'Downloading categories...' in text: data, size, frames = animation_loading rgb.gif(data, (1, 1), size, frames) rgb.scrolltext('Loading', pos=(8, 0), width=(rgb.PANEL_WIDTH - 8)) elif 'Installing' in text: data, size, frames = animation_loading rgb.gif(data, (1, 1), size, frames) rgb.scrolltext(text, pos=(8, 0), width=(rgb.PANEL_WIDTH - 8)) elif "Downloading '" in text: cur, total = text.split('(')[1].split(')')[0].split( '/') # Definitely not proud of this progress = '(%s/%s)' % (cur, total) data, size, frames = animation_loading rgb.gif(data, (1, 1), size, frames) rgb.setfont(rgb.FONT_6x3) rgb.text(progress, pos=(8, 1)) elif 'Done!' in text or 'Failed!' in text: pass
def scan_access_point_list(): data, size, frames = animation_connecting_wifi rgb.clear() rgb.framerate(3) rgb.gif(data, (12, 0), size, frames) sta_if = network.WLAN(network.STA_IF) sta_if.active(True) sta_if.disconnect() ap_result = sta_if.scan() return [(ap[0].decode("utf-8", "ignore"), ap[5]) for ap in ap_result]
def animate_wifi(): if not badgehelper.on_badge(): return False from default_icons import animation_connecting_wifi rgb.clear() data, size, frames = animation_connecting_wifi rgb.framerate(3) rgb.gif(data, (12, 0), size, frames)
def animate_no_wifi(): if not badgehelper.on_badge(): return False from default_icons import icon_no_wifi rgb.clear() data, frames = icon_no_wifi rgb.framerate(3) rgb.gif(data, (12, 0), (8, 8), frames) time.sleep(3)
def connect_wifi(): rgb.pixel((255, 255, 0), (31, 0)) # yellow connecting to wifi if not wifi.status(): wifi.connect() if wifi.wait(): rgb.pixel((0, 255, 0), (31, 0)) # green for wifi rgb.framerate(20) else: rgb.clear() rgb.framerate(20) data, frames = icon_no_wifi rgb.image(data, (12, 0), (8, 8)) time.sleep(3) rgb.clear() machine.reboot()
def connect_wifi(): if wifi.status(): return True rgb.clear() data, size, frames = animation_connecting_wifi rgb.framerate(3) rgb.gif(data, (12, 0), size, frames) wifi.connect() wifi.wait() if not wifi.status(): data, frames = icon_no_wifi rgb.gif(data, (12, 0), (8, 8), frames) time.sleep(3) rgb.clear() rgb.framerate(20) return wifi.status()
def woezel_callback(text, error): global category_stats rgb.clear() rgb.framerate(20) rgb.setfont(rgb.FONT_7x5) print(text) if 'Connecting to WiFi' in text: data, size, frames = animation_connecting_wifi rgb.framerate(3) rgb.gif(data, (12, 0), size, frames) elif 'Failed to connect to WiFi' in text: data, frames = icon_no_wifi rgb.gif(data, (12, 0), (8, 8), frames) time.sleep(3) system.reboot() elif 'Done!' in text or 'Failed!' in text: return else: data, size, frames = animation_loading rgb.gif(data, (1, 1), size, frames) rgb.scrolltext(text, pos=(8, 0), width=(rgb.PANEL_WIDTH - 8))
def prompt_message(message): rgb.clear() rgb.framerate(20) rgb.setfont(rgb.FONT_7x5) uinterface.skippabletext(message)
import uinterface, urequests, ujson, ntp, rgb, wifi, buttons, defines, system, machine, gc from default_icons import animation_connecting_wifi, icon_no_wifi from time import sleep rgb.background((0, 0, 0)) rgb.clear() rgb.framerate(20) WEATHER_API_SERVER = 'https://api.openweathermap.org/data/2.5/weather?id=2745726&mode=json&units=metric&appid=100135c6eb0eeba9bde50e165d4021c1' action = 0 weather = None last_update = 0 tick = 0 REFRESH_RATE = 31 rgb.setfont(0) def disconnect_wifi(): if wifi.status(): wifi.disconnect() rgb.pixel((255, 0, 0), (31, 0)) # red for no wifi def connect_wifi(): rgb.pixel((255, 255, 0), (31, 0)) # yellow connecting to wifi if not wifi.status(): wifi.connect()
import time, ntp, rgb, wifi, buttons, defines, system, machine from default_icons import animation_connecting_wifi, icon_no_wifi direction = 0 if not ntp.local_time_available(): if not wifi.status(): data, size, frames = animation_connecting_wifi rgb.clear() rgb.framerate(3) rgb.gif(data, (12, 0), size, frames) wifi.connect() if wifi.wait(): rgb.clear() rgb.framerate(20) else: print('No wifi') rgb.clear() rgb.framerate(20) data, frames = icon_no_wifi rgb.image(data, (12, 0), (8, 8)) time.sleep(3) rgb.clear() print("Error connecting to wifi") system.reboot() if not ntp.set_NTP_time(): print("Error setting time") system.reboot() wifi.disconnect()
def animate_end(): if badgehelper.on_badge(): rgb.clear() rgb.framerate(20)
def _initialize_display(): rgb.clear() rgb.setfont(_FONT) rgb.framerate(_MAIN_FRAMERATE)
def _initialize_display(): rgb.clear() rgb.framerate(20) rgb.setfont(FONT)
import machine, system, term_menu, virtualtimers, tasks.powermanagement as pm, buttons, defines, woezel import rgb saplings = [0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x51feb2ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x51feb2ff, 0x000000ff, 0x000000ff] def input_left(pressed): pm.feed() if pressed: rgb.setbrightness(rgb.getbrightness() - 2) def input_right(pressed): pm.feed() if pressed: rgb.setbrightness(rgb.getbrightness() + 2) buttons.register(defines.BTN_LEFT, input_left) buttons.register(defines.BTN_RIGHT, input_right) rgb.clear() rgb.framerate(2) rgb.gif(saplings, (0, 0), (32, 8), 3)
for i, d in enumerate(l): rgb.text(d, colors[color][i], (ceil(31 / len(l)) * i, 0)) else: rgb.text('E Data') # init buttons.register(UP, input_up) buttons.register(DOWN, input_down) buttons.register(LEFT, input_left) buttons.register(RIGHT, input_right) buttons.register(B, input_B) buttons.register(A, input_A) rgb.setfont(rgb.FONT_6x3) rgb.framerate(10) # second updates REFRESH_RATE = 31 # times framerate updates. # wifi connect if not wifi.status(): if not uinterface.connect_wifi(): system.reboot() rgb.text('Hi!') # main loop count = REFRESH_RATE - 1 # start fast while True: if not wifi.status(): if not uinterface.connect_wifi(): system.reboot()