示例#1
0
def larson(looks, speed=0.12):
    for l in range(looks):
        uh.rotation(0)
        r, g, b = [255, 0, 0]
        t = speed
        ease = speed * .125
        for x in range(8):
            uh.set_pixel(x, 2, r, g, b)
            uh.set_pixel(x, 1, r, g, b)
            uh.show()
            time.sleep(t)
            uh.clear()
            if x < 4:
                t -= ease
            else:
                t += ease
        for x in range(6, 0, -1):
            uh.set_pixel(x, 1, r, g, b)
            uh.set_pixel(x, 2, r, g, b)
            uh.show()
            time.sleep(t)
            uh.clear()
            if x < 4:
                t += ease
            else:
                t -= ease
示例#2
0
def blue():
   import unicornhat as unicorn
   import time
   unicorn.set_layout(unicorn.AUTO)
   unicorn.rotation(0)
   unicorn.brightness(0.5)
   width,height=unicorn.get_shape()
示例#3
0
def initunicornhat():
    """ This function initialises the unicornhat hat. """
    unicornhat.rotation(0)
    unicornhat.brightness(0.5)
    unicornhat.set_layout(unicornhat.AUTO)
    width, height = unicornhat.get_shape()
    return [width, height]
示例#4
0
文件: pulse.py 项目: e-n-p/Lampi
def runPulse():

    intensity = 1.0
    if args['intensity']:
        intensity = float(args['intensity'])
    colour = [255, 0, 255]
    if args['colour']:
        colour = list(map(int, args['colour'].split(",")))

    unicorn.set_layout(unicorn.AUTO)
    unicorn.rotation(0)
    unicorn.brightness(intensity)

    program = [[3, 5], [2, 6], [1, 7], [0, 8], [1, 7], [2, 6]]

    controller = 0
    while True:
        unicorn.clear()
        topLeft, extent = program[controller]
        for y in range(topLeft, extent):
            for x in range(topLeft, extent):
                pulse(x, y, colour)

        unicorn.show()
        time.sleep(0.5)
        if controller <= 4:
            controller += 1
        else:
            controller = 0
示例#5
0
def unicornSetup():
    unicorn.off()
    unicorn.clear()
    unicorn.set_layout(unicorn.AUTO)
    unicorn.rotation(0)
    unicorn.brightness(0.5)
    width, height = unicorn.get_shape()
示例#6
0
    def __init__(self):

        self.name = 'UniCorn'
        log_str('init {}'.format(self.__module__))

        self.rotation = UNICORN_ROTATION

        unicorn.rotation(self.rotation)

        self.width, self.height = unicorn.get_shape()

        self.hour = int(datetime.now().strftime("%H"))

        if 9 <= self.hour <= 17:
            self.brightness = HIGH.unicorn
            self.brightness_setting = 'day'

        elif 18 <= self.hour <= 23 or 0 <= self.hour <= 8:
            self.brightness = LOW.unicorn
            self.brightness_setting = 'night'

        else:
            self.brightness = self.brightness

        log_str('unicorn brightness: {} - {}: {}'.format(self.brightness, self.brightness_setting, self.hour))
        unicorn.brightness(self.brightness)
示例#7
0
def go():
    unicorn.brightness(1)
    unicorn.rotation(90)

    wrd_rgb = [[154, 173, 154], [0, 255, 0], [0, 200, 0], [0, 162, 0],
               [0, 145, 0], [0, 96, 0], [0, 74, 0], [
                   0,
                   0,
                   0,
               ]]

    clock = 0

    blue_pilled_population = [[randint(0, 7), 7]]
    t_end = time.time() + 10
    while time.time() < t_end:
        for person in blue_pilled_population:
            y = person[1]
            for rgb in wrd_rgb:
                if (y <= 7) and (y >= 0):
                    unicorn.set_pixel(person[0], y, rgb[0], rgb[1], rgb[2])
                y += 1
            person[1] -= 1
        unicorn.show()
        time.sleep(0.1)
        clock += 1
        if clock % 5 == 0:
            blue_pilled_population.append([randint(0, 7), 7])
        if clock % 7 == 0:
            blue_pilled_population.append([randint(0, 7), 7])
        while len(blue_pilled_population) > 100:
            blue_pilled_population.pop(0)
示例#8
0
文件: banner.py 项目: e-n-p/Lampi
def runBanner():

    intensity = 1.0
    if args['intensity']:
        intensity = float(args['intensity'])
    background_colour = [255, 0, 255]
    if args['bcolour']:
        background_colour = list(map(int, args['bcolour'].split(",")))
    wave_colour = [220, 20, 60]
    if args['wcolour']:
        wave_colour = list(map(int, args['wcolour'].split(",")))

    unicorn.set_layout(unicorn.AUTO)
    unicorn.rotation(0)
    unicorn.brightness(intensity)
    width, height = unicorn.get_shape()

    g = -1
    while True:
        g += 1
        for y in range(height):
            for x in range(width):
                if x == g or x == g - 1 or x == g - 2:
                    wave(x, y, wave_colour)
                else:
                    background(x, y, background_colour)
                if g > 9:
                    g = -1

        unicorn.show()
        time.sleep(0.8)
示例#9
0
def vortex(layers):
    uh.rotation(90)
    effects = [vortex_checker, vortex_tunnel, vortex_swirl]
    step = 0
    for layer in range(layers):
        for i in range(1000):
            for y in range(height):
                for x in range(width):
                    r, g, b = effects[0](x, y, step)
                    if i > 400:
                        r2, g2, b2 = effects[-1](x, y, step)

                        ratio = (500.00 - i) / 100.0
                        r = r * ratio + r2 * (1.0 - ratio)
                        g = g * ratio + g2 * (1.0 - ratio)
                        b = b * ratio + b2 * (1.0 - ratio)
                    r = int(max(0, min(255, r)))
                    g = int(max(0, min(255, g)))
                    b = int(max(0, min(255, b)))
                    uh.set_pixel(x, y, r, g, b)

            step += 1

            uh.show()

            time.sleep(0.01)

        effect = effects.pop()
        effects.insert(0, effect)
示例#10
0
文件: server.py 项目: scottsweb/ham
def light(r,g,b):
	UH.off()
	UH.rotation(180)
	UH.brightness(0.5)
	global working
	working = True
	UH.set_pixel(2,1,r,g,b)
	UH.set_pixel(3,1,r,g,b)
	UH.set_pixel(4,1,r,g,b)
	UH.set_pixel(5,1,r,g,b)
	UH.set_pixel(1,2,r,g,b)
	UH.set_pixel(6,2,r,g,b)
	UH.set_pixel(1,3,r,g,b)
	UH.set_pixel(3,3,r,g,b)
	UH.set_pixel(4,3,r,g,b)
	UH.set_pixel(6,3,r,g,b)
	UH.set_pixel(2,4,r,g,b)
	UH.set_pixel(5,4,r,g,b)
	UH.set_pixel(2,5,r,g,b)
	UH.set_pixel(5,5,r,g,b)
	UH.set_pixel(3,6,r,g,b)
	UH.set_pixel(4,6,r,g,b)
	UH.show()
	time.sleep(2)
	UH.off()
	working = False
示例#11
0
 def tick(self):
     """ tick tock - update every minute """
     uh.rotation(270)
     while True:
         self.show_time()
         time.sleep(60)
         uh.off()
示例#12
0
def clearsystem():
    led.clear()
    led.rotation(0)
    os.system("arp -d *")
    os.system("ip neigh flush all")
    led.show()
    return;
