def update(self, strip: LedStrip): strip.clear() for einBeschleuniger in self.meineBeschleuniger: einBeschleuniger.malen(strip) strip.transmit()
def paint(self, strip: LedStrip): # velocity_based_hue = min(math.pow(abs(self.v) / 2, 2), 0.9) velocity_based_brightness = max(math.pow(abs(self.v) / 2, 2), 0.1) * min(self.ttl / 3, 1) # strip.add_hsv(self.pos - self.radius, self.hue, 1, velocity_based_brightness) strip.add_hsv(self.pos, self.hue, 1, velocity_based_brightness) # strip.add_hsv(self.pos + self.radius, self.hue, 1, velocity_based_brightness) for i, hpos in enumerate(self.hist): strip.add_hsv(hpos, self.hue, 1, 1) # 1/len(self.hist) * i)
def update(self, strip: LedStrip): strip.clear() newStuff = [] for rocket in self.lauchners: results = rocket.move(PERIOD) # tickrate is perfect newStuff += results self.lauchners = newStuff for rocket in self.lauchners: rocket.paint(strip) strip.transmit()
def main(args): strip = LedStrip(args=args) global world world = LedWorld.from_json_file("data/heightmap.default.json") world.plot() game = Game(strip, world) game.loop()
def main(args): strip = LedStrip(args=args, loop=True, flip=True) w = World(strip) audio = pyaudio.PyAudio() try: stream = audio.open(format=pyaudio.paInt16, channels=2, rate=RATE, input=True, frames_per_buffer=INPUT_FRAMES_PER_BLOCK ) maximal = Amplitude() while True: data = stream.read(INPUT_FRAMES_PER_BLOCK) amp = Amplitude.from_data(data) if amp > maximal: maximal = amp #amp.display(scale=600, mark=maximal) update(None, strip, amp.to_int(scale=300), w) finally: stream.stop_stream() stream.close() audio.terminate()
def main(args): strip = LedStrip(args=args, led_count=600, power_limit=0.1) periodicx(Snake().update, Snake.PERIOD, strip)
def main(args): strip = LedStrip(args=args) periodicx(Fireworks().update, Fireworks.PERIOD, strip)
def main(args): strip = LedStrip(args=args) periodicx(Sines().update, Sines.PERIOD, strip)
def main(args): strip = LedStrip(args=args) periodicx(Noise().update, Noise.PERIOD, strip)
def main(args): strip = LedStrip(args=args, loop=True) periodicx(Rainbow(strip).update, Rainbow.PERIOD)
strip.off() cv2.destroyAllWindows() stream.stop() stream.finish() pixels = analyze(frames) positions = get_index_positions(pixels, strip.led_count) print(positions) ds = time.strftime("%Y-%m-%dT%H:%M:%S") fn = "data/heightmap.%s.json" % ds string_to_file(get_index_positions_json(pixels, strip.led_count), fn) print("exported heightmap to %s" % fn) y_min = min([y for (_, y) in positions.values()]) y_max = max([y for (_, y) in positions.values()]) for i, (x, y) in positions.items(): strip.set_hsv(i, (y - y_min) / (y_max - y_min), 1.0, 1.0) strip.transmit() draw_pixels(pixels, strip.led_count) if __name__ == '__main__': parser = argparse.ArgumentParser(description='pyledstrip detector') LedStrip.add_arguments(parser) main(parser.parse_args())
def paint(self, strip: LedStrip): strip.add_hsv(self.pos, 0.00, # self.ch, self.cs, self.cv)
def main(args): strip = LedStrip(args=args, loop=True) periodicx(World(strip).update, PERIOD, strip)
def paint(self, strip: LedStrip): strip.add_hsv(self.pos, random.uniform(0,1), #0.33, # self.ch, self.cs, self.cv / 100 )
def main(args): strip = LedStrip(args=args) periodicx(Mod().update, Mod.PERIOD, strip)
def main(args): strip = LedStrip(args=args) periodicx(Disco().update, Disco.PERIOD, strip)
def main(args): strip = LedStrip(args=args, loop=True) periodicx(Smooth(strip).update, Smooth.PERIOD)
def main(args): strip = LedStrip(args=args) strip.off()
def main(args): stream = VideoStream(0) stream.start() window_name = 'Preview' cv2.namedWindow(window_name) strip = LedStrip(args=args) for l in range(strip.led_count): strip.set_rgb(l, 1.0, 1.0, 1.0) strip.transmit() time.sleep(2.0) gray_code = cv2.structured_light.GrayCodePattern_create( strip.led_count, 1).generate()[1] frames = [] f = 0.1 for i in range(len(gray_code)): c = gray_code[i][0] for l in range(len(c)): strip.set_rgb(l, f * c[l] / 255.0, f * c[l] / 255.0, f * c[l] / 255.0) strip.transmit() time.sleep(0.5) grabbed, frame = stream.read() if not grabbed: print('Could not read frame') exit() frames.append(frame) cv2.imshow(window_name, frame) cv2.waitKey(15) print('%d frames recorded' % len(frames)) strip.off() cv2.destroyAllWindows() stream.stop() stream.finish() pixels = analyze(frames) positions = get_index_positions(pixels, strip.led_count) print(positions) ds = time.strftime("%Y-%m-%dT%H:%M:%S") fn = "data/heightmap.%s.json" % ds string_to_file(get_index_positions_json(pixels, strip.led_count), fn) print("exported heightmap to %s" % fn) y_min = min([y for (_, y) in positions.values()]) y_max = max([y for (_, y) in positions.values()]) for i, (x, y) in positions.items(): strip.set_hsv(i, (y - y_min) / (y_max - y_min), 1.0, 1.0) strip.transmit() draw_pixels(pixels, strip.led_count)
def malen(self, strip: LedStrip): strip.add_rgb((self.pos + self.startposition) * self.geschwindigkeit, self.r, self.g, self.b) self.pos = self.pos + 1