Browse Source

messing around with example code

Brennen Bearnes 4 years ago
commit
250e5c3030
3 changed files with 74 additions and 0 deletions
  1. 25
    0
      listener.js
  2. 3
    0
      listener.sh
  3. 46
    0
      raspipe.py

+ 25
- 0
listener.js View File

@@ -0,0 +1,25 @@
1
+#!/usr/bin/env node
2
+
3
+var net = require('net'),
4
+    sys = require('sys');
5
+
6
+net.createServer(onConnection).listen(5280);
7
+
8
+function onConnection(socket) {
9
+  socket.setNoDelay(true);
10
+
11
+  socket.addListener("connect", function () {
12
+    // sys.puts('client connected: ' + this.remoteAddress);
13
+  });
14
+
15
+  socket.addListener("data", function (data) {
16
+    sys.puts(data);
17
+  });
18
+
19
+  socket.addListener("end", function () {
20
+    // sys.puts('end of connection');
21
+    this.end();
22
+  });
23
+}
24
+
25
+sys.puts('Server running at 127.0.0.1:8124');

+ 3
- 0
listener.sh View File

@@ -0,0 +1,3 @@
1
+#!/usr/bin/env bash
2
+export SDL_FBDEV=/dev/fb1
3
+./listener.js | ./raspipe.py

+ 46
- 0
raspipe.py View File

@@ -0,0 +1,46 @@
1
+#!/usr/bin/env python
2
+# encoding: utf-8
3
+
4
+import sys
5
+import pygame
6
+import re
7
+
8
+pygame.init()
9
+
10
+size = width, height = 320, 240
11
+
12
+black = (0, 0, 0)
13
+white = (255,255,255)
14
+font_big = pygame.font.Font(None, 40) 
15
+
16
+screen = pygame.display.set_mode(size)
17
+
18
+line = sys.stdin.readline()
19
+while line:
20
+    stars = re.sub('\S', '★', line)
21
+
22
+    for event in pygame.event.get():
23
+      if event.type == pygame.QUIT:
24
+        sys.exit()
25
+
26
+    screen.fill(black)
27
+
28
+    text_surface = font_big.render(line, True, white)
29
+    rect = text_surface.get_rect(center=(160,120))
30
+    screen.blit(text_surface, rect)
31
+
32
+#   a = 100
33
+#   if pygame.key.get_focused():
34
+#     press = pygame.key.get_pressed()
35
+#     for i in xrange(0,len(press)):
36
+#       if press[i] == 1:
37
+#         name = pygame.key.name(i)
38
+#         text = font_big.render(name, True, white)
39
+#         screen.blit(text, (100, a))
40
+#         a=a+100
41
+#         if name == "q":
42
+#           sys.exit()
43
+
44
+    pygame.display.flip()
45
+
46
+    line = sys.stdin.readline()

Loading…
Cancel
Save