示例#13
0
def __init__():
	
	global weather
	global windSpeed

	unicornhat.rotation(270) #Sets the correct rotation for the unicornhat
	meteo = urlopen(url).read()
	meteo = meteo.decode("utf-8")
	weather = json.loads(meteo)
	weather = (weather["currently"]["temperature"]) #Stores current temp in a variable called weather
	
	meteo2 = urlopen(url).read()
	meteo2 = meteo2.decode("utf-8")
	windSpeed = json.loads(meteo2)
	windSpeed = (windSpeed["currently"]["windSpeed"])

	
	#weatherF = ((weather * 1.8) + 32) #Converts Celcius into Fahrenheit
	#windSpeedMPH = (windSpeed * 2.2369)
	
	windSpeed = int(windSpeed)
	weather = int(weather)
	
	return weather
	return windSpeed
 def __init__(self):
     self.light_on = False
     self.display_cleared = False
     self.stop_thread = False
     unicorn.set_layout(unicorn.PHAT)
     unicorn.rotation(0)
     unicorn.brightness(0.5)
示例#15
0
文件: server.py 项目: scottsweb/ham
def uh_f1start(b = 0.5):
	UH.off()
	UH.brightness(b)
	UH.rotation(180)
	for x in range(2):
		for y in range(8):
			UH.set_pixel(x,y,255,0,0)
	UH.show()
	sleep(1)
	for x in range(2,4):
		for y in range(8):
			UH.set_pixel(x,y,255,0,0)
	UH.show()
	sleep(1)
	for x in range(4,6):
		for y in range(8):
			UH.set_pixel(x,y,255,0,0)
	UH.show()
	sleep(1)
	for x in range(6,8):
		for y in range(8):
			UH.set_pixel(x,y,255,0,0)
	UH.show()
	delayswitch =  random.random()
	delay = random.random()
	if delayswitch > 0.66:
		sleep(6 + delay)
	elif delayswitch > 0.33:
		sleep(5 + delay)
	else:
		sleep(4 + delay)
	UH.off()
示例#16
0
def rainbow(endClockTime):
    unicorn.set_layout(unicorn.PHAT)
    unicorn.rotation(0)
    unicorn.brightness(.5)
    i = 0.0
    offset = 30
    while True:
        dt = datetime.datetime.now()
        clockTime = dt.strftime('%H%M')
        clockTime = int(clockTime)
        i = i + 0.3
        for y in range(4):
            for x in range(8):
                r = 0#x * 32
                g = 0#y * 32
                xy = x + y / 4
                r = (math.cos((x+i)/2.0) + math.cos((y+i)/2.0)) * 64.0 + 128.0
                g = (math.sin((x+i)/1.5) + math.sin((y+i)/2.0)) * 64.0 + 128.0
                b = (math.sin((x+i)/2.0) + math.cos((y+i)/1.5)) * 64.0 + 128.0
                r = max(0, min(255, r + offset))
                g = max(0, min(255, g + offset))
                b = max(0, min(255, b + offset))
                unicorn.set_pixel(x,y,int(r),int(g),int(b))
        unicorn.show()
        if clockTime == endClockTime:
            break
        time.sleep(0.01)
示例#17
0
def show_letter(letter, colour,
                brightness):  #displays a single letter on th UH
    UH.rotation(270)
    for i in range(8):
        for j in range(8):
            if letter[j][i]:
                if colour == 'red':
                    UH.set_pixel(j, flip[i], brightness, 0, 0)
                elif colour == 'green':
                    UH.set_pixel(j, flip[i], 0, brightness, 0)
                elif colour == 'blue':
                    UH.set_pixel(j, flip[i], 0, 0, brightness)
                elif colour == 'white':
                    UH.set_pixel(j, flip[i], brightness, brightness,
                                 brightness)
                elif colour == 'pink':
                    UH.set_pixel(j, flip[i], brightness, 52, 179)
                elif colour == 'cyan':
                    UH.set_pixel(j, flip[i], 0, brightness, brightness)
                elif colour == 'yellow':
                    UH.set_pixel(j, flip[i], brightness, brightness, 0)
                elif colour == 'orange':
                    UH.set_pixel(j, flip[i], brightness, 128, 0)
            else:
                UH.set_pixel(j, flip[i], 0, 0, 0)

    UH.show()
示例#18
0
def icon(icon):
    unicorn.rotation(270)
    for _ in range(5):
        playIcon(icon)
    unicorn.clear()
    unicorn.show()
    return "ok"
示例#19
0
 def cleanup(self):
     unicorn.clear()
     unicorn.rotation(90)
     for i in range(100):
         self.showScore()
     os.system('stty sane')
     sys.exit()
示例#20
0
文件: server.py 项目: scottsweb/ham
def iss(r,g,b):
	UH.off()
	UH.rotation(180)
	UH.brightness(0.5)
	global working
	working = True
	UH.set_pixel(4,0,r,g,b)
	UH.set_pixel(4,1,r,g,b)
	UH.set_pixel(3,2,r,g,b)
	UH.set_pixel(4,2,r,g,b)
	UH.set_pixel(5,2,r,g,b)
	UH.set_pixel(3,3,r,g,b)
	UH.set_pixel(5,3,r,g,b)
	UH.set_pixel(3,4,r,g,b)
	UH.set_pixel(4,4,r,g,b)
	UH.set_pixel(5,4,r,g,b)
	UH.set_pixel(2,5,r,g,b)
	UH.set_pixel(3,5,r,g,b)
	UH.set_pixel(4,5,r,g,b)
	UH.set_pixel(5,5,r,g,b)
	UH.set_pixel(6,5,r,g,b)
	UH.set_pixel(2,6,r,g,b)
	UH.set_pixel(3,6,210,210,35)
	UH.set_pixel(4,6,240,130,10)
	UH.set_pixel(5,6,210,210,35)
	UH.set_pixel(6,6,r,g,b)
	UH.set_pixel(3,7,210,210,35)
	UH.set_pixel(4,7,210,210,35)
	UH.set_pixel(5,7,210,210,35)
	UH.show()
	time.sleep(2)
	UH.off()
	working = False
示例#21
0
def show_letter(letter,colour,brightness): #displays a single letter on th UH
	UH.rotation(_scrollrotation)		
	for i in range(8):
		for j in range(8):
			if letter[j][i]:
				if colour == 'red':
					UH.set_pixel(j,flip[i],brightness,0,0)
				elif colour == 'green':
					UH.set_pixel(j,flip[i],0,brightness,0)
				elif colour == 'blue':
					UH.set_pixel(j,flip[i],0,0,brightness)
				elif colour == 'white':
					UH.set_pixel(j,flip[i],brightness,brightness,brightness)
				elif colour == 'pink':
					UH.set_pixel(j,flip[i],brightness,52,179)
				elif colour == 'cyan':
					UH.set_pixel(j,flip[i],0,brightness,brightness)
				elif colour == 'yellow':
					UH.set_pixel(j,flip[i],brightness,brightness,0)
				elif colour == 'orange':
					UH.set_pixel(j,flip[i],brightness,128,0)
			else:
				UH.set_pixel(j,flip[i],0,0,0)

	UH.show()
示例#22
0
文件: server.py 项目: scottsweb/ham
def battery(r,g,b):
	UH.off()
	UH.rotation(180)
	UH.brightness(0.5)
	global working
	working = True
	UH.set_pixel(1,2,r,g,b)
	UH.set_pixel(2,2,r,g,b)
	UH.set_pixel(3,2,r,g,b)
	UH.set_pixel(4,2,r,g,b)
	UH.set_pixel(5,2,r,g,b)
	UH.set_pixel(1,3,r,g,b)
	UH.set_pixel(2,3,r,g,b)
	UH.set_pixel(3,3,r,g,b)
	UH.set_pixel(6,3,r,g,b)
	UH.set_pixel(1,4,r,g,b)
	UH.set_pixel(2,4,r,g,b)
	UH.set_pixel(3,4,r,g,b)
	UH.set_pixel(6,4,r,g,b)
	UH.set_pixel(1,5,r,g,b)
	UH.set_pixel(2,5,r,g,b)
	UH.set_pixel(3,5,r,g,b)
	UH.set_pixel(4,5,r,g,b)
	UH.set_pixel(5,5,r,g,b)
	UH.show()
	time.sleep(2)
	UH.off()
	working = False
