def main_no_artsync(universe, ip='127.0.0.1', tmp=5): packet_size = 512 port = 6454 a = StupidArtnet(ip, port, universe, packet_size) a.flash_all() # send single packet with all channels at 255 file.write(StupidArtnet.print_object_and_packet(a)) a.start() time.sleep(tmp) a.stop()
def main_no_artsync(universe1, universe2, ip1='127.0.0.1', ip2='127.0.0.2', tmp=5): packet_size = 512 port = 6454 a1 = StupidArtnet(ip1, port, universe1, packet_size) a2 = StupidArtnet(ip2, port, universe2, packet_size) a1.flash_all() # send single packet with all channels at 255 a2.flash_all() file.write(StupidArtnet.print_object_and_packet(a1)) file.write(StupidArtnet.print_object_and_packet(a1)) a1.start() a2.start() time.sleep(tmp) a1.stop() a2.stop()
def sendImageToMatrix(img): for y in range(10): for x in range(10): pixel = img.getpixel((x, y)) print(pixel, end='') packet[y * 30 + x * 3] = pixel[0] packet[y * 30 + x * 3 + 1] = pixel[1] packet[y * 30 + x * 3 + 2] = pixel[2] print() a.set(packet) a.show() def textToImage(text): img = Image.new('RGB', (10, 10)) d = ImageDraw.Draw(img) d.text((0, 0), text, fill=(255, 255, 255), font=fnt7) s = io.BytesIO() img.save(f'images/{text}.bmp') return img img = textToImage("02") sendImageToMatrix(img) # hotfix lib error a.start() a.stop() del a
# ... AND SEND a.show() # send data # OR USE STUPIDARTNET FUNCTIONS a.flash_all() # send single packet with all channels at 255 time.sleep(1) # wait a bit, 1 sec a.blackout() # send single packet with all channels at 0 a.see_buffer() # ALL THE ABOVE EXAMPLES SEND A SINGLE DATAPACKET # STUPIDARTNET IS ALSO THREADABLE # TO SEND PERSISTANT SIGNAL YOU CAN START THE THREAD a.start() # start continuos sendin # AND MODIFY THE DATA AS YOU GO for x in range(100): for i in range(packet_size): # Fill buffer with random stuff packet[i] = random.randint(0, 255) a.set(packet) time.sleep(.2) # SOME DEVICES WOULD HOLD LAST DATA, TURN ALL OFF WHEN DONE a.blackout() # ... REMEMBER TO CLOSE THE THREAD ONCE YOU ARE DONE a.stop()