def update(self, strip: LedStrip): strip.clear() for einBeschleuniger in self.meineBeschleuniger: einBeschleuniger.malen(strip) strip.transmit()
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): 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)