corr_b_v = [0.0, 0.13, 0.18, 1.0] def set_pixel_2d(bar, x, y, r, g, b): bar.set_pixel(WIDTH - x - 1 + y * WIDTH, r, g, b) def cdist(center, point, scale): dist = math.sqrt( reduce(lambda a, b: a + b, map(lambda (x, y): (x - y)**2, zip(center, point)))) dist = dist * scale return dist l = Ledbar(PIXELS) M = max(WIDTH, HEIGHT) center_b = [0, 0] work = True t = 0 while work: center_r = [ math.sin(t) * (M / 2) + WIDTH / 2 - 1, math.cos(t) * (M / 2) + HEIGHT / 2 - 1 ] center_g = [ math.sin(t * 0.53234) * (M / 2) + WIDTH / 2 - 1, HEIGHT / 2 - 1 ] print("red: ", center_r[0],
for rule, func in RULE.items(): if rule(sum(top)/3): new.append(func(sum(top)/3)) else: new.append(0) iterations[j] = new return iterations def update(i): visibles = [] for iteration in iterations: visibles.append(iteration[(len(iteration)//2)-(WIDTH//2):(len(iteration)//2)+(WIDTH//2)]) if PIXEL_MODE == 'bw': return (visibles[0][i], visibles[0][i], visibles[0][i]) elif PIXEL_MODE == 'color': return (visibles[0][3*i], visibles[0][3*i+1], visibles[0][3*i+2]) elif PIXEL_MODE == 'individual_color': return (visibles[0][i], visibles[1][i], visibles[2][i]) l = Ledbar(PIXELS) work = True t = 0 while work: for i in xrange(PIXELS): c = update(i) l.set_pixel(i, c[0], c[1], c[2]) work = l.update() t += 1 if not (t % SLEEP): iterations = iterate(iterations)
col = col + 1 if col == self.letter_dx(idx): idx += 1 if idx >= self.scroll_len: idx = 0 col = 0 self.col += 1 if self.col >= self.letter_dx(self.idx): self.idx = (self.idx + 1) % self.scroll_len self.col = 0 return ledbar.update() l = Ledbar(PIXELS) work = True scroll = TextScroller() class WebThread(threading.Thread): def __init__(self): self.lineNum = -1 self.line = "" self.mutex = threading.Lock() threading.Thread.__init__(self) def run(self): while (True): self.loop()
corr_g_v = [0.0, 0.08, 0.2, 1.0] corr_b_p = [0.0, 0.6, 0.75, 1.0] corr_b_v = [0.0, 0.13, 0.18, 1.0] def set_pixel_2d(bar, x, y, r, g, b): bar.set_pixel(WIDTH - x - 1 + y * WIDTH, r, g, b) def cdist(center, point, scale): dist = math.sqrt(reduce(lambda a, b: a + b, map(lambda (x, y): (x - y) ** 2, zip(center, point)))) dist = dist * scale return dist l = Ledbar(PIXELS) M = max(WIDTH, HEIGHT) center_b = [0, 0] work = True t = 0 while work: center_r = [math.sin(t) * (M / 2) + WIDTH / 2 - 1, math.cos(t) * (M / 2) + HEIGHT / 2 - 1] center_g = [math.sin(t * 0.53234) * (M / 2) + WIDTH / 2 - 1, HEIGHT / 2 - 1] print("red: ", center_r[0], center_r[1], " green: ", center_g[0], center_g[1], end=" \r", file=sys.stderr) for x in range(WIDTH): for y in range(HEIGHT): r = cdist(center_r, [x, y], 0.2) r = lint(r, corr_r_p, corr_r_v) g = cdist(center_g, [x, y], 0.2) g = lint(g, corr_g_p, corr_g_v)
import sys from ledbar import Ledbar PIXELS = 20 def update(t, i): offset = float(i)/PIXELS time = 0.005*t phi = 6*offset+time phase = int(phi%6) part = phi % 1.0 inc = part dec = 1-part if phase == 0: return ( 1, inc, 0) elif phase == 1: return (dec, 1, 0) elif phase == 2: return ( 0, 1, inc) elif phase == 3: return ( 0, dec, 1) elif phase == 4: return (inc, 0, 1) elif phase == 5: return ( 1, 0, dec) l = Ledbar(PIXELS) t = 0 work = True while work: for i in xrange(PIXELS): c = update(t, i) l.set_pixel(i, c[0], c[1], c[2]) work = l.update() t += 1