Last active
February 22, 2020 19:58
-
-
Save Tom-Archer/2aa6ba2ef6ed5658b39421f8a4add6d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socket import * | |
from mote import Mote | |
import signal | |
import sys | |
def signal_handler(signal, frame): | |
recvSocket.close() | |
mote.clear() | |
mote.show() | |
sys.exit(0) | |
signal.signal(signal.SIGINT, signal_handler) | |
leds = 64 | |
pixels = 16 | |
gamma_correction = False | |
iteration = 0 | |
mote = Mote() | |
mote.configure_channel(1, pixels, gamma_correction) | |
mote.configure_channel(2, pixels, gamma_correction) | |
mote.configure_channel(3, pixels, gamma_correction) | |
mote.configure_channel(4, pixels, gamma_correction) | |
mote.clear() | |
mote.set_pixel(1, 0, 255, 0, 0) | |
mote.show() | |
recvSocket = socket(AF_INET, SOCK_DGRAM) | |
recvSocket.settimeout(1) | |
recvSocket.bind(('', 21324)) | |
while True: | |
print(iteration%1024) | |
iteration=iteration+1 | |
try: | |
message, address = recvSocket.recvfrom(1024) | |
if (message[0] == 2): #DRGB | |
if (len(message) == 194): | |
mote.clear() | |
for led in range(leds): | |
mote.set_pixel(led//16+1, led%16, message[2+(led*3)], message[3+(led*3)], message[4+(led*3)]) | |
mote.show() | |
except timeout: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment