Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

draw a identifying text on each panel

  • Loading branch information...
commit b52d6b8431902c742882a609d044d12ade190851 1 parent 71c60bc
@osresearch authored
Showing with 43 additions and 41 deletions.
  1. +39 −32 identify
  2. +4 −9 matrix-udp-rx.c
View
71 identify
@@ -1,32 +1,39 @@
-#!/usr/bin/perl
-use warnings;
-use strict;
-
-# Make a bargraph to help identify which port is which
-# R Y G C B W
-
-my $width = 10;
-my $height = 32;
-
-my $s = '1';
-
-for(my $y = 0 ; $y < $height ; $y++)
-{
- for(my $x = 0 ; $x < $width ; $x++)
- {
- my $v = ($y % 8) >= $x ? 0x10 : 0;
- my $r = 0;
- my $g = 0;
- my $b = 0;
- $r = $v if int($y / 8) == 0;
- $g = $v if int($y / 8) == 1;
- $b = $v if int($y / 8) == 2;
- $g = $r = $v if int($y / 8) == 3;
-
- $s .= chr($r);
- $s .= chr($g);
- $s .= chr($b);
- }
-}
-
-print $s;
+#!/usr/bin/python
+# Draw an image with PIl that has the coordinates
+# in flashing colors
+#
+import Image, ImageFont, ImageDraw
+import socket
+import time, datetime
+from colorsys import hsv_to_rgb
+
+sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+dest = ("localhost", 9999)
+
+#print im.format, im.size, im.mode
+# use a truetype font
+font = ImageFont.truetype("pf_tempesta_seven.ttf", 8)
+
+i = 0
+width = 256
+height = 64
+disp = Image.new("RGB", (width,height), "black")
+disp_draw = ImageDraw.Draw(disp)
+
+def rainbow(i):
+ rgb = [int(x*256) for x in hsv_to_rgb(i/256.0,0.8,0.8)]
+ return (rgb[0],rgb[1],rgb[2])
+
+
+while True:
+ disp.paste("black", (0,0,width,height))
+
+ for x in range(0,width, 32):
+ for y in range(0,height, 16):
+ s = str(x) + "," + str(y)
+ disp_draw.text((x+2, y), s, font=font, fill=rainbow(i))
+
+ # Send it to the drawing server
+ sock.sendto(chr(1) + disp.tostring(), dest)
+ i = (i+1) % width
+ time.sleep(0.025)
View
13 matrix-udp-rx.c
@@ -25,9 +25,6 @@
#include "bitslice.h"
#include "ledscape.h"
-static int port = 9999;
-static unsigned width = 16;
-static unsigned height = 256;
static int
udp_socket(
@@ -62,7 +59,7 @@ main(
die("socket port %d failed: %s\n", port, strerror(errno));
const unsigned width = 256;
- const unsigned height = 16;
+ const unsigned height = 64;
const size_t image_size = width * height * 3;
// largest possible UDP packet
@@ -72,13 +69,14 @@ main(
fprintf(stderr, "%u x %u, UDP port %u\n", width, height, port);
- ledscape_t * const leds = ledscape_init(width);
+ ledscape_t * const leds = ledscape_init(width, height);
const unsigned report_interval = 10;
unsigned last_report = 0;
unsigned long delta_sum = 0;
unsigned frames = 0;
+ uint32_t * const fb = calloc(width*128,4);
while (1)
{
@@ -119,9 +117,6 @@ main(
gettimeofday(&start_tv, NULL);
const unsigned frame_num = 0;
- ledscape_frame_t * const frame
- = ledscape_frame(leds, frame_num);
- uint32_t * const fb = (void*) frame;
for (unsigned x = 0 ; x < width ; x++)
{
@@ -136,7 +131,7 @@ main(
}
}
- ledscape_draw(leds, frame_num);
+ ledscape_draw(leds, fb);
gettimeofday(&stop_tv, NULL);
timersub(&stop_tv, &start_tv, &delta_tv);
Please sign in to comment.
Something went wrong with that request. Please try again.