示例#23
0
文件: server.py 项目: scottsweb/ham
def pause(r,g,b):
	UH.off()
	UH.rotation(180)
	UH.brightness(0.5)
	global working
	working = True
	UH.set_pixel(1,1,r,g,b)
	UH.set_pixel(1,2,r,g,b)
	UH.set_pixel(1,3,r,g,b)
	UH.set_pixel(1,4,r,g,b)
	UH.set_pixel(1,5,r,g,b)
	UH.set_pixel(1,6,r,g,b)
	UH.set_pixel(2,1,r,g,b)
	UH.set_pixel(2,2,r,g,b)
	UH.set_pixel(2,3,r,g,b)
	UH.set_pixel(2,4,r,g,b)
	UH.set_pixel(2,5,r,g,b)
	UH.set_pixel(2,6,r,g,b)
	UH.set_pixel(5,1,r,g,b)
	UH.set_pixel(5,2,r,g,b)
	UH.set_pixel(5,3,r,g,b)
	UH.set_pixel(5,4,r,g,b)
	UH.set_pixel(5,5,r,g,b)
	UH.set_pixel(5,6,r,g,b)
	UH.set_pixel(6,1,r,g,b)
	UH.set_pixel(6,2,r,g,b)
	UH.set_pixel(6,3,r,g,b)
	UH.set_pixel(6,4,r,g,b)
	UH.set_pixel(6,5,r,g,b)
	UH.set_pixel(6,6,r,g,b)
	UH.show()
	time.sleep(2)
	UH.off()
	working = False
示例#24
0
文件: server.py 项目: scottsweb/ham
def play(r,g,b):
	UH.off()
	UH.rotation(180)
	UH.brightness(0.5)
	global working
	working = True
	UH.set_pixel(2,0,r,g,b)
	UH.set_pixel(2,1,r,g,b)
	UH.set_pixel(2,2,r,g,b)
	UH.set_pixel(2,3,r,g,b)
	UH.set_pixel(2,4,r,g,b)
	UH.set_pixel(2,5,r,g,b)
	UH.set_pixel(2,6,r,g,b)
	UH.set_pixel(2,7,r,g,b)
	UH.set_pixel(3,1,r,g,b)
	UH.set_pixel(3,2,r,g,b)
	UH.set_pixel(3,3,r,g,b)
	UH.set_pixel(3,4,r,g,b)
	UH.set_pixel(3,5,r,g,b)
	UH.set_pixel(3,6,r,g,b)
	UH.set_pixel(4,2,r,g,b)
	UH.set_pixel(4,3,r,g,b)
	UH.set_pixel(4,4,r,g,b)
	UH.set_pixel(4,5,r,g,b)
	UH.set_pixel(5,3,r,g,b)
	UH.set_pixel(5,4,r,g,b)
	UH.show()
	time.sleep(2)
	UH.off()
	working = False
示例#25
0
def go():
    unicorn.brightness(1)
    unicorn.rotation(90)

    wrd_rgb = [[154, 173, 154], [0, 255, 0], [0, 200, 0], [0, 162, 0], [0, 145, 0], [0, 96, 0], [0, 74, 0], [0, 0, 0,]]

    clock = 0

    blue_pilled_population = [[randint(0,7), 7]]
    t_end = time.time() + 10
    while time.time() < t_end:
            for person in blue_pilled_population:
                    y = person[1]
                    for rgb in wrd_rgb:
                            if (y <= 7) and (y >= 0):
                                    unicorn.set_pixel(person[0], y, rgb[0], rgb[1], rgb[2])
                            y += 1
                    person[1] -= 1
            unicorn.show()
            time.sleep(0.1)
            clock += 1
            if clock % 5 == 0:
                    blue_pilled_population.append([randint(0,7), 7])
            if clock % 7 == 0:
                    blue_pilled_population.append([randint(0,7), 7])
            while len(blue_pilled_population) > 100:
                    blue_pilled_population.pop(0)
示例#26
0
def kscope(width, height, rgb):
    """ Freakin' Kaleidoscope F.X. """
    choices = [0, 1]
    choice = random.choice(choices)
    shift = lsc.getshift()
    mytime = lsd.getduration()
    xcoord, ycoord = lsd.getcoords(width, height)
    for _ in range(mytime):
        if width == height:
            for thisrot in range(0, 360, 90):
                unicornhat.rotation(thisrot)
                unicornhat.set_pixel(xcoord, ycoord, rgb[0], rgb[1], rgb[2])
            unicornhat.show()
        else:
            for thisrot in range(0, 270, 180):
                unicornhat.rotation(thisrot)
                unicornhat.set_pixel(xcoord, ycoord, rgb[0], rgb[1], rgb[2])
            unicornhat.show()
        if choice == 0:
            rgb = lsc.warpcolour(rgb)
        else:
            rgb = lsc.shiftcolour(rgb, shift)
        time.sleep(1)
        xcoord, ycoord = lsd.getcoords(width, height)
    unicornhat.set_all(0, 0, 0)
    unicornhat.show()
示例#27
0
def message(message):
    unicorn.rotation(270)
    for _ in range(2):
        unicorn_scroll(message,'white',255,0.1)
    unicorn.clear()
    unicorn.show()
    return "ok"
def show_heart():
    unicornhat.rotation(270)
    while True:
        unicornhat.set_pixel(1, 1, 255, 165, 0)
        unicornhat.set_pixel(1, 2, 255, 165, 0)
        unicornhat.set_pixel(1, 5, 255, 165, 0)
        unicornhat.set_pixel(1, 6, 255, 165, 0)
        for i in range(8):
            unicornhat.set_pixel(2, i, 255, 165, 0)
            unicornhat.set_pixel(3, i,255, 165, 0)
            unicornhat.set_pixel(4, i, 255, 165, 0)
        for x in range(1, 7):
            unicornhat.set_pixel(5, x, 255, 165, 0)
        for z in range(2, 6):
            unicornhat.set_pixel(6, z, 255, 165, 0)
        for c in range(3, 5):
            unicornhat.set_pixel(7, c, 255, 165, 0)
        unicornhat.show()
        time.sleep(0.4)
        # -------------------------
        unicornhat.clear()
        unicornhat.set_pixel(2, 2, 255, 165, 0)
        unicornhat.set_pixel(2, 5, 255, 165, 0)
        for i1 in range(1, 7):
            unicornhat.set_pixel(3, i1, 255, 165, 0)
        for x1 in range(1, 7):
            unicornhat.set_pixel(4, x1, 255, 165, 0)
        for z1 in range(2, 6):
            unicornhat.set_pixel(5, z1, 255, 165, 0)
        for c1 in range(3, 5):
            unicornhat.set_pixel(6, c1,255, 165, 0)
        unicornhat.show()
        time.sleep(0.3)
        # -------------------------
        unicornhat.clear()
def unicorn_init(orientation, lowlight):
    unicorn.set_layout(unicorn.AUTO)
    unicorn.rotation(orientation)
    if lowlight:
        unicorn.brightness(0.3)
    else:
        unicorn.brightness(0.5)
示例#30
0
def main():
    try:
        unicorn.set_layout(unicorn.AUTO)
        unicorn.rotation(0)
        unicorn.brightness(0.3)
        width, height = unicorn.get_shape()
        letters = Letter.V + Letter.I + Letter.T

        yellow = [247, 178, 28]
        white = [255, 255, 255]
        colors = [yellow, yellow, yellow, white, yellow, yellow, yellow, white]

        for x in range(width):
            rgb = colors[x]
            for y in range(height):
                if len(letters) > x:
                    row = letters[x]
                    if len(row) > y:
                        if row[y] == 1:
                            unicorn.set_pixel(x, y, rgb[0], rgb[1], rgb[2])

                unicorn.show()
                time.sleep(0.05)

    except:
        print('traceback.format_exc():\n%s', traceback.format_exc())
        exit()
