You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.0 KiB
Python

#!/usr/bin/env python3
import sys
import io
import socket
sys.path.append('..')
from waves import create_wpotd
SERVER_IP = '192.168.178.75'
SERVER_PORT = 1234
def chunker(seq, size):
return (seq[pos:pos + size] for pos in range(0, len(seq), size))
#buf = io.BytesIO()
#surface = create_wpotd(buf)
#
#data = surface.get_data()
#pixels = data.hex()
#
#x, y = 0, 0
#for hexpx in chunker(pixels, 8):
# if x > 1919:
# x = 0
# y += 1
# pxstr = f'PX {x} {y} {hexpx[:6]}'
# x += 1
# print(pxstr)
def surface_to_pixelflut(surface):
data = surface.get_data()
pixels = data.hex()
x, y = 0, 0
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((SERVER_IP, SERVER_PORT))
for hexpx in chunker(pixels, 8):
if x > 1919:
x = 0
y += 1
pxstr = f'PX {x} {y} {hexpx[:6]}\n'
x += 1
if hexpx[6:8] == '00':
continue
s.sendall(pxstr.encode())
print('transmission to pixelflut finished')