def serialWarning(): oldOrientation = display.orientation() setDisplayOrientation() easydraw.messageCentered( "NOTICE\n\nThis app can only be controlled using the USB-serial connection.", True, "/media/usb.png") display.orientation(oldOrientation)
def demoThread(): global demoThreadRunning counter = 0 fpsTrig = False w, h, _, _ = display.pngInfo(mascot.snek) display.drawFill(0xFFFF00) prev = time.ticks_ms() av = [0]*100 display.orientation(0) while demoThreadRunning: if counter > 100: fpsTrig = True current = time.ticks_ms() if (current-prev) > 0: fps = 1000//(current-prev) else: fps = 0 _ = av.pop(0) av.append(fps) fps = 0 for i in range(len(av)): fps += av[i] fps = fps // len(av) display.drawRect(0,0,display.width()-1,20, True, 0xFFFF00) if fpsTrig: display.drawText(0,0,"{} fps".format(fps),0x000000,"ocra16") else: display.drawText(0,0,"Demo time!",0x000000,"ocra16") my = (display.height()-h)//2 - (round(math.sin(counter))-1)*10 mx = (display.width()-w)//2 - (round(math.cos(counter))-1)*10 display.drawPng(mx,my,mascot.snek) #Draw squares display.drawRect(display.width()-39-(counter % display.width()),display.height()//2-20,40,40, True, 0x00FF00) display.drawRect(counter % display.width(),display.height()//2-10,20,20, True, 0xFF0000) #Flush to display display.flush() #Clear away the squares display.drawRect(display.width()-39-(counter % display.width()),display.height()//2-20,40,40, True, 0xFFFF00) display.drawRect(counter % display.width(),display.height()//2-10,20,20, True, 0xFFFF00) #Clear away the mascot display.drawRect(mx,my,w,h,True,0xFFFF00) #Increment counter counter+=1 #time.sleep(0.01) prev = current display.orientation(90) drawNickname()
def setDisplayOrientation(value=None): display.orientation(value or machine.nvs_get_u16('system', 'orientation') or consts.DEFAULT_ORIENTATION)
departureDir = [None] * 4 departureLine = [None] * 4 refreshCounter = 10 updateDisplay = True ############################################### BADGE_EINK_LUT_CUSTOM = -1 BADGE_EINK_LUT_FULL = 4 BADGE_EINK_LUT_NORMAL = 8 BADGE_EINK_LUT_FASTER = 16 BADGE_EINK_LUT_FASTEST = 32 ############################################### while True: #ugfx.init() display.orientation(270) try: wifi.init() #wifi.connect() while not wifi.sta_if.isconnected(): sleep(0.1) except: wifi.connect() print("Connecting to WiFi") if not wifi.wait(): time.sleep(2) print("Connection Error, Rebooting") machine.reset() #############################################################################################################################################################################################
def default(): #Deprecated display.orientation(getDefault())
def portrait(): display.orientation(90)
def landscape(): display.orientation(0)
def isLandscape(value=None): if value == None: value = display.orientation() if value==90 or value==270: return False return True
def setDefault(): display.orientation(getDefault())
def orientation(deg=None): if deg: display.orientation(deg) else: return display.orientation()
demoThreadRunning = True _ = _thread.start_new_thread("DEMO", demoThread, ()) else: demoThreadRunning = False def drawNickname(): owner = machine.nvs_getstr("owner", "name") or "BADGE.TEAM" display.drawFill(0xFFFF00) x = (display.width()-display.getTextWidth(owner, "ocra16"))//2 y = (display.height()-display.getTextHeight(owner, "ocra16"))//2 display.drawText(x,y,owner,0x000000,"ocra16") display.flush() # Send the new buffer to the display display.backlight(0xFF) # Turn on backlight display.orientation(90) buttons.attach(buttons.BTN_A, onButtonA) buttons.attach(buttons.BTN_B, onButtonB) drawNickname() # Demo :-) def demoThread(): global demoThreadRunning counter = 0 fpsTrig = False w, h, _, _ = display.pngInfo(mascot.snek) display.drawFill(0xFFFF00)
def portrait(rotateButtons=True): if rotateButtons: buttons.rotate(90) display.orientation(90)
def landscape(rotateButtons=True): if rotateButtons: buttons.rotate(0) display.orientation(0)
def default(rotateButtons=True): value = machine.nvs_get_u16('system', 'orientation') or consts.DEFAULT_ORIENTATION if rotateButtons: buttons.rotate(value) display.orientation(value)
def default(rotateButtons=True): value = getDefault() if rotateButtons: buttons.rotate(value) display.orientation(value)