示例#31
0
 def __init__(self, default_r=255, default_g=255, default_b=255):
     self.brightness = 0
     unicorn.set_layout(unicorn.AUTO)
     unicorn.rotation(0)
     unicorn.brightness(self.brightness)
     self.width, self.height = unicorn.get_shape()
     self.default_r, self.default_g, self.default_b = default_r, default_g, default_b
     self.r, self.g, self.b = self.default_r, self.default_g, self.default_b
def rotate():  #Rotates image on AstroPi LED matrix
    global rotation
    if rotation == 270:
        rotation = 0
    else:
        rotation = rotation + 90
    #ap.set_rotation(rotation)
    uh.rotation(rotation)
def rotate(): #Rotates image on AstroPi LED matrix
	global rotation
	if rotation == 270:
		rotation = 0
	else:
		rotation = rotation + 90
	#ap.set_rotation(rotation)
	uh.rotation(rotation)
def show_random_all():
    while True:
        unicornhat.rotation(90)
        unicornhat.set_pixel(random.randint(0, 7), random.randint(0, 7), random.randint(0, 255), random.randint(0, 255),
                             random.randint(0, 255))
        unicornhat.show()
        time.sleep(0.4)
        for i in unicornhat.get_pixels():
            print(i)
示例#35
0
 def __init__(self, oversample):
     self.oversample = oversample
     self.size = 8 * self.oversample
     self.initGrid()
     # fire up the unicorn hat
     unicorn.set_layout(unicorn.HAT)
     unicorn.rotation(90)
     unicorn.brightness(1)
     self.width, self.height = unicorn.get_shape()
示例#36
0
    def __init__(self, correction=[1., 1., 1.]):

        BaseLamp.__init__(self, correction=correction)

        unicorn.set_layout(unicorn.AUTO)
        unicorn.rotation(0)

        # Get LED matrix dimensions
        self.width, self.height = unicorn.get_shape()
def show_letter_rgb(letter,r,g,b): #displays a single letter on th UH
	UH.rotation(270)		
	for i in range(8):
		for j in range(8):
			if letter[j][i]:
				
				UH.set_pixel(j,flip[i],r,g,b)
				
					
			else:
				UH.set_pixel(j,flip[i],0,0,0)

	UH.show()
示例#38
0
    import numpy as np
except ImportError:
    exit("This script requires the numpy module\nInstall with: sudo pip install numpy")

import unicornhat as unicorn

print("""Random Blinky

Blinks random yellow-orange-red LEDs.

If you're using a Unicorn HAT and only half the screen lights up, 
edit this example and  change 'unicorn.AUTO' to 'unicorn.HAT' below.
""")

unicorn.set_layout(unicorn.AUTO)
unicorn.rotation(0)
unicorn.brightness(0.4)
width,height=unicorn.get_shape()


while True:
    rand_mat = np.random.rand(width,height)
    for y in range(height):
        for x in range(width):
            h = 0.1 * rand_mat[x, y]
            s = 0.8
            v = rand_mat[x, y]
            rgb = colorsys.hsv_to_rgb(h, s, v)
            r = int(rgb[0]*255.0)
            g = int(rgb[1]*255.0)
            b = int(rgb[2]*255.0)
示例#39
0
#!/usr/bin/env python

import unicornhat as uh
import time
from random import randint

uh.rotation(0)
heights = []


def setup():

    global heights
    heights = []
    for b in range(0, 6):
        heights.append(0)
    uh.off()
    for b in range(0, 8):
        uh.set_pixel(0, b, 255, 255, 255)
    for b in range(0, 8):
        uh.set_pixel(7, b, 255, 255, 255)
    for b in range(1, 7):
        uh.set_pixel(b, 0, 255, 255, 255)
    uh.show()


def drop_ball():

    ball_colour = [randint(100, 255), randint(100, 255), randint(100, 255)]
    ball_column = randint(0, 5)
示例#40
0
		[1, 6, 6, 1, 8, 8, 8, 1],
		[1, 6, 6, 1, 8, 8, 8, 1],
		[1, 6, 6, 1, 8, 8, 8, 1]] 
	tog(1, 2, 3, h1, 3)
	tog(1, 4, 7, h2, 5)
	tog(5, 1, 3, m1, 7)
	tog(5, 4, 7, m2, 9)

	for x in range(8):
		for y in range(8):
			r, g, b = colors[ disp[y][x] ]
			unicornhat.set_pixel(x, y, r, g, b)
	unicornhat.show()

unicornhat.set_layout(unicornhat.AUTO)
unicornhat.rotation(0)
unicornhat.brightness(0.5)
unicornhat.clear()
unicornhat.show()

try:
    while True:
        mainprog()
        time.sleep(inter)

except KeyboardInterrupt:
    unicornhat.clear()
    unicornhat.show()
    time.sleep(0.1)

示例#41
0
                else:
                        lpos += 1
        return lpos                   

if __name__ == '__main__':

        #Initialize curses
        stdscr = curses.initscr()
        curses.cbreak()
        curses.noecho()
        stdscr.nodelay(1)
        stdscr.keypad(1)

        #Initialize the Unicorn Hat
        unicorn.brightness(0.1)
        unicorn.rotation(180)

        ship = ['s',255,0,0]
        ship_pos = [3,7]
        matrix = initialize()
        
        #Global variables
        time = 0
        lpos = 0        #Position of lightspeed trails
        dodge_blue = 0  #How many blue asteroids dodged
        dodge_green = 0  #How many blue asteroids dodged

        while True:
                press = get_input(stdscr.getch()) #Get input
                #ship_pos = move_ship(ship_pos,press)        
                
示例#42
0
#!/usr/bin/env python

import unicornhat as unicorn
import time, colorsys
import numpy as np

unicorn.brightness(0.5)
unicorn.rotation(270)

def make_gaussian(fwhm):
        x = np.arange(0, 8, 1, float)
        y = x[:, np.newaxis]
        x0, y0 = 3.5, 3.5
        fwhm = fwhm
        gauss = np.exp(-4 * np.log(2) * ((x - x0) ** 2 + (y - y0) ** 2) / fwhm ** 2)
        return gauss

heart = [[0,0,0,0,0,0,0,0],
         [0,1,1,0,0,1,1,0],
         [1,1,1,1,1,1,1,1],
         [1,1,1,1,1,1,1,1],
         [0,1,1,1,1,1,1,0],
         [0,0,1,1,1,1,0,0],
         [0,0,0,1,1,0,0,0],
         [0,0,0,0,0,0,0,0]]

heart = np.array(heart) * make_gaussian(7.5)

while True:
	for i in 2*(range(1,11)[::-1]+range(1,10)):
		for y in range(8):
示例#43
0
import unicornhat as UH
import time
import random

if __name__=='__main__':
  UH.brightness(0.01)
  UH.rotation(90)
  r = range(0,8)
  while True:
    for x in r:
      y = random.choice(r)
      for fill in range(0, y):
        UH.set_pixel(x,fill,255,0,255)

    UH.show()
    time.sleep(0.05)
    UH.clear()
    UH.show()
    time.sleep(0.05)
示例#44
0
文件: heart.py 项目: bendo/pi
#!/usr/bin/env python3

import unicornhat as uh
import time
from random import randrange

uh.brightness(0.1)
uh.rotation(270)

while True:
    r = randrange(200, 255, 1)
    b = randrange(0, 200, 1)

    x = (r, 0, b)
    o = (0, 0, 0)

    heart = [
        [o, o, o, o, o, o, o, o],
        [o, x, x, o, o, x, x, o],
        [x, x, x, x, x, x, x, x],
        [x, x, x, x, x, x, x, x],
        [o, x, x, x, x, x, x, o],
        [o, o, x, x, x, x, o, o],
        [o, o, o, x, x, o, o, o],
        [o, o, o, o, o, o, o, o],
    ]

    uh.set_pixels(heart)
    uh.show()
    time.sleep(0.5)
