#!/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_IP = '127.0.0.1' SERVER_PORT = 1234 def chunker(seq, size): return (seq[pos:pos + size] for pos in range(0, len(seq), size)) def surface_to_pixelflut(): global DRAW_MAP while True: data = DRAW_MAP.get_data() pixels = data.hex() x, y = 0, 0 to_send = list() for hexpx in chunker(pixels, 8): if x > 1919: x = 0 y += 1 x += 1 if hexpx[6:8] == '00': continue pxstr = f'PX {x} {y} {hexpx[:6]}\n' to_send.append(pxstr) with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((SERVER_IP, SERVER_PORT)) print('!! socket opened !!') for px in to_send: s.sendall(px.encode()) #print(f'sent {pxstr}') print('!! transmission to pixelflut finished !!')