From e180313ef03b090de1ee3cfa41757cf0418e38bb Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 20 Feb 2014 11:52:53 +0100 Subject: README: fixed missing links --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index b6412a7..a63acc3 100644 --- a/README.rst +++ b/README.rst @@ -35,6 +35,8 @@ Related Projects * `A game programming framework for Mate Light`_ * `Snake for Mate Light`_ * `Game of Life for Mate Light`_ +* `Mate Light Android App`_ +* `Blinkenlights for Mate Light`_ .. _`A Python script that plays gifs over CRAP`: https://github.com/uwekamper/matelight-gifplayer .. _`An HTML5 CRAP emulator`: https://github.com/sodoku/matelightemu -- cgit From b87f6164dbd5d72a67fa33ce6c3d8ddffc8c2d6d Mon Sep 17 00:00:00 2001 From: Philip Stewart Date: Sat, 22 Feb 2014 17:27:05 +0100 Subject: Added node.js module --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index a63acc3..0ce1e2f 100644 --- a/README.rst +++ b/README.rst @@ -31,6 +31,7 @@ Related Projects ---------------- * `A Python script that plays gifs over CRAP`_ * `An HTML5 CRAP emulator`_ +* `A CRAP client for node.js`_ * `Webcam streaming on Mate Light`_ * `A game programming framework for Mate Light`_ * `Snake for Mate Light`_ @@ -40,6 +41,7 @@ Related Projects .. _`A Python script that plays gifs over CRAP`: https://github.com/uwekamper/matelight-gifplayer .. _`An HTML5 CRAP emulator`: https://github.com/sodoku/matelightemu +.. _`A CRAP client for node.js`: https://github.com/sodoku/node-matelight .. _`Webcam streaming on Mate Light`: https://github.com/c-base/matetv .. _`A game programming framework for Mate Light`: https://github.com/c-base/pymlgame .. _`Snake for Mate Light`: https://github.com/c-base/pymlsnake -- cgit From c4dd54e16fcc31c43c2ccccbb34eea07b9de735c Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 23 Feb 2014 10:37:15 +0100 Subject: README: Added a link to the Postillon newsticker --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 0ce1e2f..376db26 100644 --- a/README.rst +++ b/README.rst @@ -38,10 +38,12 @@ Related Projects * `Game of Life for Mate Light`_ * `Mate Light Android App`_ * `Blinkenlights for Mate Light`_ +* `Postillon Newsticker for Matelight`_ .. _`A Python script that plays gifs over CRAP`: https://github.com/uwekamper/matelight-gifplayer .. _`An HTML5 CRAP emulator`: https://github.com/sodoku/matelightemu .. _`A CRAP client for node.js`: https://github.com/sodoku/node-matelight +.. _`Postillon Newsticker for Matelight`: https://gist.github.com/XenGi/9168633 .. _`Webcam streaming on Mate Light`: https://github.com/c-base/matetv .. _`A game programming framework for Mate Light`: https://github.com/c-base/pymlgame .. _`Snake for Mate Light`: https://github.com/c-base/pymlsnake -- cgit From b503b8fffc43dad16a64ec34799c28757bd127d2 Mon Sep 17 00:00:00 2001 From: Uwe Kamper Date: Fri, 7 Mar 2014 22:18:10 +0100 Subject: multithreaded frame-queueing and polling in the server classes --- host/server.py | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/host/server.py b/host/server.py index 56002fa..0de0edc 100755 --- a/host/server.py +++ b/host/server.py @@ -83,7 +83,29 @@ def log(*args): print(strftime('[%m-%d %H:%M:%S]'), ' '.join(str(arg) for arg in args), '\x1B[0m') printlock.release() + +class MateLightUDPServer(UDPServer): + """ + The server class for the SocketServer interface. + """ + def __init__(self, *args, **kwargs): + """ + Setup the deque for the frame + """ + super(MateLightUDPServer, self).__init__(*args, **kwargs) + self.frame_deque = collections.deque(maxlen=30) + + def get_next_frame(self): + try: + return self.frame_deque.popleft() + except IndexError: + return None + + class MateLightUDPHandler(BaseRequestHandler): + """ + Handles one UDP connection to the matelight + """ def handle(self): try: # Housekeeping - FIXME: This is *so* the wrong place for this. @@ -113,8 +135,9 @@ class MateLightUDPHandler(BaseRequestHandler): if current_entry.entrytype == 'udp' and current_entry.remote == addr: current_entry = conn frame = a.reshape((DISPLAY_HEIGHT, DISPLAY_WIDTH, 3)) - sendframe(frame) - printframe(np.pad(frame, ((0,0),(0,0),(0,1)), 'constant', constant_values=(0,0))) + self.server.frame_deque.append(frame) + #sendframe(frame) + #printframe(np.pad(frame, ((0,0),(0,0),(0,1)), 'constant', constant_values=(0,0))) except Exception as e: log('Error receiving UDP frame:', e) @@ -131,19 +154,25 @@ class MateLightTCPTextHandler(BaseRequestHandler): textqueue.append(QueueEntry('text', addr, timestamp, data)) self.request.sendall(b'KTHXBYE!\n') -TCPServer.allow_reuse_address = True -server = TCPServer(('', 1337), MateLightTCPTextHandler) -t = threading.Thread(target=server.serve_forever) -t.daemon = True -t.start() +#TCPServer.allow_reuse_address = True +#server = TCPServer(('', 1337), MateLightTCPTextHandler) +#t = threading.Thread(target=server.serve_forever) +#t.daemon = True +#t.start() UDPServer.allow_reuse_address = True -userver = UDPServer(('', 1337), MateLightUDPHandler) +userver = MateLightUDPServer(('', 1337), MateLightUDPHandler) t = threading.Thread(target=userver.serve_forever) t.daemon = True t.start() if __name__ == '__main__': + while True: + next_frame = userver.get_next_frame() + if next_frame: + sendframe(next_frame) + +def bla(): print('\033[2J'+'\n'*9) while True: if current_entry.entrytype == 'text': -- cgit From 8166cb4bb22b479e2e09a608499c09a6e09c3b44 Mon Sep 17 00:00:00 2001 From: Uwe Kamper Date: Fri, 7 Mar 2014 22:37:16 +0100 Subject: 20 frames per second --- host/server.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/host/server.py b/host/server.py index 0de0edc..511267c 100755 --- a/host/server.py +++ b/host/server.py @@ -168,9 +168,16 @@ t.start() if __name__ == '__main__': while True: + millis = int(round(time.time() * 1000)) + next_frame = userver.get_next_frame() if next_frame: sendframe(next_frame) + + while int(round(time.time() * 1000)) - millis < 50: + // do nothing + pass + def bla(): print('\033[2J'+'\n'*9) -- cgit