def draw_logo(x, y, h): ugfx.string(x + 20, y, "STILL", "Roboto_BlackItalic24", ugfx.BLACK) ugfx.string(x, y + 25, h, "PermanentMarker22", ugfx.BLACK) len = ugfx.get_string_width(h, "PermanentMarker22") ugfx.line(x, y + 47, x + 14 + len, y + 47, ugfx.BLACK) ugfx.line(x + 10 + len, y + 27, x + 10 + len, y + 45, ugfx.BLACK) ugfx.string(x + 10, y + 50, "Anyway", "Roboto_BlackItalic24", ugfx.BLACK)
def re_draw(): global scroll, max_scroll print("redraw:"+str(scroll)) ugfx.clear(ugfx.WHITE) y=0 ugfx.string(0, y, "SSID", "pixelade13", ugfx.BLACK) ugfx.string(110, y, "Enc", "pixelade13", ugfx.BLACK) ugfx.string(150, y, "Ch", "pixelade13", ugfx.BLACK) ugfx.string(175, y, "dB", "pixelade13", ugfx.BLACK) ugfx.string(210, y, "BSSID", "pixelade13", ugfx.BLACK) ugfx.string(270, y, '{:d}/{:d}'.format(scroll, max_scroll), "pixelade13", ugfx.BLACK) ugfx.line(0, 12, 296, 12, ugfx.BLACK) y+=15 for net in scanResults[scroll:]: # (ssid, bssid, channel, RSSI, authmode, hidden) # (b'SHA2017-legacy', b"\xa8\xbd'z\xd1\xc0", 1, -55, 5, False) print(net) bssid = ubinascii.hexlify(net[1]).upper() ssid = net[0] if net[5] == True: ssid = "<hidden>" ugfx.string(0, y, '{:40}'.format(ssid), "pixelade13", ugfx.BLACK) ugfx.string(110, y, '{}'.format(encription.get(net[4],"?")), "pixelade13", ugfx.BLACK) ugfx.string(150, y, '{:2d}'.format(net[2]), "pixelade13", ugfx.BLACK) ugfx.string(175, y, '{:3d}'.format(net[3]), "pixelade13", ugfx.BLACK) ugfx.string(210, y, '{:2}:{:2}:{:2}:{:2}:{:2}:{:2}'.format(bssid[0:2],bssid[2:4],bssid[4:6],bssid[6:8],bssid[8:10],bssid[10:12]), "pixelade13", ugfx.BLACK) y += 14 ugfx.flush()
def draw_screen(): loc_data = get_data("https://freegeoip.app/json/") lat = str(loc_data["latitude"]) lon = str(loc_data["longitude"]) city = loc_data["city"] country = loc_data["country_name"] iss_data = get_data("http://api.open-notify.org/iss-pass.json?lat=" + lat + "&lon=" + lon) risetime = iss_data['response'][0]['risetime'] datetime = iss_data['request']['datetime'] countdown = datetime LED(LED.GREEN).off() while countdown < risetime: ugfx.clear(ugfx.BLACK) ugfx.text(5, 5, "When does the ISS next pass?", ugfx.WHITE) ugfx.line(5, 20, ugfx.width(), 20, ugfx.GREY) ugfx.text(5, 35, "Location: " + city + ", " + country, ugfx.WHITE) ugfx.text(5, 50, "Latitude: " + lat, ugfx.WHITE) ugfx.text(5, 65, "Longitude: " + lon, ugfx.WHITE) ugfx.text(5, 80, "Rise time: " + str(get_time(risetime)), ugfx.WHITE) ugfx.text(5, 95, "Duration: " + str(get_seconds(iss_data['response'][0]['duration'])), ugfx.WHITE) countdown +=1 ugfx.text(5, 110, "Countdown: " + str(get_wait(risetime, countdown)), ugfx.WHITE) utime.sleep(1) else: LED(LED.GREEN).on() LED(LED.RED).on() utime.sleep(1) LED(LED.GREEN).off() LED(LED.RED).off() draw_screen()
def draw_screen(): ugfx.clear(ugfx.BLACK) ugfx.text(60, 5, "what's on tap?", ugfx.RED) ugfx.line(5, 20, ugfx.width(), 20, ugfx.GREY) for idx, beer in enumerate(bar['location']): ugfx.text(5, 22 + idx * 15, beer['description'], ugfx.WHITE)
def list_categories(): global options global text global categories try: categories except: ugfx.input_init() draw_msg('Getting categories') try: f = urequests.get("https://badge.team/eggs/categories/json", timeout=30) categories = f.json() except: draw_msg('Failed!') draw_msg('Returning to launcher :(') appglue.start_app('launcher', False) f.close() draw_msg('Done!') options = ugfx.List(0, 0, int(ugfx.width() / 2), ugfx.height()) text = ugfx.Textbox(int(ugfx.width() / 2), 0, int(ugfx.width() / 2), ugfx.height()) ugfx.input_attach(ugfx.JOY_UP, lambda pushed: ugfx.flush() if pushed else False) ugfx.input_attach(ugfx.JOY_DOWN, lambda pushed: ugfx.flush() if pushed else False) ugfx.input_attach(ugfx.BTN_A, select_category) ugfx.input_attach( ugfx.BTN_B, lambda pushed: appglue.start_app("launcher", False) if pushed else False) ugfx.input_attach( ugfx.BTN_START, lambda pushed: appglue.start_app("") if pushed else False) ugfx.clear(ugfx.WHITE) ugfx.flush() while options.count() > 0: options.remove_item(0) for category in categories: options.add_item("%s (%d) >" % (category["name"], category["eggs"])) options.selected_index(0) text.text("Install or update eggs from the hatchery here\n\n\n\n") ugfx.string_box(148, 0, 148, 26, "Hatchery", "Roboto_BlackItalic24", ugfx.BLACK, ugfx.justifyCenter) ugfx.line(148, 78, 296, 78, ugfx.BLACK) ugfx.string_box(148, 78, 148, 18, " A: Open category", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.string_box(148, 92, 148, 18, " B: Return to home", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.line(148, 110, 296, 110, ugfx.BLACK) ugfx.string_box(148, 110, 148, 18, " badge.team", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.flush(ugfx.LUT_FULL) gc.collect()
def wait_sauna(): clear(ugfx.BLACK) ugfx.string(50, 25, "STILL", "Roboto_BlackItalic24", ugfx.WHITE) ugfx.string(30, 50, "Connecting to sauna", "PermanentMarker22", ugfx.WHITE) len = ugfx.get_string_width("Connecting to sauna", "PermanentMarker22") ugfx.line(30, 72, 30 + 14 + len, 72, ugfx.WHITE) ugfx.string(140, 75, "Anyway", "Roboto_BlackItalic24", ugfx.WHITE) ugfx.flush()
def wait_wifi(): clear(ugfx.BLACK) ugfx.string(50, 25, "STILL", "Roboto_BlackItalic24", ugfx.WHITE) ugfx.string(30, 50, "Connecting to wifi", "PermanentMarker22", ugfx.WHITE) len = ugfx.get_string_width("Connecting to wifi", "PermanentMarker22") ugfx.line(30, 72, 30 + 14 + len, 72, ugfx.WHITE) ugfx.string(140, 75, "Anyway", "Roboto_BlackItalic24", ugfx.WHITE) ugfx.flush() while not wifi.sta_if.isconnected(): time.sleep(0.1)
def start(): ugfx.input_init() ugfx.set_lut(ugfx.LUT_FASTER) ugfx.clear(ugfx.WHITE) # Instructions if orientation.isLandscape(): ugfx.line(148, 78, 296, 78, ugfx.BLACK) ugfx.string_box(148, 78, 148, 18, " A: Run", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.string_box(148, 78, 148, 18, " B: Return to home", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyRight) ugfx.string_box(148, 92, 148, 18, " SELECT: Uninstall", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.line(148, 110, 296, 110, ugfx.BLACK) ugfx.string_box(148, 110, 148, 18, " " + version.name, "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) else: ugfx.line(0, ugfx.height() - 18 * 4, ugfx.width(), ugfx.height() - 18 * 4, ugfx.BLACK) ugfx.string_box(0, ugfx.height() - 18 * 4, ugfx.width(), 18, " A: Run", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.string_box(0, ugfx.height() - 18 * 3, ugfx.width(), 18, " B: Return to home", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.string_box(0, ugfx.height() - 18 * 2, ugfx.width(), 18, " SELECT: Uninstall", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.line(0, ugfx.height() - 18 * 1, ugfx.width(), ugfx.height() - 18 * 1, ugfx.BLACK) ugfx.string_box(0, ugfx.height() - 18 * 1, ugfx.width(), 18, " " + version.name, "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) global options global install_path options = None install_path = None ugfx.input_attach(ugfx.BTN_A, input_a) ugfx.input_attach(ugfx.BTN_B, input_b) ugfx.input_attach(ugfx.BTN_SELECT, input_select) ugfx.input_attach(ugfx.JOY_UP, input_other) ugfx.input_attach(ugfx.JOY_DOWN, input_other) ugfx.input_attach(ugfx.JOY_LEFT, input_other) ugfx.input_attach(ugfx.JOY_RIGHT, input_other) ugfx.input_attach(ugfx.BTN_START, input_other) populate_apps() populate_category() populate_options() # do a greyscale flush on start ugfx.flush(ugfx.GREYSCALE)
def tree(point, level, angle, disp): if level > 0: point_new = ( point[0] + int(cos(radians(angle)) * level * 3.2), point[1] + int(sin(radians(angle)) * level * 2.0)) rand_left, rand_right = (uniform(0.5, 1.5), uniform(0.5, 1.5)) if BADGE == SHA17: ugfx.line(point[0], point[1], point_new[0], point_new[1], ugfx.WHITE) elif BADGE == CCC19: p0, p1 = sanitize_point(point), sanitize_point(point_new) disp.line(p0[0], p0[1], p1[0], p1[1], col=(128, 128, 128)) tree(point_new, level - 1, angle - 20 * rand_left, disp) tree(point_new, level - 1, angle + 20 * rand_right, disp)
def cuss(): ## t = easyrtc.string() ugfx.clear(ugfx.WHITE) herp = str(random.choice(first)) ###ugfx.string(x, y, string, font, colour) ugfx.string(10, 5, str(random.choice(first)), "Roboto_BlackItalic24", ugfx.BLACK) ugfx.string(30, 25, str(random.choice(second)), "PermanentMarker36", ugfx.BLACK) len = ugfx.get_string_width(str(random.choice(second)),"PermanentMarker36") ugfx.line(25, 59, 72 + len, 59, ugfx.BLACK) ugfx.string(135, 68, str(random.choice(third)), "Roboto_BlackItalic24", ugfx.BLACK) # ugfx.string(110, 85, str(herp), "PermanentMarker22", ugfx.BLACK) ugfx.string(30, 95, " it's ", "PermanentMarker22", ugfx.BLACK) ## ugfx.string(140, 85, t, "PermanentMarker36", ugfx.BLACK) ugfx.flush() time.sleep(3)
def start(): ugfx.input_init() ugfx.set_lut(ugfx.LUT_FASTER) ugfx.clear(ugfx.BLACK) ugfx.flush() ugfx.clear(ugfx.WHITE) ugfx.flush() ugfx.string_box(148, 0, 148, 26, "STILL", "Roboto_BlackItalic24", ugfx.BLACK, ugfx.justifyCenter) ugfx.string_box(148, 23, 148, 23, "Hacking", "PermanentMarker22", ugfx.BLACK, ugfx.justifyCenter) ugfx.string_box(148, 48, 148, 26, "Anyway", "Roboto_BlackItalic24", ugfx.BLACK, ugfx.justifyCenter) #the line under the text str_len = ugfx.get_string_width("Hacking", "PermanentMarker22") line_begin = 148 + int((148 - str_len) / 2) line_end = str_len + line_begin ugfx.line(line_begin, 46, line_end, 46, ugfx.BLACK) #the cursor past the text cursor_pos = line_end + 5 ugfx.line(cursor_pos, 22, cursor_pos, 44, ugfx.BLACK) # Instructions ugfx.line(148, 78, 296, 78, ugfx.BLACK) ugfx.string_box(148, 78, 148, 18, " A: Run", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.string_box(148, 78, 148, 18, " B: Return to home", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyRight) ugfx.string_box(148, 92, 148, 18, " SELECT: Uninstall", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.line(148, 110, 296, 110, ugfx.BLACK) ugfx.string_box(148, 110, 148, 18, " " + version.name, "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) global options global install_path options = None install_path = None ugfx.input_attach(ugfx.BTN_A, input_a) ugfx.input_attach(ugfx.BTN_B, input_b) ugfx.input_attach(ugfx.BTN_SELECT, input_select) ugfx.input_attach(ugfx.JOY_UP, input_other) ugfx.input_attach(ugfx.JOY_DOWN, input_other) ugfx.input_attach(ugfx.JOY_LEFT, input_other) ugfx.input_attach(ugfx.JOY_RIGHT, input_other) ugfx.input_attach(ugfx.BTN_START, input_other) populate_apps() populate_category() populate_options() ugfx.flush(ugfx.LUT_FULL)
def draw_screen(): global bar, stock ugfx.clear(ugfx.BLACK) ugfx.text(65, 5, "what's on tap?", ugfx.RED) ugfx.line(5, 20, ugfx.width(), 20, ugfx.GREY) for idx, beer in enumerate(bar['location']): remaining = 0 for item in stock['stock']: if item['description'] == beer['description']: remaining = float(item['remaining']) ugfx.text(5, 22 + idx*15, beer['description'][:28], ugfx.WHITE) ugfx.text(202, 22 + idx*15, '!' if (remaining < 30) else ' ', ugfx.RED) ugfx.text(210, 22 + idx*15, "{:>4}".format(beer['price']), ugfx.WHITE)
def go(): ugfx.clear(ugfx.BLACK) draw_name() colors = [ugfx.WHITE, ugfx.GREEN, ugfx.YELLOW, ugfx.BLUE] ci = 0 r = 70 dr = 2 d = 0.0 dd = 0.1 hOffset = 40 while True: if (math.fabs(d) > 4): ugfx.clear(ugfx.BLACK) draw_name() dd = -dd d = 0 ci += 1 if (ci >= len(colors)): ci = 0 px1 = math.floor(width / 2 + r * math.sin(d)) py1 = math.floor(height / 2 + r * math.cos(d) + hOffset) px2 = math.floor(width / 2 + r * math.sin(d + math.pi / 2)) py2 = math.floor(height / 2 + r * math.cos(d + math.pi / 2) + hOffset) px3 = math.floor(width / 2 + r * math.sin(d + math.pi)) py3 = math.floor(height / 2 + r * math.cos(d + math.pi) + hOffset) px4 = math.floor(width / 2 + r * math.sin(d + (math.pi * 1.5))) py4 = math.floor(height / 2 + r * math.cos(d + (math.pi * 1.5)) + hOffset) ugfx.line(px1, py1, px2, py2, colors[ci]) ugfx.line(px3, py3, px2, py2, colors[ci]) ugfx.line(px3, py3, px4, py4, colors[ci]) ugfx.line(px1, py1, px4, py4, colors[ci]) d += dd r += dr if (r > 100): dr = -dr if (r < 30): dr = -dr sleep_or_exit(0.1)
def drawTask(onSleep=False): global gui_redraw, cfg_nickname, gui_apps, gui_app_current, ota_available if gui_redraw or onSleep: gui_redraw = False ugfx.clear(ugfx.WHITE) currHeight = 0 if gui_app_current < 0: if cfg_nickname: currHeight += easydraw.nickname() currHeight += 4 ugfx.line(0, currHeight, ugfx.width(), currHeight, ugfx.BLACK) currHeight += 4 app_height = ugfx.height() - 16 - currHeight logoHeight = drawLogo(currHeight, app_height, True) else: display_app(currHeight) if onSleep: info = 'Sleeping...' #elif badge.safe_mode(): # info = "Recovery mode" #elif not rtc.isSet(): # info = "Clock not set" elif ota_available: info = "Update available!" #elif wifi_status_curr: # info = "WiFi connected" else: info = 'Press START' ugfx.line(0, ugfx.height() - 16, ugfx.width(), ugfx.height() - 16, ugfx.BLACK) easydraw.disp_string_right_bottom(0, info) if len(gui_apps) > 0: drawPageIndicator(len(gui_apps), gui_app_current) ugfx.flush(ugfx.LUT_NORMAL) return 1000
def draw(self): width = 4 height = 8 x = self.x * X_SIZE y = self.y * Y_SIZE # center ugfx.line(x + int(X_SIZE / 2), y, int(x + X_SIZE / 2), y + height, ugfx.WHITE) if self.direction == DIRECTION_UP: # left pix ugfx.line(x + int(X_SIZE / 2) - 1, y + 3, int(x + X_SIZE / 2) - 1, y + height, ugfx.WHITE) # right pix ugfx.line(x + int(X_SIZE / 2) + 1, y + 3, int(x + X_SIZE / 2) + 1, y + height, ugfx.WHITE) elif self.direction == DIRECTION_DOWN: # left pix ugfx.line(x + int(X_SIZE / 2) - 1, y, int(x + X_SIZE / 2) - 1, y + height - 3, ugfx.WHITE) # right pix ugfx.line(x + int(X_SIZE / 2) + 1, y, int(x + X_SIZE / 2) + 1, y + height - 3, ugfx.WHITE) else: raise Exception("Unsupported direction")
def draw(self): # Draws from the x, y location of the plan so that # X is in the left of plane # and Y is to highest pixel. width = 8 height = 12 x = self.x * X_SIZE y = self.y * Y_SIZE ugfx.line(int(x + width / 2), y, int(x), y + height, ugfx.WHITE) ugfx.line(int(x + width / 2), y, int(x + width), y + height, ugfx.WHITE) ugfx.line(int(x + width), y + height, int(x), y + height, ugfx.WHITE)
def draw(self): if not self.crashing: self.crashing = not (pyb.rng() % 500) ugfx.area(self.x-QUADCOPTER_BODY_SIZE, self.y-QUADCOPTER_BODY_SIZE, QUADCOPTER_BODY_SIZE*2, QUADCOPTER_BODY_SIZE*2, self.color) self.animation_frame += 1 self.animation_frame %= 4 for armature_x, armature_y in ( (-QUADCOPTER_BODY_SIZE*3, -QUADCOPTER_BODY_SIZE*2), (QUADCOPTER_BODY_SIZE*3, -QUADCOPTER_BODY_SIZE*2), (-QUADCOPTER_BODY_SIZE*3, QUADCOPTER_BODY_SIZE*2), (QUADCOPTER_BODY_SIZE*3, QUADCOPTER_BODY_SIZE*2) ): rotor_center_x = self.x + armature_x rotor_center_y = self.y + armature_y ugfx.thickline(rotor_center_x, rotor_center_y, self.x, self.y, self.color, 2, False) if self.animation_frame == 0: ugfx.line(rotor_center_x - int(QUADCOPTER_BODY_SIZE*0.7), rotor_center_y - int(QUADCOPTER_BODY_SIZE*0.7), rotor_center_x + int(QUADCOPTER_BODY_SIZE*0.7), rotor_center_y + int(QUADCOPTER_BODY_SIZE*0.7), ugfx.BLACK) elif self.animation_frame == 1: ugfx.line(rotor_center_x, rotor_center_y - QUADCOPTER_BODY_SIZE, rotor_center_x, rotor_center_y + QUADCOPTER_BODY_SIZE, ugfx.BLACK) elif self.animation_frame == 2: ugfx.line(rotor_center_x + int(QUADCOPTER_BODY_SIZE*0.7), rotor_center_y - int(QUADCOPTER_BODY_SIZE*0.7), rotor_center_x - int(QUADCOPTER_BODY_SIZE*0.7), rotor_center_y + int(QUADCOPTER_BODY_SIZE*0.7), ugfx.BLACK) elif self.animation_frame == 3: ugfx.line(rotor_center_x + QUADCOPTER_BODY_SIZE, rotor_center_y, rotor_center_x - QUADCOPTER_BODY_SIZE, rotor_center_y, ugfx.BLACK) draw_crosshair(crosshair_x, crosshair_y)
# Hand: seconds angel_seconds = math.pi * 2 * sec / 60 - math.pi / 2 # wait for vsync while(tear.value() == 0): pass while(tear.value()): pass #Do all the drawing at once ugfx.area(cx-71, cy-71, 141, 141, 0) # Hands draw_hand(cx, cy, angel_hour, 35, 4, ugfx.YELLOW) draw_hand(cx, cy, angel_seconds, 50, 1, ugfx.RED) draw_hand(cx, cy, angel_min, 40, 2, ugfx.WHITE) # Clock face ugfx.circle(cx, cy, 70, ugfx.WHITE) for i in range(0, 12): a = math.pi * 2 * i / 12 x1 = int(math.cos(a) * 55 + cx); y1 = int(math.sin(a) * 55 + cy); x2 = int(math.cos(a) * 60 + cx); y2 = int(math.sin(a) * 60 + cy); ugfx.line(x1, y1, x2, y2, ugfx.WHITE) # Wait pyb.delay(10) sec += 1; ugfx.disable_tear()
def start(): ugfx.input_init() ugfx.set_lut(ugfx.LUT_FASTER) ugfx.clear(ugfx.WHITE) # Instructions if orientation.isLandscape(): x0 = int(display.width() / 2) display.font("fairlight8") currentY = 20 display.cursor( x0 + int((display.width() - x0) / 2) - int(display.get_string_width("BADGE.TEAM") / 2), currentY) display.print("BADGE.TEAM\n") display.font("pixelade9") (_, currentY) = display.cursor() display.cursor( x0 + int((display.width() - x0) / 2) - int(display.get_string_width("ESP32 platform") / 2), currentY) display.print("ESP32 platform\n") display.line(x0, 0, x0, display.height() - 1, 0x000000) display.textColor(0x000000) display.font("pixelade9") currentY = display.get_string_height(" ") * 5 - 5 display.line(x0, currentY, display.width() - 1, currentY, 0x000000) display.cursor(x0 + 5, currentY + 5) display.print("A: Run\n") display.print("B: Return to home\n") display.print("SELECT: Uninstall app\n") (_, currentY) = display.cursor() display.line(x0, currentY, display.width() - 1, currentY, 0x000000) _ = display.cursor(x0 + 5, currentY + 5) display.print(consts.INFO_FIRMWARE_NAME) else: ugfx.line(0, ugfx.height() - 18 * 4, ugfx.width(), ugfx.height() - 18 * 4, ugfx.BLACK) ugfx.string_box(0, ugfx.height() - 18 * 4, ugfx.width(), 18, " A: Run", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.string_box(0, ugfx.height() - 18 * 3, ugfx.width(), 18, " B: Return to home", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.string_box(0, ugfx.height() - 18 * 2, ugfx.width(), 18, " SELECT: Uninstall", "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) ugfx.line(0, ugfx.height() - 18 * 1, ugfx.width(), ugfx.height() - 18 * 1, ugfx.BLACK) ugfx.string_box(0, ugfx.height() - 18 * 1, ugfx.width(), 18, " " + consts.INFO_FIRMWARE_NAME, "Roboto_Regular12", ugfx.BLACK, ugfx.justifyLeft) global options global install_path options = None install_path = None ugfx.input_attach(ugfx.BTN_A, input_a) ugfx.input_attach(ugfx.BTN_B, input_b) ugfx.input_attach(ugfx.BTN_SELECT, input_select) ugfx.input_attach(ugfx.JOY_UP, input_other) ugfx.input_attach(ugfx.JOY_DOWN, input_other) ugfx.input_attach(ugfx.JOY_LEFT, input_other) ugfx.input_attach(ugfx.JOY_RIGHT, input_other) ugfx.input_attach(ugfx.BTN_START, input_other) populate_apps() populate_category() populate_options() # do a greyscale flush on start ugfx.flush(ugfx.GREYSCALE)
ugfx.clear(ugfx.BLACK) ugfx.fill_circle(60, 60, 50, ugfx.WHITE) ugfx.fill_circle(60, 60, 40, ugfx.BLACK) ugfx.fill_circle(60, 60, 30, ugfx.WHITE) ugfx.fill_circle(60, 60, 20, ugfx.BLACK) ugfx.fill_circle(60, 60, 10, ugfx.WHITE) ugfx.thickline(1, 1, 100, 100, ugfx.WHITE, 10, 5) ugfx.box(30, 30, 50, 50, ugfx.WHITE) ugfx.string(150, 25, "STILL", "Roboto_BlackItalic24", ugfx.WHITE) ugfx.string(130, 50, "Hacking", "PermanentMarker22", ugfx.WHITE) len = ugfx.get_string_width("Hacking", "PermanentMarker22") ugfx.line(130, 72, 144 + len, 72, ugfx.WHITE) ugfx.line(140 + len, 52, 140 + len, 70, ugfx.WHITE) ugfx.string(140, 75, "Anyway", "Roboto_BlackItalic24", ugfx.WHITE) ugfx.flush() def render(text, pushed): if (pushed): ugfx.string(100, 10, text, "PermanentMarker22", ugfx.WHITE) else: ugfx.string(100, 10, text, "PermanentMarker22", ugfx.BLACK) ugfx.flush() def start_app(pushed):
wifi.init() ugfx.clear(ugfx.BLACK) ugfx.string(20, 25, "Connecting to:", "Roboto_BlackItalic24", ugfx.WHITE) ugfx.string(140, 75, "WiFi", "PermanentMarker22", ugfx.WHITE) ugfx.flush() while not wifi.sta_if.isconnected(): time.sleep(0.1) pass ugfx.clear(ugfx.WHITE) ugfx.string(180, 25, "STILL", "Roboto_BlackItalic24", ugfx.BLACK) ugfx.string(160, 50, "Hacking", "PermanentMarker22", ugfx.BLACK) str_len = ugfx.get_string_width("Hacking", "PermanentMarker22") ugfx.line(160, 72, 174 + str_len, 72, ugfx.BLACK) ugfx.line(170 + str_len, 52, 170 + str_len, 70, ugfx.BLACK) ugfx.string(170, 75, "Anyway", "Roboto_BlackItalic24", ugfx.BLACK) def show_description(active): if active: text.text(packages[options.selected_index()]["description"]) ugfx.flush() def woezel_it(active): if active: ugfx.clear(ugfx.BLACK) ugfx.string(40, 25, "Installing:", "Roboto_BlackItalic24", ugfx.WHITE) ugfx.string(100, 75, packages[options.selected_index()]["name"],
def draw(self): ugfx.fill_circle(self.x, self.y, QUADCOPTER_BODY_SIZE*2, ugfx.GRAY) ugfx.line(self.x, self.y+(QUADCOPTER_BODY_SIZE), self.x, self.y+QUADCOPTER_BODY_SIZE*3, ugfx.BLACK) ugfx.area(self.x-5, self.y+QUADCOPTER_BODY_SIZE*3, QUADCOPTER_BODY_SIZE*2, QUADCOPTER_BODY_SIZE, self.color) draw_crosshair(crosshair_x, crosshair_y)
ugfx.input_attach(ugfx.JOY_LEFT, dec_decay) # same here ugfx.input_attach(ugfx.JOY_RIGHT, inc_decay) ugfx.input_attach(ugfx.BTN_A, larson_mode_next) ugfx.input_attach(ugfx.BTN_B, larson_mode_prev) ugfx.input_attach(ugfx.BTN_START, home) ugfx.input_attach(ugfx.BTN_SELECT, home) ugfx.clear(ugfx.BLACK) ugfx.flush() ugfx.clear(ugfx.WHITE) ugfx.flush() ugfx.string(190, 7, "STILL", "Roboto_BlackItalic24", ugfx.BLACK) ugfx.string(170, 32, name, "PermanentMarker22", ugfx.BLACK) length = ugfx.get_string_width(name, "PermanentMarker22") ugfx.line(170, 54, 184 + length, 54, ugfx.BLACK) ugfx.line(180 + length, 34, 180 + length, 54, ugfx.BLACK) ugfx.string(180, 57, "Anyway", "Roboto_BlackItalic24", ugfx.BLACK) ugfx.string(177, 88, "Mode: A/B, Tail: L/R", "Roboto_Regular12", ugfx.BLACK) ugfx.string(177, 101, "Brightness: UP/DOWN", "Roboto_Regular12", ugfx.BLACK) ugfx.string(215, 116, "Larson Pride", "Roboto_Regular10", ugfx.BLACK) ugfx.string(279, 116, LARSON_VERSION, "Roboto_Regular10", ugfx.BLACK) ugfx.flush() current_color_map = settings_get_color_map() show_scanner() while True: scanner.draw() scanner.wait()
def drawCursor(i): ugfx.box(applistOffset[0] + i * (10 + iconSize) - 3, applistOffset[1] - 17, iconSize + 6, iconSize + 20, 0) def drawBattery(percent): bw = int(20 * (percent / 100)) ugfx.area(w - 22, 1, bw, 10, 0) # statusbar ugfx.string(1, 0, "Sun, 18.06.2017", font, 0) ugfx.string_box(0, 0, w, 13, "doebi", font, 0, ugfx.justifyCenter) ugfx.line(0, 12, w, 12, 0) ugfx.box(w - 22, 1, 20, 10, 0) drawBattery(50) # applist apps = ["nametag", "weather", "fahrplan", "foo", "bar"] for i, app in enumerate(apps): ugfx.string_box(applistOffset[0] + i * (10 + iconSize), applistOffset[1] - 17, iconSize, 14, app, font, 0, ugfx.justifyCenter) ugfx.box(applistOffset[0] + i * (10 + iconSize), applistOffset[1], iconSize, iconSize, 0) drawCursor(2) ugfx.line(0, 90, w, 90, 0)
def put_pixel(x, y, color): ugfx.line(2 * x, 239 - y, 2 * x + 1, 239 - y, color)
i2c = I2C(sda=Pin(26), scl=Pin(27), freq=100000) sgp30 = SGP30(i2c) history = [(0, 0)] * BADGE_EINK_WIDTH while True: measurement = sgp30.air_quality() print(measurement) co2_ppm = measurement['co2_ppm'] tvoc_ppb = measurement['tvoc_ppb'] log_max = math.log(60000) co2_y = int(math.log(max(co2_ppm, 1)) / log_max * 64) tvoc_y = int(math.log(max(tvoc_ppb, 1)) / log_max * 64) _ = history.pop(0) history.append((co2_y, tvoc_y)) ugfx.clear(ugfx.WHITE) ugfx.line(0, 64, BADGE_EINK_WIDTH, 64, ugfx.BLACK) ugfx.string(0, 0, 'eCO2: %d ppm' % co2_ppm, 'Roboto_Regular18', ugfx.BLACK) ugfx.string(0, 64, 'TVOC: %d ppb' % tvoc_ppb, 'Roboto_Regular18', ugfx.BLACK) for (x, (a, b)) in enumerate(zip(history, history[1:])): ugfx.thickline(x, 64 - a[0], x + 1, 64 - b[0], ugfx.BLACK, 2, 0) ugfx.thickline(x, (64 - a[1]) + 64, x + 1, (64 - b[1]) + 64, ugfx.BLACK, 2, 0) ugfx.flush() time.sleep(1)
def draw_crosshair(x, y): ugfx.circle(x, y, CROSSHAIR_DIAMETER, ugfx.BLACK) ugfx.line(x, y - CROSSHAIR_RADIUS - CROSSHAIR_LINE_OFFSET, x, y - CROSSHAIR_RADIUS + CROSSHAIR_LINE_OFFSET, ugfx.BLACK) ugfx.line(x, y + CROSSHAIR_RADIUS - CROSSHAIR_LINE_OFFSET, x, y + CROSSHAIR_RADIUS + CROSSHAIR_LINE_OFFSET, ugfx.BLACK) ugfx.line(x - CROSSHAIR_RADIUS - CROSSHAIR_LINE_OFFSET, y, x - CROSSHAIR_RADIUS + CROSSHAIR_LINE_OFFSET, y, ugfx.BLACK) ugfx.line(x + CROSSHAIR_RADIUS - CROSSHAIR_LINE_OFFSET, y, x + CROSSHAIR_RADIUS + CROSSHAIR_LINE_OFFSET, y, ugfx.BLACK)
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) #the cursor past the text cursor_pos = line_end + 5 ugfx.line(cursor_pos, 46, cursor_pos, 81, ugfx.BLACK) ugfx.flush(ugfx.LUT_FULL) import deepsleep, badge badge.eink_busy_wait() deepsleep.start_sleeping(60000)
def draw(): ugfx.clear(ugfx.WHITE) ugfx.line(0, 0, 180, 100, ugfx.BLACK)
def draw(self): ugfx.line(int(floor(self.start[0])), int(floor(self.start[1])), int(floor(self.end[0])), int(floor(self.end[1])),ugfx.BLACK)