def cradle(): ground = GroundBase() ground.parse_args() delay = 0.5 while True: for x in range(1, 4): ground.set_nodes(set_color(x)) time.sleep(delay) for x in range(3, 1, -1): ground.set_nodes(set_color(x)) time.sleep(delay)
def main(): ground = GroundBase() ground.argparse.add_argument("--gif", help="Path to GIF file to load") ground.parse_args() file_path = ground.args.gif im = Image.open(file_path) palette = im.getpalette() pixels = im.load() width, height = im.size try: # per the docs, duration may not be present frame_delay = im.info.duration / 1000 # value is in ms except AttributeError: frame_delay = 0.1 temp_im = Image.new("RGB", im.size) while True: im.putpalette(palette) temp_im.paste(im) frame = Frame(source="gif:{}".format(file_path), width=width, height=height, image=temp_im) #print(pixels) ground.set_nodes_frame(frame) time.sleep(frame_delay) try: im.seek(im.tell() + 1) except EOFError: im.seek(0)
def main(): ground = GroundBase() ground.argparse.add_argument("--patch_file", help="Path to file with node patch", default="./node_patch.json") ground.argparse.add_argument("--serial_port", help="Serial port to outpute path", default="") ground.argparse.add_argument("--downsample_res", help="Size to reduce image to before sending to nodes, XxY", default="10x10") ground.parse_args() patch = {} with open(ground.args.patch_file, "r") as patch_file: patch = {int(pix): loc for pix, loc in json.load(patch_file).items()} down_res = [int(val) for val in ground.args.downsample_res.split("x")] nodes = NodeOutput(patch, ground.args.serial_port, down_res) ground.register_frame_received(nodes.handle_frame) ground.wait_for_frames()
def main(): ground = GroundBase() ground.parse_args() nodes = dict() degrees = 0 frame_delay = 0.01 while True: degrees += 1 # Map each node to a closes for node_id in [1, 3, 2, 4]: nodes[node_id] = color(degrees + node_id * 15) ground.set_nodes(nodes) time.sleep(frame_delay)
def main(): ground = GroundBase() ground.parse_args() nodes = dict() packet_index = 0 frame_delay = 0.1 while True: packet_index += 1 r = 255 if (packet_index % 8 >= 4) else 0 g = 255 if (packet_index % 4 >= 2) else 0 b = 255 if packet_index % 2 else 0 a = 255 # Map each node to a closes for node_id in range(6): nodes[node_id] = (r, g, b, a) ground.set_nodes(nodes) time.sleep(frame_delay)
def main(): ground = GroundBase() ground.parse_args() file_path = "color_bars.jpg" #file_path = "pixels2.bmp" im = Image.open(file_path) print(im, im.getpixel((0, 0))) pixels = im.load() for j in range(im.height): for i in range(im.width): print(i, j, pixels[i, j]) width, height = im.size frame = Frame(source="color_bars", width=width, height=height, image=im) print(type(frame.image), frame.width, frame.height, frame.image.size, frame.image.getpixel((0, 0))) while True: ground.send_frame(frame) time.sleep(1)
def __init__(self): super().__init__() ground = GroundBase() ground.parse_args() self.image_queue = Queue() self.receive_thread = GroundThread(target=ground.wait_for_frames, queue=self.image_queue) print('a') ground.register_frame_received(self.receive_thread.handle_frame) print('c') self.receive_thread.new_frame_signal.connect(self.show_frame) print('d') self.receive_thread.start() print('b') self.setWindowTitle("Constellation Viewer") self.setGeometry(10, 10, 100, 100) self.label = QLabel(self) self.label.setText("No Image Yet") print("created app") self.show()
def boom(node): ground = GroundBase() ground.parse_args() delay = 0.01 while True: for i in range(1, 10): ground.set_nodes(red(node)) time.sleep(1.0/i) ground.set_nodes(black(node)) time.sleep(1.0/i) ground.set_nodes(ready(node)) time.sleep(delay) ground.set_nodes(arm(node)) time.sleep(delay) ground.set_nodes(fire(node)) time.sleep(10)
def main(): ground = GroundBase() ground.parse_args() ground.register_frame_received(handle_frame) ground.wait_for_frames()