Created
August 5, 2017 16:36
-
-
Save sknebel/6c7928d37cf8c8805bd3df26d92a72dd to your computer and use it in GitHub Desktop.
mlight experiments
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
#import numpy | |
import socket | |
import time | |
import random | |
srv = "display.ilexlux.xyz" | |
srv = "localhost" | |
width = 15 | |
height=16 | |
def pos(row, column): | |
return (column+row*width)*3 | |
def send(data): | |
sock.sendto(data, (srv, 1337)) | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
#sock.sendto(data, (self.host, self.port)) | |
data = bytearray(3*16*15+4) | |
def random_bytes(): | |
while True: | |
time.sleep(0.05) | |
x=random.randint(0, 3*16*15-1) | |
data[x] = random.randint(0, 255) | |
send(data) | |
def blank(): | |
send(bytes(3*15*16+4)) | |
blank() | |
def randrow(data): | |
for i in range(pos(height-1, 0), pos(height-1, width-1)+3,3): | |
r = random.randint(180, 255) | |
g = random.randint(100, r) | |
b = random.randint(max(0,g-40), g) | |
b=0 | |
data[i] = r | |
data[i+1] = g | |
data[i+2] = b | |
def decay(init=randrow): | |
init(data) | |
send(data) | |
while True: | |
time.sleep(0.05) | |
data[0:pos(height-2,width-1)+3] = data[pos(1,0):pos(height-1, width-1)+3] | |
for i in range(0, pos(height-2, width-1),3): | |
data[i] = int(data[i]*0.85) | |
data[i+1] = int(data[i+1]*0.7) | |
data[i+2] = int(data[i+2]*0.6) | |
init(data) | |
send(data) | |
decay() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment