Пример #1
0
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)
Пример #2
0
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()
Пример #3
0
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)
Пример #4
0
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()
Пример #5
0
def printLetter(letter, x, r, g, b):

    if (letter > 47) and (letter < 58):
        letter = letter - 47
    elif letter == 35:  # #
        letter = 41

    elif letter == 42:  # *
        letter = 43
    elif letter == 43:  # +
        letter = 42
    elif letter == 45:  # -
        letter = 44
    elif letter == 46:  # .
        letter = 38
    elif letter == 47:  # /
        letter = 39
    elif letter == 58:  # :
        letter = 40
    elif letter == 61:  # =
        letter = 45

    else:
        letter = letter - 53
    if letter < 1:
        letter = 0

    Font_Letter = Font_ABC[letter]
    for fy in range(6):
        for fx in range(5):
            if (x + fx >= 0) and (x + fx < 17):
                if Font_Letter[fy][fx] == 1:
                    send(x + fx, fy, r, g, b, tick)
                else:
                    send(x + fx, fy, back_r, back_g, back_b, tick)
Пример #6
0
def printLetter( letter, x,r,g,b):
	 
	if(letter>47) and (letter<58):
		letter=letter-47
	elif letter==35: # #
		letter=41

	elif letter==42: # *
		letter=43
	elif letter==43: # +
		letter=42
	elif letter==45: # -
		letter=44
	elif letter==46: # .
		letter=38
	elif letter==47: # /
		letter=39
	elif letter==58: # :
		letter=40
	elif letter==61: # =
		letter=45

	else:
		letter=letter-53
	if letter<1:
		letter=0
	 
	Font_Letter=Font_ABC[letter]
	for fy in range(6):
		for fx in range(5):
			if (x+fx>=0) and(x+fx<17) :
				if Font_Letter[fy][fx] == 1:
					send(x+fx,fy,r, g,b, tick)
				else:
					send(x+fx,fy,back_r, back_g,back_b, tick)
Пример #7
0
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()
Пример #8
0
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()
Пример #9
0
def printDigit(digit, x,r,g,b):
	Font_Letter=Font_ABC[digit]
	for fy in range(6):
		for fx in range(4):
			if (x+fx)>=0:
				if Font_Letter[fy][fx] == 1:
					send(x+fx,fy,r, g,b, tick)
				else:
					send(x+fx,fy,back_r, back_g,back_b, tick)
Пример #10
0
def printDigit(digit, x, r, g, b):
    Font_Letter = Font_ABC[digit]
    for fy in range(6):
        for fx in range(4):
            if (x + fx) >= 0:
                if Font_Letter[fy][fx] == 1:
                    send(x + fx, fy, r, g, b, tick)
                else:
                    send(x + fx, fy, back_r, back_g, back_b, tick)
Пример #11
0
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)
Пример #12
0
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 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()
Пример #14
0
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)
Пример #15
0
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)
Пример #16
0
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)
Пример #17
0
	def goForward(self):
		global wait
		self.tail = [self.position]+self.tail
		if self.position != foodposition:
			self.deltail = self.tail[-1]
			del self.tail[-1]
		else:
			newFoodPosition(self)
			redrawAll(player)
			wait /= 1.1
		acabsl.send(self.position[0],self.position[1],*tail,t=wait)
		self.position = self.direction.getNewPos(self.position)
		for i in self.tail:
			if self.position == i:
				raise posInTailError
		"""if self.position != foodposition:
Пример #18
0
 def goForward(self):
     global wait
     self.tail = [self.position] + self.tail
     if self.position != foodposition:
         self.deltail = self.tail[-1]
         del self.tail[-1]
     else:
         newFoodPosition(self)
         redrawAll(player)
         wait /= 1.1
     acabsl.send(self.position[0], self.position[1], *tail, t=wait)
     self.position = self.direction.getNewPos(self.position)
     for i in self.tail:
         if self.position == i:
             raise posInTailError
     """if self.position != foodposition:
Пример #19
0
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)
Пример #20
0
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)
Пример #21
0
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)
Пример #22
0
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 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 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()
Пример #25
0
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()
Пример #26
0
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()
Пример #27
0
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()
Пример #28
0
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()
Пример #29
0
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()
Пример #30
0
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()
Пример #31
0
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()
Пример #32
0
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()
Пример #33
0
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()
Пример #34
0
 def draw_single(self, pos, colour, fade=0):
     acabsl.send(pos[0], pos[1], *colour, t=fade)
Пример #35
0
    def draw(self, t, fade=0):
        super(RainbowCurvePoint, self).draw(t, fade)
        self.recolour_step(0)

    def recolour_step(self, t):
        self.h = (self.h + 1. / self.spectrum_size) % 1.
        self.colour = hsv_hue_colour(self.h)


def roundtrip_cw(t, width=12, height=2):
    # only supports height = 2 /o\
    if (t / width) % 2 == 0:
        return (t % width, 0)
    return (width - 1 - (t % width), 1)


if __name__ == "__main__":
    for x in range(acabsl.WALLSIZEX):
        for y in range(acabsl.WALLSIZEY):
            acabsl.send(x, y, 0, 0, 0)
    acabsl.update()

    sleep_time = 0.07
    t = 0
    point = RainbowCurvePoint(roundtrip_cw, tail=5)
    while True:
        point.draw(t, fade=sleep_time)
        acabsl.update()
        time.sleep(sleep_time)
        t += 1
Пример #36
0
def set_pattern():
    set_all(0, 0, 0)
    r = random.random() * 127 + 127
    g = random.random() * 127 + 127
    b = random.random() * 127 + 127

    acabsl.send(5, 0, r, g, b)
    acabsl.send(5, 0, r, g, b)
    acabsl.send(7, 0, r, g, b)
    acabsl.send(8, 0, r, g, b)
    acabsl.send(9, 0, r, g, b)
    acabsl.send(0xA, 0, r, g, b)
    acabsl.send(0xD, 0, r, g, b)

    acabsl.send(6, 1, r, g, b)
    acabsl.send(8, 1, r, g, b)
    acabsl.send(9, 1, r, g, b)
    acabsl.send(0xC, 1, r, g, b)

    acabsl.send(6, 2, r, g, b)
    acabsl.send(8, 2, r, g, b)
    acabsl.send(0xB, 2, r, g, b)
    acabsl.send(0xC, 2, r, g, b)

    acabsl.send(5, 3, r, g, b)
    acabsl.send(5, 3, r, g, b)
    acabsl.send(7, 3, r, g, b)
    acabsl.send(0xA, 3, r, g, b)
    acabsl.send(0xC, 3, r, g, b)
    acabsl.send(0xD, 3, r, g, b)
    acabsl.send(0xE, 3, r, g, b)

    acabsl.send(0x8, 4, r, g, b)
    acabsl.send(0x9, 4, r, g, b)
    acabsl.send(0xB, 4, r, g, b)
Пример #37
0
def setcol(col, r, g, b, time):
    for i in range(0, 6):
        send(col, i, r, g, b, time)
Пример #38
0
def setcol(col, r, g, b, time):
    for i in range(0,6):
    	send(col,i,r,g,b,time);
Пример #39
0
def set_col(col,r,g,b,t):
    for w in range(acabsl.NOOFWALLS):
        for y in range(acabsl.WALLSIZEY):
            acabsl.send(col,y,r,g,b,t,w)
Пример #40
0
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()
Пример #41
0
    ]
    """
    universe = []
    for x in range ( 0 , maxX ):
        universe.append( [] )
        for y in range ( 0 , maxY + 1 ):
            universe[x].append( cell( x , y , random.randint(0,1) ))
    return universe


u = randomUniverse()
h_dead = 0
update()
while 1:
    h_dead += random.gauss(0.02,0.05)
    h_dead = h_dead% 1
    h_alive = (h_dead + 0.5)%1
    rd, gd, bd = colorsys.hsv_to_rgb(h_dead,.3, .2)
    ra, ga, ba = colorsys.hsv_to_rgb(h_alive,1., 1.) 

    for i in range (0, maxX ):
        for j in range (0, maxY):
            if ( u[i][j].getState() == 0 ):
                send(i , j , rd*255, gd*255, bd*255 , tick*0.5)
            else:
                send(i , j , ra*255, ba*255, ba*255 , tick*0.5)
            u[i][j].updateState(u)
    update()
    time.sleep(tick)

Пример #42
0
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()
Пример #43
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()
Пример #44
0
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)
Пример #45
0
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)
Пример #46
0
def printCLS():
    update()
    for fx in range(16):
        for fy in range(6):
            send(fx, fy, back_r, back_g, back_b, tick)
    update()
Пример #47
0
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()
Пример #48
0
def setcol(col, r, g, b, time):
    for i in range(0, acabsl.WALLSIZEY):
        send(col, i, r, g, b, time)
    update()
Пример #49
0
def set_all(r,g,b,t):
    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,t,w)
Пример #50
0
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()


acabsl.update()
for c in range(0, 8):
    for r in range(0, 6):
        acabsl.send(wall, c, r, 0, 0, 0, 0.5)
acabsl.update()
time.sleep(0.5)

x = 1
y = 0
lastc = 0
c = 0
mode = 0
lastm = 0

while 1:
    while c == lastc:
        c = random.randint(0, 5)
    lastc = c
Пример #51
0
    dr = row - midrow
    dist = math.sqrt(dc**2+dr**2)
    if dist > maxdist:
      maxdist = dist

hoffset = 0
update()
while 1:
  midcol = min(acabsl.WALLSIZEX-2,max(1, midcol + random.gauss(0,0.1)))
  midrow = min(acabsl.WALLSIZEY-2,max(1, midrow + random.gauss(0,0.1)))

  #hoffset += random.gauss(0.01,0.02)
  hoffset += 0.03
  hoffset = hoffset % 1.
  #t = time.time()

  for row in range(0,acabsl.WALLSIZEY):
    for col in range(0,acabsl.WALLSIZEX):
      dc = col - midcol
      dr = row - midrow
      dist = math.sqrt(dc**2+dr**2)/maxdist
      h = (math.atan2(dc, dr) + math.pi/2)/math.pi/2
      h = (h+hoffset) % 1.
      r,g,b = colorsys.hsv_to_rgb(h, dist, 1)
      send(int(col), int(row), r*255, g*255, b*255, tick*2)
  #print time.time()-t
  update()
  time.sleep(tick)
    

Пример #52
0
def reset():
	acabsl.update()
	for i in xrange(width):
		for j in xrange(height):
			acabsl.send(i,j,*background)
	acabsl.update()
Пример #53
0
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()
Пример #54
0
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()
Пример #55
0
    for col in range(0, acabsl.WALLSIZEX):
        dc = col - midcol
        dr = row - midrow
        dist = math.sqrt(dc**2 + dr**2)
        if dist > maxdist:
            maxdist = dist

hoffset = 0
update()
while 1:
    midcol = min(acabsl.WALLSIZEX - 2, max(1, midcol + random.gauss(0, 0.1)))
    midrow = min(acabsl.WALLSIZEY - 2, max(1, midrow + random.gauss(0, 0.1)))

    #hoffset += random.gauss(0.01,0.02)
    hoffset += 0.03
    hoffset = hoffset % 1.
    #t = time.time()

    for row in range(0, acabsl.WALLSIZEY):
        for col in range(0, acabsl.WALLSIZEX):
            dc = col - midcol
            dr = row - midrow
            dist = math.sqrt(dc**2 + dr**2) / maxdist
            h = (math.atan2(dc, dr) + math.pi / 2) / math.pi / 2
            h = (h + hoffset) % 1.
            r, g, b = colorsys.hsv_to_rgb(h, dist, 1)
            send(int(col), int(row), r * 255, g * 255, b * 255, tick * 2)
    #print time.time()-t
    update()
    time.sleep(tick)
Пример #56
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()