Permalink
Browse files

Scrolling multi-color example; removed bitmap test since it is no lon…

…ger used
  • Loading branch information...
1 parent 90d571c commit 004865b2c56e7841b58fbd296b65e837c5c782c7 @osresearch committed Sep 15, 2013
Showing with 24 additions and 82 deletions.
  1. +0 −76 bitmap-test.c
  2. BIN pf_tempesta_seven.ttf
  3. +24 −6 python-test
View
@@ -1,76 +0,0 @@
-/** \file
- * Test the matrix LCD PRU firmware by displaying an image.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <time.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <unistd.h>
-#include "ledscape.h"
-
-int
-main(
- int argc,
- char ** argv
-)
-{
- const int num_pixels = 256;
- ledscape_t * const leds = ledscape_init(num_pixels);
-
- FILE * f = fopen(argv[1], "r");
- uint8_t * buf = calloc(1<<20, 1);
- size_t len = fread(buf, 1, 1<<20, f);
- printf("len=%zu\n", len);
-
- buf += 0x82; // skip the BMP header (hardcoded)
-
- time_t last_time = time(NULL);
- unsigned last_i = 0;
-
- unsigned i = 0;
- while (1)
- {
- // Alternate frame buffers on each draw command
- const unsigned frame_num = i++ % 2;
- ledscape_frame_t * const frame
- = ledscape_frame(leds, frame_num);
-
- uint32_t * const p = (void*) frame;
-
- for (unsigned x = 0 ; x < num_pixels ; x++)
- {
- for (unsigned y = 0 ; y < 16 ; y++)
- {
- uint8_t j = (i >> 6);
- uint8_t * const inpx = (void*) &buf[4 * ((x + j) % num_pixels) + num_pixels * (16 - y) * 4];
- uint8_t * const px = (void*) &p[x + num_pixels * y];
-
- px[0] = inpx[0];
- px[1] = inpx[1];
- px[2] = inpx[2];
- }
- }
- ledscape_draw(leds, frame_num);
- usleep(100);
-
- // wait for the previous frame to finish;
- //const uint32_t response = ledscape_wait(leds);
- const uint32_t response = 0;
- time_t now = time(NULL);
- if (now != last_time)
- {
- printf("%d fps. starting %d previous %"PRIx32"\n",
- i - last_i, i, response);
- last_i = i;
- last_time = now;
- }
-
- }
-
- ledscape_close(leds);
-
- return EXIT_SUCCESS;
-}
View
Binary file not shown.
View
@@ -1,33 +1,51 @@
#!/usr/bin/python
# Draw images with PIL and send them to the display.
+# Dual scrolling example with fixed time on each side and
+# the date scrolling around.
#
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)
-logo = Image.open("futurecrew.png")
#print im.format, im.size, im.mode
# use a truetype font
-font = ImageFont.truetype("spincycle.ttf", 24)
+font = ImageFont.truetype("spincycle.ttf", 18)
+font_sm = ImageFont.truetype("pf_tempesta_seven.ttf", 8)
i = 0
width = 256
disp = Image.new("RGB", (256,16), "black")
im = Image.new("RGB", (width,16), "black")
-draw = ImageDraw.Draw(im)
+im_draw = ImageDraw.Draw(im)
+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:
im.paste("black", (0,0,width,16))
- t = datetime.datetime.now().strftime("%a %d %b %H:%M:%S")
- draw.text((0, -4), t, font=font)
+ now = datetime.datetime.now()
+ d = now.strftime("%a %d %b %Y")
+ t = now.strftime("%H:%M")
+ # Draw the date
+ im_draw.text((0, -2), d, font=font, fill=rainbow(i))
+
+ # Make it scroll
disp.paste(im.crop((0,0,i,16)), (256-i,0))
disp.paste(im.crop((i+1,0,255,16)), (0,0))
- # Slice a 256 size image from the large image
+ # draw the time on each face
+ for x in range(0,7):
+ disp_draw.text((4+x*32, 8-3), t, font=font_sm)
+
+ # Send it to the drawing server
sock.sendto(chr(1) + disp.tostring(), dest)
i = (i+1) % width
time.sleep(0.025)

0 comments on commit 004865b

Please sign in to comment.