示例#45
0
#!/usr/bin/python3
# my own attempt at displaying a clock. WIP

import unicornhat as u
import time, math

u.rotation(180)
u.brightness(0.5)

def line(x1, y1, x2, y2, color=(255, 255, 255)):
    x1 = int(x1)
    y1 = int(y1)
    x2 = int(x2)
    y2 = int(y2)

    dx = abs(x2 - x1)
    dy = abs(y2 - y1)
    sx = 1 if x1 < x2 else -1
    sy = 1 if y1 < y2 else -1
    err = dx - dy

    u.set_pixel(x1, y1, *color)
    while x1 != x2 or y1 != y2:
        e = 2 * err
        if e > -dy:
            err -= dy
            x1 += sx
        if e < dx:
            err += dx
            y1 += sy
        u.set_pixel(x1, y1, *color)
	's': [0x00, 0x00, 0x38, 0x40, 0x38, 0x04, 0x78, 0x00],
	't': [0x00, 0x10, 0x38, 0x10, 0x10, 0x10, 0x0c, 0x00],
	'u': [0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00],
	'v': [0x00, 0x00, 0x44, 0x44, 0x28, 0x28, 0x10, 0x00],
	'w': [0x00, 0x00, 0x44, 0x54, 0x54, 0x54, 0x28, 0x00],
	'x': [0x00, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00],
	'y': [0x00, 0x00, 0x44, 0x44, 0x44, 0x3c, 0x04, 0x38],
	'z': [0x00, 0x00, 0x7c, 0x08, 0x10, 0x20, 0x7c, 0x00],
	'{': [0x00, 0x0e, 0x08, 0x30, 0x08, 0x08, 0x0e, 0x00],
	'|': [0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00],
	'}': [0x00, 0x70, 0x10, 0x0c, 0x10, 0x10, 0x70, 0x00],
	'~': [0x00, 0x14, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00],
	'©': [0x3c, 0x42, 0x99, 0xa1, 0xa1, 0x99, 0x42, 0x3c]
}

unihat.rotation(180);

# a virtual framebuffer, which we'll copy to the unicorn hat.
# we're using a framebuffer of 24x8 pixels, which equates to eight rows of three bytes.
# we will only draw byte 1 of each row (row is byte 0, 1, 2) so that we use byte 0 and 2
# as "offscreen" drawing area. this gives us left/right shiftable screen area.
vfb = [
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00],
	[0x00, 0x00, 0x00]
];
示例#47
0
import itertools

from twitterpibot.hardware.myhardware import is_linux
from twitterpibot.hardware.unicorn.canvas import Buffer
from twitterpibot.hardware.unicorn.myunicornhatmodes import *

if is_linux:
    import unicornhat

    unicornhat.rotation(270)
else:
    from twitterpibot.hardware.unicorn import unicornhat_viz as unicornhat

_buffer = Buffer(8, 8)

# TODO unicorn hat patterns

# Sin Wave
# Swipes
# graphic equalizer
# starfield

# bouncing ball/line

# snake
# game of life
# battleships
# chess/draughts

# strobe
# lifts?
示例#48
0
 def set_rotation(self,rotation):
     unicornhat.rotation(rotation)
示例#49
0
    raw_input          # Python 2
except NameError:
    raw_input = input  # Python 3

brightness = float(sys.argv[1])/100
UH.off()
UH.brightness(brightness)

while True:
    try:
        data = raw_input()
        if len(data) < 10:
            if data[0] == "B":
                UH.brightness(float(data[1:])/100)
            if data[0] == "R":
                UH.rotation(float(data[1:]))
        else:
            if data[0] == "P":
                data = data[1:].strip()
                s = data.split(',')
                for p in range(0,len(s),5):
                    x1 = 0
                    x2 = 0
                    y1 = 0
                    y2 = 0
                    if s[p] == "*":
                        x1 = 0
                        x2 = 8
                    elif "-" in s[p]:
                        x1 = int(s[p].split('-')[0]) % 8
                        x2 = int(s[p].split('-')[1]) % 8 + 1
示例#50
0
            print 'The market is up', numfloat, 'percent.'
            print ""
       

#optional delay
#time.sleep(2)     
           
   #unicorn hat matrix color change based on market direction

    import unicornhat as unicorn
    from random import randint
    import time

    #tie LED brightness to change magnitude here
    unicorn.brightness(0.30)
    unicorn.rotation(90)

    #colors if market is up, down,or zero change
    if numfloat > 0:
        wrd_rgb = [[154, 173, 154], [0, 255, 0], [0, 200, 0], [0, 162, 0], [0, 145, 0], [0, 96, 0], [0, 74, 0], [0, 0, 0,]]
    elif numfloat == 0:
        wrd_rgb = [[255, 20, 20], [245, 10, 10], [200, 0, 10], [162, 0, 0], [145, 0, 0], [96, 0, 0], [74, 0, 0], [0, 0, 0,]]
    else:     #maybe change this to rainbow sparkles
        wrd_rgb = [[255, 255, 154], [255, 255, 0], [255, 255, 0], [255, 255, 0], [255, 255, 0], [255, 255, 0], [255, 255, 0], [255, 255, 0,]]

    clock = 0

    blue_pilled_population = [[randint(0,7), 7]]
 
    #while True:
    timeout_start = time.time()
示例#51
0
#!/usr/bin/env python

import unicornhat as unicorn
import time, colorsys
import numpy as np

unicorn.set_layout(unicorn.AUTO)
unicorn.rotation(0)	# tested on pHAT/HAT with rotation 0, 90, 180 & 270
unicorn.brightness(0.4)
width,height=unicorn.get_shape()

if height==width:
    delta=0
else:
    delta=2


def make_gaussian(fwhm):
	x = np.arange(0, 8, 1, float)
	y = x[:, np.newaxis]
	x0, y0 = 3.5, 3.5
	fwhm = fwhm
	gauss = np.exp(-4 * np.log(2) * ((x - x0) ** 2 + (y - y0) ** 2) / fwhm ** 2)
	return gauss

while True:
	for z in list(range(1, 10)[::-1]) + list(range(1, 10)):
		fwhm = 5.0/z
		gauss = make_gaussian(fwhm)
                start = time.time()
		for y in range(height):
示例#52
0
#!/usr/bin/python

import unicornhat as unicorn
import time
import sys

