def install(): easydraw.msg("Installing resources...") if not easywifi.status(): if not easywifi.enable(): return False import woezel woezel.install("resources") appglue.home()
def confirm(ssid, password): term.header(True, "WiFi setup") badge.nvs_set_str("badge", "wifi.ssid", ssid) badge.nvs_set_str("badge", "wifi.password", password) print("New configuration has been saved.") print("") print("SSID:\t\t" + ssid) if len(password) < 1: print("No password") else: print("PASSWORD:\t" + password) print("") print("Press any key to return to the homescreen") sys.stdin.read(1) appglue.home()
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') 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()
def asked_nickname(value): if value: badge.nvs_set_str("owner", "name", value) # Do the firstboot magic newState = 1 if badge.nvs_get_u8('badge', 'setup.state', 0) == 0 else 3 badge.nvs_set_u8('badge', 'setup.state', newState) # Show the user that we are done easydraw.msg("Hi " + value + "!", 'Your nick has been stored to flash!') time.sleep(0.5) else: badge.nvs_set_u8('badge', 'setup.state', 2) # Skip the sponsors badge.nvs_set_u8('sponsors', 'shown', 1) appglue.home()
def app_main(): ugfx.init() clear() ugfx.set_lut(ugfx.LUT_FASTEST) badge.vibrator_init() ugfx.input_attach(ugfx.BTN_A, lambda pressed: badge.vibrator_activate(0xd)) ugfx.input_attach(ugfx.BTN_START, lambda pressed: appglue.home()) loop()
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)
splash = splash[7:len(splash)] badge.mount_sdcard() def back_button_default_action(pressed): if pressed: esp.rtcmem_write_string("") machine.deepsleep(1) ugfx.input_attach(ugfx.BTN_B, back_button_default_action) __import__(splash) else: ugfx.clear(ugfx.WHITE) ugfx.flush(ugfx.LUT_FULL) except BaseException as e: sys.print_exception(e) import easydraw easydraw.msg("", "Fatal exception", True) # if we started the splash screen and it is not the default splash screen, # then revert to original splash screen. if splash == badge.nvs_get_str('boot', 'splash', 'splash') and splash != 'splash': print(">> Restored default splashscreen! <<") badge.nvs_erase_key('boot', 'splash') easydraw.msg(str(e)) import time time.sleep(5) import appglue appglue.home()
def action_exit(pushed): if (pushed): appglue.home()
def home(pressed): if pressed: appglue.home()
def exit(p): if p: appglue.home()
def input_home(pressed): pm.feed() if pressed: appglue.home()
def pm_cb(dummy): appglue.home()
def goToSleep(unused_variable=None): appglue.home()
def home(): if not EMULATOR: appglue.home() else: print("Emulator: home() does nothing")
def home(pushed): if (pushed): appglue.home()
def btn_home(pressed): if pressed: appglue.home()
def home(): appglue.home()
def exit_app(): log('+ Exiting app...') appglue.home()
import urequests, appglue, ugfx, badge, easydraw, wifi, time easydraw.msg('', 'waiting for wifi') wifi.init() while not wifi.sta_if.isconnected(): time.sleep(0.1) req = urequests.get('') ugfx.clear() badge.eink_png(0, 0, req.content) ugfx.flush() req.close() while True: ugfx.input_attach(ugfx.BTN_SELECT, lambda x: appglue.home() if x else '')
"Roboto_BlackItalic22", ugfx.BLACK) ugfx.flush() def fire_gun(round, bullet): print(str('round ') + str(round) + str(' vs ') + str(bullet)) if bullet == round: ugfx.clear(ugfx.WHITE) badge.png(0, 0, '/lib/russian_roulette_9000/shot.png') ugfx.flush() time.sleep(4.0) ugfx.clear(ugfx.WHITE) ugfx.string(0, 30, lost_text, big_font, ugfx.BLACK) ugfx.flush() time.sleep(4.0) reset_game() else: ugfx.clear(ugfx.WHITE) ugfx.string(10, 20, click_text, big_font, ugfx.BLACK) ugfx.flush() time.sleep(1.0) print_start() badge.init() ugfx.init() ugfx.input_init() ugfx.input_attach(ugfx.BTN_START, lambda pressed: fire_button(pressed, bullet)) ugfx.input_attach(ugfx.BTN_B, lambda pressed: appglue.home()) reset_game()
def asked_nickname(value): if value: badge.nvs_set_str("owner", "name", value) appglue.home()
if self.delay > 10 and button_pressed: self.delay -= 10 def press_up(self, button_pressed): if self.delay < 1000 and button_pressed: self.delay += 10 def press_left(self, button_pressed): if button_pressed: self.change_color(False) def press_right(self, button_pressed): if button_pressed: self.change_color(True) def main(): strobonator = Strobonator() ugfx.input_attach(ugfx.BTN_START, strobonator.press_start) ugfx.input_attach(ugfx.JOY_UP, strobonator.press_up) ugfx.input_attach(ugfx.JOY_DOWN, strobonator.press_down) ugfx.input_attach(ugfx.JOY_LEFT, strobonator.press_left) ugfx.input_attach(ugfx.JOY_RIGHT, strobonator.press_right) ugfx.input_init() ugfx.input_attach(ugfx.BTN_B, lambda pushed: appglue.home() if pushed else False) _thread.start_new_thread(main, ())
def go_home(pushed): if (pushed): appglue.home()