def set_decke(r,g,b): acabsl.set_target("127.0.0.1",8002) for w in range(acabsl.NOOFWALLS): for x in range(acabsl.WALLSIZEX): for y in range(acabsl.WALLSIZEY): acabsl.send(x,y,r,g,b,1,w) acabsl.update()
def text(text, repetitions=1, colour=(0, 42, 42), interval=0.3, marquee=True): text = text.upper() matrix = [] for i in range(len(text)): if text[i] not in alphabet: continue for j in range(len(alphabet[text[i]][0])): matrix.append([]) for k in range(len(alphabet[text[i]]) - 1, -1, -1): matrix[-1].append(alphabet[text[i]][k][j]) matrix.append([0] * len(alphabet[text[i]])) for i in range(repetitions): for j in range(0 if not marquee else (-acabsl.WALLSIZEX), len(matrix)): for x in range(acabsl.WALLSIZEX): for y in range(acabsl.WALLSIZEY): if x + j < len(matrix) and x + j >= 0 and matrix[ x + j][y] == 1: set_single(x, acabsl.WALLSIZEY - 1 - y, *colour, fade_time=interval / 2.) else: set_single(x, acabsl.WALLSIZEY - 1 - y, 0, 0, 0, fade_time=interval / 2.) acabsl.update() time.sleep(interval)
def update_screen(columns): '''send the columns to the leds''' for x,col in enumerate(columns): for y,color in enumerate(col): r,g,b = color send(WALL,x,y,r,g,b,FADE_TIME) update()
def set_all(r, g, b): for w in range(acabsl.NOOFWALLS): for x in range(acabsl.WALLSIZEX): for y in range(acabsl.WALLSIZEY): acabsl.send(x, y, r, g, b, 0, w) acabsl.update() time.sleep(4)
def set_all(r,g,b): for w in range(acabsl.NOOFWALLS): for x in range(acabsl.WALLSIZEX): for y in range(acabsl.WALLSIZEY): acabsl.send(x,y,r,g,b,0,w) acabsl.update() time.sleep(4)
def drawMap(player, seefood): acabsl.send(player.position[0], player.position[1], *head) if player.deltail: acabsl.send(player.deltail[0], player.deltail[1], 0, 0, 0) if seefood: acabsl.send(foodposition[0], foodposition[1], *foodcolor, t=wait) else: acabsl.send(foodposition[0], foodposition[1], 0, 0, 0, wait) acabsl.update()
def drawc(c,r,c1): acabsl.send(c,r,cs[0][c1],cs[1][c1],cs[2][c1],tfade,wall) for x in range(c,7): acabsl.send(x,r,cs[0][c1],cs[1][c1],cs[2][c1],tfade,wall) for y in range(r,6): acabsl.send(c,y,cs[0][c1],cs[1][c1],cs[2][c1],tfade,wall) acabsl.update()
def drawMap(player,seefood): acabsl.send(player.position[0],player.position[1],*head) if player.deltail: acabsl.send(player.deltail[0],player.deltail[1],0,0,0) if seefood: acabsl.send(foodposition[0],foodposition[1],*foodcolor,t=wait) else: acabsl.send(foodposition[0],foodposition[1],0,0,0,wait) acabsl.update()
def setcol(cols, time): for x in range(0, acabsl.WALLSIZEX): h = cols[x] r = math.sin(math.pi * h) g = math.sin(math.pi * (h + 1.0 / 3)) b = math.sin(math.pi * (h + 2.0 / 3)) for y in range(0, acabsl.WALLSIZEY): send(x, y, r * r * 255, g * g * 255, b * b * 255, time) update()
def warp_ring(wall, row, time): for i in range(cols): if row < rows - 1: send(i,(row+1)%rows,r/shade,g/shade,b/shade,time*1.5,wall); if row <= rows - 1: send(i,row,r,g,b,time/2,wall); if row > 0 and row <= rows: send(i, (row-1)%(rows),r/shade,g/shade,b/shade,time*1.5,wall); update()
def setcol(cols, time): for x in range(0,acabsl.WALLSIZEX): h = cols[x] r = math.sin(math.pi * h) g = math.sin(math.pi * (h + 1.0/3)) b = math.sin(math.pi * (h + 2.0/3)) for y in range(0,acabsl.WALLSIZEY): send(x,y,r*r*255,g*g*255,b*b*255,time); update()
def drawb(c, r, c1): acabsl.send(wall, c, r, cs[0][c1], cs[1][c1], cs[2][c1], tfade) for x in range(c, 7): acabsl.send(wall, x, r, cs[0][c1], cs[1][c1], cs[2][c1], tfade) for y in range(0, r): acabsl.send(wall, c, y, cs[0][c1], cs[1][c1], cs[2][c1], tfade) acabsl.update()
def drawd(c, r, c1): acabsl.send(wall, c, r, cs[0][c1], cs[1][c1], cs[2][c1], tfade) for x in range(1, c): acabsl.send(wall, x, r, cs[0][c1], cs[1][c1], cs[2][c1], tfade) for y in range(r, 6): acabsl.send(wall, c, y, cs[0][c1], cs[1][c1], cs[2][c1], tfade) acabsl.update()
def drawa(c,r,c1): acabsl.send(c,r,cs[0][c1],cs[1][c1],cs[2][c1],tfade,wall) for x in range(1,c): acabsl.send(x,r,cs[0][c1],cs[1][c1],cs[2][c1],tfade,wall) for y in range(0,r): acabsl.send(c,y,cs[0][c1],cs[1][c1],cs[2][c1],tfade,wall) acabsl.update()
def drawd(c, r, c1): acabsl.send(c, r, cs[0][c1], cs[1][c1], cs[2][c1], tfade, wall) for x in range(1, c): acabsl.send(x, r, cs[0][c1], cs[1][c1], cs[2][c1], tfade, wall) for y in range(r, 6): acabsl.send(c, y, cs[0][c1], cs[1][c1], cs[2][c1], tfade, wall) acabsl.update()
def drawb(c, r, c1): acabsl.send(c, r, cs[0][c1], cs[1][c1], cs[2][c1], tfade, wall) for x in range(c, 7): acabsl.send(x, r, cs[0][c1], cs[1][c1], cs[2][c1], tfade, wall) for y in range(0, r): acabsl.send(c, y, cs[0][c1], cs[1][c1], cs[2][c1], tfade, wall) acabsl.update()
def warp_ring(wall, row, time): for i in range(cols): if row < rows - 1: send(wall,i,row+1,r/shade,g/shade,b/shade,time); if row <= rows - 1: send(wall,i,row,r,g,b,time); if row > 0 and row <= rows: send(wall,i, row-1,r/shade,g/shade,b/shade,time); update()
def warp_ring(wall, row, time): for i in range(cols): if row < rows - 1: send(i, row + 1, r / shade, g / shade, b / shade, time, wall) if row <= rows - 1: send(i, row, r, g, b, time, wall) if row > 0 and row <= rows: send(i, row - 1, r / shade, g / shade, b / shade, time, wall) update()
def redrawAll(player,seefood=True): acabsl.update() for i in xrange(width): for j in xrange(height): acabsl.send(i,j,0,0,0) acabsl.update() for i in player.tail: acabsl.send(i[0],i[1],*tail) acabsl.send(player.position[0],player.position[1],*head) if seefood: acabsl.send(foodposition[0],foodposition[1],*foodcolor,t=wait)
def warp_ring(wall, row, time): for i in range(cols): if row < rows - 1: send(i, (row + 1) % rows, r / shade, g / shade, b / shade, time * 1.5, wall) if row <= rows - 1: send(i, row, r, g, b, time / 2, wall) if row > 0 and row <= rows: send(i, (row - 1) % (rows), r / shade, g / shade, b / shade, time * 1.5, wall) update()
def redrawAll(player, seefood=True): acabsl.update() for i in xrange(width): for j in xrange(height): acabsl.send(i, j, 0, 0, 0) acabsl.update() for i in player.tail: acabsl.send(i[0], i[1], *tail) acabsl.send(player.position[0], player.position[1], *head) if seefood: acabsl.send(foodposition[0], foodposition[1], *foodcolor, t=wait)
def fill(dimensions, color, ftime, draw = True): walls, cols, lines = dimensions r, g, b = color for w in range(walls): for col in range(cols): for l in range(lines): acabsl.send(col, l, r, g, b, ftime, w) if draw: acabsl.update() time.sleep(ftime)
def printMarquee(text, r, g, b): printCLS() text = text.upper() + " " pos_x = 8 while 1: update() pos_x = pos_x - 1 time.sleep(tick * 5) for act_l in range(len(text)): printLetter(ord(text[act_l]), (act_l * 5) + pos_x, r, g, b) if (pos_x < 0 - len(text) * 5): pos_x = 16
def printMarquee( text,r,g,b): printCLS() text=text.upper()+" " pos_x = 8 while 1: update() pos_x=pos_x-1 time.sleep(tick*5) for act_l in range(len(text)): printLetter(ord(text[act_l]),(act_l*5)+pos_x,r,g,b) if(pos_x<0-len(text)*5): pos_x=16
def render_frame(wall, image_data, angle): ptr = 0 for y in range(rows): for x in range(cols): x += angle x = x % cols if type(image_data[ptr]) == int: send(x,y,image_data[ptr],image_data[ptr],image_data[ptr],0,wall); else: send(x,y,image_data[ptr][0],image_data[ptr][1],image_data[ptr][2],0,wall); ptr += 1 update()
def fill(dimensions, color, ftime, draw=True): walls, cols, lines = dimensions r, g, b = color for w in range(walls): for col in range(cols): for l in range(lines): acabsl.send(col, l, r, g, b, ftime, w) if draw: acabsl.update() time.sleep(ftime)
def render_frame(wall, image_data, angle): ptr = 0 for y in range(rows): for x in range(cols): x += angle x = x % cols if type(image_data[ptr]) == int: send(wall,x,y,image_data[ptr],image_data[ptr],image_data[ptr],0); else: send(wall,x,y,image_data[ptr][0],image_data[ptr][1],image_data[ptr][2],0); ptr += 1 update()
def vlscan(dimensions, direction, fgcolor, bgcolor, delay, ftime, cl=False): walls, cols, lines = dimensions rev = 0 > direction d = -1 if rev else 1 for line in reversed(range(lines)) if rev else range(lines): if cl: fill(dimensions, bgcolor, ftime, False) hline(dimensions, max(-1, line + d), fgcolor, ftime, False) hline(dimensions, line, bgcolor, ftime, False) acabsl.update() time.sleep(ftime + delay)
def vlscan(dimensions, direction, fgcolor, bgcolor, delay, ftime, cl = False): walls, cols, lines = dimensions rev = 0 > direction d = -1 if rev else 1 for line in reversed(range(lines)) if rev else range(lines): if cl: fill(dimensions, bgcolor, ftime, False) hline(dimensions, max(-1, line + d), fgcolor, ftime, False) hline(dimensions, line, bgcolor, ftime, False) acabsl.update() time.sleep(ftime + delay)
def hpscan(dim, direction, bgcolor, delay, ftime, pat, cl = True): walls, cols, lines = dim all_cols = range(-1 * cols, 1 + cols * walls) rev = 0 > direction d = -1 if rev else 1 for col in reversed(all_cols) if rev else all_cols: if cl: fill(dim, bgcolor, 0, False) pat(dimensions=dim, x=col, ftime=ftime, draw=False) acabsl.update() time.sleep(ftime + delay)
def hpscan(dim, direction, bgcolor, delay, ftime, pat, cl=True): walls, cols, lines = dim all_cols = range(-1 * cols, 1 + cols * walls) rev = 0 > direction d = -1 if rev else 1 for col in reversed(all_cols) if rev else all_cols: if cl: fill(dim, bgcolor, 0, False) pat(dimensions=dim, x=col, ftime=ftime, draw=False) acabsl.update() time.sleep(ftime + delay)
def pattern(dimensions, x, y, color, ftime, pixels, draw=True): walls, cols, lines = dimensions def map_pixel(dimensions, x, y, pixel): walls, cols, lines = dimensions px, py, pcolor = pixel return int((x + px) / cols), (x + px) % cols, y + py, pcolor for p in pixels: w, c, l, (r, g, b) = map_pixel(dimensions, x, y, p) if w > -1 and c > -1 and l > -1 and w < walls and c < cols and l < lines: acabsl.send(c, l, r, g, b, ftime, w) if draw: acabsl.update() time.sleep(ftime)
def pattern(dimensions, x, y, color, ftime, pixels, draw = True): walls, cols, lines = dimensions def map_pixel(dimensions, x, y, pixel): walls, cols, lines = dimensions px, py, pcolor = pixel return int((x + px) / cols), (x + px) % cols, y + py, pcolor for p in pixels: w, c, l, (r, g, b) = map_pixel(dimensions, x, y, p) if w>-1 and c>-1 and l>-1 and w<walls and c<cols and l<lines: acabsl.send(c, l, r, g, b, ftime, w) if draw: acabsl.update() time.sleep(ftime)
def rain(steps=23, interval=0.3): drops = [] infinite = False if steps == 0: infinite = True while infinite or (steps > 0): new_drops = [] for drop in drops: if drop[1] > 0: new_drops.append([drop[0], drop[1] - 1]) drops = new_drops drops.append( [random.randint(0, acabsl.WALLSIZEX - 1), acabsl.WALLSIZEY - 1]) for x in range(acabsl.WALLSIZEX): for y in range(acabsl.WALLSIZEY): if [x, y] in drops: set_single(x, acabsl.WALLSIZEY - 1 - y, 0, 0, 255, 0.7) else: set_single(x, acabsl.WALLSIZEY - 1 - y, 0, 0, 0, 0.7) acabsl.update() steps -= 1 time.sleep(interval)
def blank_walls(row, time): for col in range(cols): for wall in range(wall_count): send(col, (row - 2) % rows, 0, 0, 0, time, wall) update()
def blank_walls(): for col in range(cols): for row in range(rows): for wall in range(wall_count): send(wall,col,row,0,0,0,0); update()
def set_all(r, g, b): for w in range(1): for x in range(2): for y in range(12): acabsl.send(x, y, r, g, b, 1, 1) acabsl.update()
def setcol(col, r, g, b, rtime): for i in range(0,acabsl.WALLSIZEY): send(col,i,r,g,b,rtime,0); send(acabsl.WALLSIZEX - col - 1,i,r,g,b,rtime,0); update() time.sleep(tick)
def setcol(col, r, g, b, rtime): for i in range(0, acabsl.WALLSIZEY): send(col, i, r, g, b, rtime) update() time.sleep(tick)
def setcol(cols, time): for x in range(0,acabsl.WALLSIZEX): r,g,b = colorsys.hsv_to_rgb(cols[x], 1., 1.) for y in range(0,acabsl.WALLSIZEY): send(x,y,r*255,g*255,b*255,time); update()
def blank_walls(): for col in range(cols): for row in range(rows): for wall in range(wall_count): send(col, row, 0, 0, 0, 0, wall) update()
def setcol(col, r, g, b, time): for i in range(0,acabsl.WALLSIZEY): c = (col+i+1)%(acabsl.WALLSIZEX) send(c,i,r,g,b,time); update()
def setcol(col, r, g, b, time): for i in range(0, acabsl.WALLSIZEY): send(col, i, r, g, b, time) update()
def setcol(col, r, g, b, time): for i in range(0,6): send(col,i,r,g,b,time); update()
def send(pos,rgb,fadet=0): acabsl.send(pos[0],pos[1],*rgb,t=fadet) acabsl.update()
def printCLS(): update() for fx in range(16): for fy in range(6): send(fx, fy, back_r, back_g, back_b, tick) update()
def setcol(col, r, g, b, time): for i in range(0, NOOFPIXELSY): c = (col + i + 1) % (NOOFPIXELSX) send(c, i, r, g, b, time) update()
def setcol(col, r, g, b, time): for i in range(0,NOOFPIXELSY): c = (col+i+1)%(NOOFPIXELSX) send(WALL,c,i,r,g,b,time); update()
from acabsl import send from acabsl import update import acabsl import colorsys import random import time TICK = 3.7 def setcol(col, r, g, b, time): for i in range(0,acabsl.WALLSIZEY): c = (col+i+1)%(acabsl.WALLSIZEX) send(c,i,r,g,b,time); update() h = 0 col = 0 update() while 1: h += random.gauss(0.02,0.05) h = h % 1. col += 1 col = col % acabsl.WALLSIZEX r,g,b = colorsys.hsv_to_rgb(h, 1., 1.) setcol(col, r*255, g*255, b*255, TICK*3) time.sleep(TICK)
def printCLS(fade): update() for fx in range(16): for fy in range(6): send(fx,fy,back_r, back_g,back_b,fade) update()
import random import time TICK = 0.2 WALL = 0 NOOFPIXELSX=8 NOOFPIXELSY=6 def setcol(col, r, g, b, time): for i in range(0,NOOFPIXELSY): c = (col+i+1)%(NOOFPIXELSX) send(WALL,c,i,r,g,b,time); update() h = 0 col = 0 update() while 1: h += random.gauss(0.02,0.05) h = h % 1. col += 1 col = col % 8 r,g,b = colorsys.hsv_to_rgb(h, 1., 1.) setcol(col, r*255, g*255, b*255, TICK*3) time.sleep(TICK)
def reset(): acabsl.update() for i in xrange(width): for j in xrange(height): acabsl.send(i,j,*background) acabsl.update()
#!/usr/bin/env python # -*- coding: utf-8 -*- import acabsl import time t = 1 acabsl.update() def set_all(r,g,b): set_wall(r,g,b) set_decke(r,g,b) def set_wall(r,g,b): acabsl.set_target("127.0.0.1",6002) for w in range(acabsl.NOOFWALLS): for x in range(acabsl.WALLSIZEX): for y in range(acabsl.WALLSIZEY): acabsl.send(x,y,r,g,b,1,w) acabsl.update() def set_decke(r,g,b): acabsl.set_target("127.0.0.1",8002) for w in range(acabsl.NOOFWALLS): for x in range(acabsl.WALLSIZEX): for y in range(acabsl.WALLSIZEY): acabsl.send(x,y,r,g,b,1,w) acabsl.update() def set_all_to_black(): set_all(0,0,0)
def blank_walls(row, time): for col in range(cols): for wall in range(wall_count): send(col,(row-2)%rows,0,0,0,time,wall); update()
def set_random(r,g,b): for w in [random.choice(range(acabsl.NOOFWALLS))]: for x in [random.choice(range(acabsl.WALLSIZEX))]: for y in [random.choice(range(acabsl.WALLSIZEY))]: acabsl.send(x,y,r,g,b,0,w) acabsl.update()
def reset(): acabsl.update() for i in xrange(width): for j in xrange(height): acabsl.send(i, j, *background) acabsl.update()