unicorn.rotation(180) # adjust for your Pi's orientation
unicorn.brightness(0.4) # warning: altering this value can make the LED very bright!
font_dictionary={' ': [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], '$': [[0.15, 1, 1, 1, 0.15], [1, 0.15, 1, 0.15, 1], [1, 0.15, 1, 0, 0.15], [0.15, 1, 1, 0.75, 0.15], [0.15, 0, 1, 0.15, 1], [1, 0.15, 1, 0.15, 1], [0.15, 1, 1, 1, 0.15], [0, 0, 1, 0, 0]], '(': [[0, 0.75, 0.15], [0.15, 0.75, 0], [0.75, 0.15, 0], [1, 0.15, 0], [1, 0, 0], [1, 0.15, 0], [0.75, 0.15, 0], [0.15, 0.75, 0]], ',': [[0], [0], [0], [0], [0], [0], [1], [1]], '0': [[0.15, 0.75, 1, 0.75, 0.15], [0.75, 0.75, 0.15, 0.75, 0.75], [1, 0.15, 0, 0.15, 1], [1, 0, 0, 0, 1], [1, 0.15, 0, 0.15, 1], [0.75, 0.75, 0.15, 0.75, 0.75], [0.15, 0.75, 1, 0.75, 0.15], [0, 0, 0, 0, 0]], '4': [[0, 0.15, 1, 0], [0, 0.15, 1, 0], [0, 0.15, 1, 0], [0.15, 0, 1, 0], [0.15, 0, 1, 0], [1, 1, 1, 1], [0, 0, 1, 0], [0, 0, 0, 0]], '8': [[0.15, 1, 1, 1, 0.15], [1, 0.15, 0, 0.15, 1], [1, 0.15, 0, 0.15, 1], [0.15, 1, 1, 1, 0.15], [1, 0.15, 0, 0.15, 1], [1, 0.15, 0, 0.15, 1], [0.15, 1, 1, 1, 0.15], [0, 0, 0, 0, 0]], '<': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0.15], [0, 0, 0.15, 0.75, 0.75], [0.15, 0.75, 0.15, 0, 0], [0.15, 0.75, 0.75, 0.15, 0], [0, 0, 0.15, 0.75, 0.75], [0, 0, 0, 0, 0]], '@': [[0, 1, 1, 1, 1, 1, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 1, 1, 1, 1], [1, 1, 0, 1, 0, 0, 1], [1, 1, 0, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]], 'D': [[1, 1, 1, 0.75, 0.15], [1, 0, 0.15, 0.75, 0.75], [1, 0, 0, 0.15, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0.15, 1], [1, 0, 0.15, 0.75, 0.75], [1, 1, 1, 0.75, 0.15], [0, 0, 0, 0, 0]], 'H': [[1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 0, 0, 0, 0]], 'L': [[1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0]], 'P': [[1, 1, 1, 1, 0.15], [1, 0, 0, 0.15, 1], [1, 0, 0, 0.15, 1], [1, 1, 1, 1, 0.15], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]], 'T': [[1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]], 'X': [[0.15, 0.75, 0, 0, 0.75, 0.15], [0, 0.75, 0.15, 0.15, 0.75, 0], [0, 0.15, 1, 0.75, 0.15, 0], [0, 0, 0.75, 0.75, 0, 0], [0, 0.15, 0.75, 0.75, 0.15, 0], [0.15, 1, 0.15, 0.15, 0.75, 0], [0.75, 0.75, 0, 0, 0.75, 0.75], [0, 0, 0, 0, 0, 0]], '\\': [[1, 0.15, 0], [0.75, 0.15, 0], [0.15, 0.75, 0], [0.15, 0.75, 0], [0, 1, 0.15], [0, 0.75, 0.15], [0, 0.15, 0.75], [0, 0, 0]], 'd': [[0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [0.15, 1, 1, 0.75, 1], [1, 0.75, 0.15, 0.75, 1], [1, 0.15, 0, 0.15, 1], [1, 0.75, 0.15, 0.75, 1], [0.15, 1, 1, 0.75, 1], [0, 0, 0, 0, 0]], 'h': [[1, 0, 0, 0], [1, 0, 0, 0], [1, 0.75, 1, 0.75], [1, 0.15, 0.15, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1], [0, 0, 0, 0]], 'l': [[1], [1], [1], [1], [1], [1], [1], [0]], 'p': [[0, 0, 0, 0], [0, 0, 0, 0], [1, 0.75, 1, 0.15], [1, 0.15, 0.15, 1], [1, 0, 0, 1], [1, 0.15, 0.15, 1], [1, 0.75, 1, 0.15], [1, 0, 0, 0]], 't': [[0, 0, 0], [0, 1, 0], [1, 1, 1], [0, 1, 0], [0, 1, 0], [0, 1, 0.15], [0, 1, 1], [0, 0, 0]], 'x': [[0, 0, 0, 0], [0, 0, 0, 0], [0.75, 0.15, 0.15, 0.75], [0, 0.75, 0.75, 0.15], [0, 0.75, 0.75, 0], [0.15, 0.75, 0.75, 0.15], [0.75, 0.15, 0.15, 0.75], [0, 0, 0, 0]], "'": [[1], [1], [0.15], [0], [0], [0], [0], [0]], '+': [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 1, 0], [1, 1, 1], [0, 1, 0], [0, 1, 0], [0, 0, 0]], '/': [[0, 0.15, 0.75], [0, 0.75, 0.15], [0, 1, 0.15], [0.15, 0.75, 0], [0.15, 0.75, 0], [0.75, 0.15, 0], [1, 0.15, 0], [0, 0, 0]], '3': [[0.15, 1, 1, 1, 0.15], [1, 0.15, 0, 0.15, 1], [0, 0, 0.15, 0.15, 1], [0, 0, 1, 1, 0.15], [0, 0, 0, 0.15, 1], [1, 0.15, 0, 0.15, 1], [0.15, 1, 1, 1, 0.15], [0, 0, 0, 0, 0]], '7': [[1, 1, 1, 1], [0, 0, 0.15, 0.75], [0, 0, 0.75, 0.15], [0, 0.15, 0.75, 0], [0, 0.15, 0.75, 0], [0, 0.75, 0.15, 0], [0, 1, 0.15, 0], [0, 0, 0, 0]], ';': [[0], [0], [1], [0], [0], [0], [1], [1]], '?': [[0.75, 1, 1, 0.15], [1, 0.15, 0.15, 1], [0, 0, 0.15, 1], [0, 0.15, 1, 0.15], [0, 1, 0.15, 0], [0, 0.15, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0]], 'C': [[0, 0.75, 1, 1, 0.75, 0.15], [0.75, 0.75, 0.15, 0.15, 0.15, 1], [1, 0.15, 0, 0, 0, 0], [1, 0.15, 0, 0, 0, 0], [1, 0.15, 0, 0, 0, 0], [0.75, 0.75, 0.15, 0, 0.15, 1], [0, 0.75, 1, 1, 0.75, 0.15], [0, 0, 0, 0, 0, 0]], 'G': [[0, 0.75, 1, 1, 1, 0.75, 0.15], [0.75, 1, 0.15, 0.15, 0.15, 0.75, 0.75], [1, 0.15, 0, 0, 0, 0, 0], [1, 0.15, 0, 0, 1, 1, 1], [1, 0.15, 0, 0, 0, 0.15, 1], [0.15, 1, 0.15, 0.15, 0.15, 0.75, 1], [0, 0.15, 1, 1, 1, 0.15, 1], [0, 0, 0, 0, 0, 0, 0]], 'K': [[1, 0, 0, 0.15, 0.75, 0.15], [1, 0, 0.15, 1, 0.15, 0], [1, 0.15, 1, 0.15, 0, 0], [1, 0.75, 1, 0.15, 0, 0], [1, 0.15, 0.15, 0.75, 0, 0], [1, 0, 0, 0.75, 0.15, 0], [1, 0, 0, 0.15, 1, 0.15], [0, 0, 0, 0, 0, 0]], 'O': [[0, 0.15, 1, 1, 1, 0.15, 0], [0.15, 1, 0.15, 0.15, 0.15, 1, 0.15], [1, 0.15, 0, 0, 0, 0.15, 1], [1, 0.15, 0, 0, 0, 0.15, 1], [1, 0.15, 0, 0, 0, 0.15, 1], [0.15, 1, 0.15, 0.15, 0.15, 1, 0.15], [0, 0.15, 1, 1, 1, 0.15, 0], [0, 0, 0, 0, 0, 0, 0]], 'S': [[0.15, 1, 1, 1, 0.15], [1, 0.15, 0, 0.15, 1], [1, 0.15, 0, 0, 0], [0.15, 1, 0.75, 0.75, 0.15], [0, 0, 0.15, 0.75, 1], [1, 0.15, 0, 0.15, 1], [0.15, 1, 1, 1, 0.15], [0, 0, 0, 0, 0]], 'W': [[1, 0.15, 0, 0.15, 0.75, 0, 0, 0.75], [0.75, 0.15, 0, 0.75, 1, 0.15, 0, 1], [0.15, 0.75, 0, 1, 0.75, 0.15, 0.15, 1], [0.15, 0.75, 0.15, 0.75, 0.15, 0.75, 0.15, 0.75], [0, 1, 0.75, 0.75, 0, 1, 0.75, 0.15], [0, 0.75, 1, 0.15, 0, 0.75, 1, 0.15], [0, 0.75, 1, 0, 0, 0.75, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]], '[': [[1, 0.75], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]], '_': [[], [], [], [], [], [], [], []], 'c': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0.15, 0.75, 1, 1, 0.15], [0.75, 0.75, 0.15, 0.15, 1], [1, 0.15, 0, 0, 0], [1, 0.75, 0.15, 0.15, 1], [0.15, 0.75, 1, 1, 0.15], [0, 0, 0, 0, 0]], 'g': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0.15, 1, 1, 0.75, 1], [1, 0.15, 0.15, 0.75, 1], [1, 0.15, 0, 0.15, 1], [1, 0.15, 0.15, 0.75, 1], [0.15, 1, 1, 0.75, 1], [1, 0.15, 0.15, 0.75, 1]], 'k': [[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0.75, 0.75, 0], [1, 0.75, 0.75, 0, 0], [1, 0.75, 0.75, 0, 0], [1, 0, 0.75, 0.15, 0], [1, 0, 0.15, 1, 0.15], [0, 0, 0, 0, 0]], 'o': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0.15, 0.75, 1, 1, 0.15], [0.75, 0.75, 0.15, 0.75, 1], [1, 0.15, 0, 0.15, 1], [0.75, 0.75, 0.15, 0.75, 1], [0.15, 0.75, 1, 1, 0.15], [0, 0, 0, 0, 0]], 's': [[0, 0, 0, 0], [0, 0, 0, 0], [0.15, 1, 1, 0.15], [1, 0.15, 0.15, 1], [0.75, 1, 0.75, 0.15], [1, 0.15, 0.15, 1], [0.15, 1, 1, 0.75], [0, 0, 0, 0]], 'w': [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0.15, 1, 0, 0.75, 0.75], [0.75, 0.15, 0.75, 1, 0.15, 0.75, 0.15], [0.15, 0.75, 1, 0.75, 0.15, 0.75, 0], [0.15, 0.75, 1, 0.15, 1, 0.75, 0], [0, 0.75, 0.75, 0, 1, 0.15, 0], [0, 0, 0, 0, 0, 0, 0]], '{': [[0, 0.75, 1], [0, 1, 0.15], [0, 1, 0], [0.15, 1, 0], [0.75, 0.75, 0], [0.15, 1, 0], [0, 1, 0], [0, 1, 0.15]], '"': [[1, 1], [1, 1], [0.15, 0.15], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]], '&': [[0, 0.15, 1, 0.15, 0, 0], [0, 1, 0.15, 1, 0, 0], [0, 0.75, 0.75, 0.75, 0, 0], [0.15, 0.75, 0.75, 0.15, 0.15, 0], [1, 0.15, 0.15, 1, 0.75, 0], [1, 0.15, 0.15, 1, 0.75, 0], [0.15, 1, 1, 0.15, 0.75, 0.15], [0, 0, 0, 0, 0, 0]], '*': [[0.15, 1, 0.15], [0.75, 1, 0.75], [0.15, 0.15, 0.15], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]], '.': [[0], [0], [0], [0], [0], [0], [1], [0]], '2': [[0.15, 1, 1, 1, 0.15], [1, 0.15, 0.15, 0.15, 1], [0, 0, 0, 0.15, 1], [0, 0, 0.15, 1, 0.15], [0, 0.15, 0.75, 0.15, 0], [0, 0.15, 0, 0, 0], [0, 1, 1, 1, 1], [0, 0, 0, 0, 0]], '6': [[0, 0.75, 1, 1, 0.15], [0.75, 0.75, 0.15, 0.75, 0.75], [1, 0.15, 0, 0, 0], [1, 0.75, 1, 1, 0.15], [1, 0.15, 0, 0.15, 1], [0.75, 0.15, 0, 0.15, 1], [0.15, 1, 1, 1, 0.15], [0, 0, 0, 0, 0]], ':': [[0], [0], [1], [0], [0], [0], [1], [0]], '>': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0.15, 0, 0, 0, 0], [0.15, 0.75, 0.75, 0.15, 0], [0, 0, 0.15, 0.75, 0.75], [0, 0.15, 0.75, 0.75, 0.15], [0.15, 0.75, 0.15, 0, 0], [0, 0, 0, 0, 0]], 'B': [[1, 1, 1, 1, 0.15], [1, 0, 0, 0.15, 1], [1, 0, 0, 0.15, 1], [1, 1, 1, 1, 0.15], [1, 0, 0, 0.15, 1], [1, 0, 0, 0.15, 1], [1, 1, 1, 1, 0.15], [0, 0, 0, 0, 0]], 'F': [[1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0]], 'J': [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1], [1, 0.15, 0.15, 1], [0.75, 1, 1, 0.15], [0, 0, 0, 0]], 'N': [[1, 0.15, 0, 0, 1], [1, 0.75, 0, 0, 1], [1, 0.75, 0.15, 0, 1], [1, 0, 0.75, 0, 1], [1, 0, 0.15, 0.15, 1], [1, 0, 0, 0.75, 1], [1, 0, 0, 0.15, 1], [0, 0, 0, 0, 0]], 'R': [[1, 1, 1, 1, 0.15, 0], [1, 0, 0, 0.15, 1, 0], [1, 0, 0, 0.15, 1, 0], [1, 1, 1, 1, 0.15, 0], [1, 0, 0, 0.15, 1, 0], [1, 0, 0, 0, 1, 0], [1, 0, 0, 0, 1, 0.75], [0, 0, 0, 0, 0, 0]], 'V': [[0.75, 0.15, 0, 0, 0.15, 0.75], [0.15, 0.75, 0, 0, 0.75, 0.15], [0.15, 1, 0, 0.15, 1, 0], [0, 0.75, 0.15, 0.15, 0.75, 0], [0, 0.15, 0.75, 0.75, 0.15, 0], [0, 0.15, 1, 0.75, 0, 0], [0, 0, 0.75, 0.75, 0, 0], [0, 0, 0, 0, 0, 0]], 'Z': [[0.75, 1, 1, 1, 1, 0.15], [0, 0, 0, 0.15, 1, 0.15], [0, 0, 0.15, 1, 0.15, 0], [0, 0, 0.75, 0.15, 0, 0], [0, 0.75, 0.75, 0, 0, 0], [0.15, 0.75, 0, 0, 0, 0], [0.75, 1, 1, 1, 1, 0.15], [0, 0, 0, 0, 0, 0]], '^': [[0, 0.75, 0.75, 0], [0, 0.75, 0.75, 0.15], [0.15, 0.15, 0.15, 0.75], [0.15, 0.15, 0, 0.15], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], 'b': [[1, 0, 0, 0], [1, 0, 0, 0], [1, 0.75, 1, 0.15], [1, 0.15, 0.15, 1], [1, 0, 0, 1], [1, 0.15, 0.15, 1], [1, 0.75, 1, 0.15], [0, 0, 0, 0]], 'f': [[0, 0.75, 1], [0, 1, 0.15], [1, 1, 1], [0, 1, 0], [0, 1, 0], [0, 1, 0], [0, 1, 0], [0, 0, 0]], 'j': [[0, 1], [0, 0], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0.15, 1]], 'n': [[0, 0, 0, 0], [0, 0, 0, 0], [1, 0.75, 1, 0.75], [1, 0.15, 0.15, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1], [0, 0, 0, 0]], 'r': [[0, 0, 0], [0, 0, 0], [1, 0.75, 0.75], [1, 0.15, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0], [0, 0, 0]], 'v': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0.75, 0.15, 0, 0.75, 0.15], [0.75, 0.15, 0, 0.75, 0], [0.15, 0.75, 0.15, 0.75, 0], [0, 0.75, 0.75, 0.15, 0], [0, 0.75, 0.75, 0, 0], [0, 0, 0, 0, 0]], 'z': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0.75, 1, 1, 1, 0], [0, 0, 0.15, 0.75, 0], [0, 0.15, 0.75, 0, 0], [0.15, 0.75, 0, 0, 0], [0.75, 1, 1, 1, 0.15], [0, 0, 0, 0, 0]], '~': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0.75, 1, 0.75, 0.15, 1], [1, 0.15, 0.75, 1, 0.75], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]], '!': [[1], [1], [1], [1], [0.75], [0.15], [1], [0]], '%': [[0.15, 1, 1, 0.15, 0, 0.15, 0.15, 0], [1, 0.15, 0.15, 1, 0, 0.15, 0, 0], [1, 0.15, 0.15, 1, 0.15, 0.15, 0, 0], [0.15, 1, 1, 0.15, 0.75, 0, 0, 0], [0, 0, 0, 0.75, 0.15, 0.75, 1, 0.75], [0, 0, 0.15, 0.75, 0, 1, 0.15, 1], [0, 0, 0.75, 0.15, 0, 0.75, 1, 0.75], [0, 0, 0, 0, 0, 0, 0, 0]], ')': [[0.15, 0.75, 0], [0, 0.75, 0.15], [0, 0.15, 0.75], [0, 0.15, 1], [0, 0, 1], [0, 0.15, 1], [0, 0.15, 0.75], [0, 0.75, 0]], '-': [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [1, 1, 0.15], [0, 0, 0], [0, 0, 0], [0, 0, 0]], '1': [[0.15, 1], [1, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 0]], '5': [[0.15, 1, 1, 1, 0.75], [0.15, 0.75, 0, 0, 0], [0.15, 0.75, 1, 1, 0.15], [0.75, 0.75, 0.15, 0.75, 1], [0, 0, 0, 0.15, 1], [1, 0.75, 0.15, 0.75, 0.75], [0.15, 1, 1, 0.75, 0.15], [0, 0, 0, 0, 0]], '9': [[0.15, 0.75, 1, 0.75, 0.15], [0.75, 0.75, 0.15, 0.75, 0.75], [1, 0.15, 0, 0.15, 1], [1, 0.75, 0.15, 0.75, 1], [0.15, 1, 1, 0.75, 1], [0.75, 0.75, 0.15, 0.75, 0.75], [0.15, 1, 1, 0.75, 0.15], [0, 0, 0, 0, 0]], '=': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0.75, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0.75, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]], 'A': [[0, 0, 0.75, 0.75, 0, 0], [0, 0.15, 0.75, 1, 0.15, 0], [0, 0.15, 0.75, 0.75, 0.15, 0], [0, 0.75, 0.15, 0.15, 0.75, 0], [0.15, 1, 1, 1, 1, 0.15], [0.15, 0.75, 0, 0, 0.75, 0.15], [0.75, 0.15, 0, 0, 0.15, 0.75], [0, 0, 0, 0, 0, 0]], 'E': [[1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0]], 'I': [[1], [1], [1], [1], [1], [1], [1], [0]], 'M': [[1, 0.75, 0, 0, 0.75, 1], [1, 0.75, 0, 0, 0.75, 1], [1, 0.75, 0.15, 0.15, 0.75, 1], [1, 0.15, 0.15, 0.15, 0.15, 1], [1, 0.15, 0.75, 0.75, 0.15, 1], [1, 0, 0.75, 0.75, 0, 1], [1, 0, 0.75, 0.75, 0, 1], [0, 0, 0, 0, 0, 0]], 'Q': [[0, 0.15, 1, 1, 1, 0.15, 0], [0.15, 1, 0.15, 0.15, 0.15, 1, 0.15], [1, 0.15, 0, 0, 0, 0.15, 1], [1, 0.15, 0, 0, 0, 0.15, 1], [1, 0.15, 0, 0, 0.15, 0.15, 1], [0.15, 1, 0.15, 0.15, 0.75, 1, 0.15], [0, 0.15, 1, 1, 1, 0.75, 0.75], [0, 0, 0, 0, 0, 0, 0.15]], 'U': [[1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0.15, 0.15, 0.15, 1], [0.15, 1, 1, 1, 0.15], [0, 0, 0, 0, 0]], 'Y': [[0.15, 1, 0, 0, 0, 1, 0.15], [0, 0.75, 0.15, 0, 0.15, 0.75, 0], [0, 0.15, 1, 0.15, 1, 0.15, 0], [0, 0, 0.75, 1, 0.75, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]], ']': [[1, 0.75], [0, 0.75], [0, 0.75], [0, 0.75], [0, 0.75], [0, 0.75], [0, 0.75], [0, 0.75]], 'a': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0.15, 1, 1, 0.75, 0], [1, 0.15, 0.15, 1, 0], [0.15, 0.75, 0.75, 1, 0], [1, 0.75, 0.75, 1, 0.15], [0.75, 1, 0.75, 0.75, 0.75], [0, 0, 0, 0, 0]], 'e': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0.15, 0.75, 1, 1, 0.15], [0.75, 0.15, 0.15, 0.15, 0.75], [1, 1, 1, 1, 1], [0.75, 0.15, 0.15, 0.75, 0.75], [0.15, 0.75, 1, 0.75, 0.15], [0, 0, 0, 0, 0]], 'i': [[1], [0], [1], [1], [1], [1], [1], [0]], 'm': [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0.75, 0.75, 0.75, 1, 0.75], [1, 0.15, 1, 0.15, 0.15, 1], [1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 0, 1], [0, 0, 0, 0, 0, 0]], 'q': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0.15, 1, 1, 0.75, 1], [0.75, 0.75, 0.15, 0.75, 1], [1, 0.15, 0, 0.15, 1], [1, 0.75, 0.15, 0.75, 1], [0.15, 1, 1, 0.75, 1], [0, 0, 0, 0, 1]], 'u': [[0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 0.15, 0.15, 1], [0.75, 1, 0.75, 1], [0, 0, 0, 0]], 'y': [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0.75, 0.15, 0, 0.75, 0.15], [0.75, 0.75, 0, 0.75, 0], [0.15, 0.75, 0.15, 0.75, 0], [0, 0.75, 0.75, 0.15, 0], [0, 0.15, 1, 0, 0], [0, 0.75, 0.75, 0, 0]], '}': [[1, 0.75, 0], [0.15, 1, 0], [0, 1, 0], [0, 1, 0.15], [0, 0.75, 0.75], [0, 1, 0.15], [0, 1, 0], [0.15, 1, 0]]} # paste font dictionary here


