#Initialisierung der Oxocard try: from machine import Pin, deepsleep, ADC, reset from globals import __np import time Pin(2, Pin.OUT).value(1) # audio ampli on Pin(15, Pin.OUT).value(0) # neopix on __np.set(37, 0xffff00, update = True) # Möglichkeit zum Ausschalten... for i in range(50): if Pin(13, Pin.IN, Pin.PULL_DOWN).value() == 1 and Pin(27, Pin.IN, Pin.PULL_DOWN).value() == 1: print("Power off") for k in [250, 100, 50, 20, 10, 5, 1, 0]: for i in range(8): __np.set(9*i+1, k << 16, update = False) __np.set(7*i+8, k << 16, update = False) __np.show() time.sleep(0.5) Pin(2, Pin.OUT).value(0) # audio ampli off Pin(15, Pin.OUT).value(1) # neopix off deepsleep() time.sleep(0.02) except ImportError: pass ################################### # Start vom eigentlichen Programm # ################################### from oxocard import * from ivobuttons import * def hsv2rgb(h,s,v): c = v*s x = c*(1-abs(h*6 % 2 -1)) m = c-v rgb = (0,0,0) if (h<1/6): rgb = (c,x,0) elif h<2/6: rgb = (x,c,0) elif h<3/6: rgb = (0,c,x) elif h<4/6: rgb = (0,x,c) elif h<5/6: rgb = (x,0,c) else: rgb = (c,0,x) rgb = ((int((rgb[0]+m)*255)), (int((rgb[1]+m)*255)),(int((rgb[2]+m)*255))) return rgb clear(BLACK) dirs = ((0,1),(1,0),(0,-1), (-1,0)) x = 0 y = 0 d = 0 h = 0.0 a = 0 b = 0 dd = 0 ivobuttons.delay=0 fps = getms() while True: for i in range(24): fastDot(x,y,hsv2rgb((h+i/40)%1, 1, (i/24)**1.5)) x+=dirs[d][0] y+=dirs[d][1] if (x>7 or x<0 or y>7 or y<0): x-=dirs[d][0] y-=dirs[d][1] d=(d+1)%4 x+=dirs[d][0] y+=dirs[d][1] if (i==0): a = x b = y dd = d fastRepaint() s = ivobuttons.states() if (s & IVO_R2): sleep(0.05) if (s & IVO_R3): sleep(0.15) h = (h+0.005)%1 x = a y = b d = dd fps2 = getms() print("%d fps" % int(1000/(fps2-fps))) fps = fps2