if len(sys.argv) > 1:
    args = sys.argv
    del args[0]
    string_to_show = ' '.join(args)

    scroll_rows=[[0]*8]*8 # blank space at start of message

    for character in string_to_show:
        if character in font_dictionary:
            character_rows = font_dictionary[character]
        else:
            character_rows = font_dictionary['-']
        for i in range(8):
           scroll_rows[i] = scroll_rows[i]+character_rows[i]
           scroll_rows[i] += [0] # gap between letters

    for i in range(8):
        scroll_rows[i]+=[0]*8 # blank space at end of message

    for scroll_position in range(len(scroll_rows[0])-8):
示例#53
0
        index += 1
        if index >= maxPixels:
            #print index, maxPixels
            pixels = pixels[:maxPixels-1]    #trim the list as we've maxed out
            break
    UH.show()

#show all pixels one colour
def showColour(c):
    for coords in pattern:
        UH.set_pixel(coords[0], coords[1], c[0], c[1], c[2])
    UH.show()
                  
#main program

UH.rotation(180)
UH.brightness(0.4)

#process the currently available list of colours
data = getJSON("feed.json")
if mode != 2 and len(data) > 0:
    for feedItem in data["feeds"]:
        parseColour(feedItem)
    showPixels()

#check for new colour requests
while True:
    data = getJSON("field/1/last.json")
    
    if getEntryID(data) > lastID:   #Has this entry_id been processed before?
        parseColour(data)