v0.4 with a combined example at the end of the usage.

pull/1/head
Jürgen Weigert 6 years ago
parent fc3892d977
commit 2fb3af8779
  1. 32
      README.md
  2. 22
      led-badge-11x44.py
  3. BIN
      photos/love_my_fablab.jpg

@ -26,32 +26,39 @@ Required dependencies on Debian/Ubuntu Systems:
sudo python3 ./led-badge-11x44.py "Hello World!"
loads the text 'Hello World!' as the first message, and scrolls it from right to left (default scroll mode=0) and speed 4 (default). After each upload, press the little button next to the USB connector once to see the first message permanently. If you don't press the button, the device shows the message only once and returns to the charging screen. Sudo may or may not be needed, depending on your system.
loads the text 'Hello World!' as the first message, and scrolls it from right to left (default scroll mode=0) and speed 4 (default). After an upload the device shows the first message once and returns to the charging screen if still connected to USB. Either pull the plug or press the small button next to the USB connector.
Sudo may or may not be needed, depending on your system.
sudo python3 ./led-badge-11x44.py -m 6 -s 8 Hello World!
loads the text 'Hello' as message one and 'World!' as message two. Note the diffrence in quoting. Up to 8 messages can be uploaded. This example uses mode 6, which is dromps the words with a nice little animation vertically into the display area. Speed is set to maximum here, so that the animation is very smooth. Per default you will only see 'Hello'. To get both messages alternating, press the little button next to the USB connector two more times, so that the message 'M1-8' appears. Now the display loops through all uploaded messages.
loads the text 'Hello' as message one and 'World!' as message two. Note the diffrence in quoting. Up to 8 messages can be uploaded. This example uses mode 6, which is dromps the words with a nice little animation vertically into the display area. Speed is set to maximum here, so that the animation is very smooth. Per default you will only see 'Hello'.
To see all messages, press the small button next to the USB connector multiple times, until you briefly see 'M1-8'. Now the display loops through all uploaded messages.
sudo python3 ./led-badge-11x44.py -m 5 gfx/fablabnbg_logo_44x11.png
loads a fullscreen still image. (Or displays the pathname, if the image was not found. That is a hack. Sorry)
sudo python3 ./led-badge-11x44.py -l gfx/heart.png -l gfx/fablab_logo_16x11.png "I^Amy^Bfablab^B"
sudo python3 ./led-badge-11x44.py -p gfx/heart.png -p gfx/fablab_logo_16x11.png "I^Amy^Bfablab^B"
preloads two images, a heart and a crude fablab logo as images 1 and two. The images can then be embedded in a message by using control characters. To enter the ^A control character on the shell, press CTRL-V followed by CTRL-A.
![LED Mini Board](photos/love_my_fablab.jpg)
python3 ./led-badge-11x44.py --help
prints some condensed help:
<pre>
Usage: led-badge-11x44.py [-h] [-s SPEED] [-m MODE] [-l FILE]
message [message ...]
Usage: led-badge-11x44.py [-h] [-s SPEED] [-m MODE] [-p FILE]
MSG_OR_FILENAME [MSG_OR_FILENAME ...]
./led-badge-11x44.py Version 0.3 -- upload messages to a 44x11 led badge via
USB HID. https://github.com/jnweiger/led-badge-44x11
Upload messages or graphics to a 44x11 led badge via USB HID. Version 0.4 from
https://github.com/jnweiger/led-badge-44x11 -- see there for more examples and
for updates.
positional arguments:
message Up to 8 message texts or image file names
MSG_OR_FILENAME Up to 8 message texts or image file names
optional arguments:
-h, --help show this help message and exit
@ -61,8 +68,13 @@ optional arguments:
-m MODE, --mode MODE Up to 8 mode values: Scroll-left(0) -right(1) -up(2)
-down(3); still-centered(4) -left(5); drop-down(6);
curtain(7); laser(8)
-l FILE, --load FILE Bitmap images, made available as ^A, ^B, ^C, ... in
text messages
-p FILE, --preload FILE
Load bitmap images. Use ^A, ^B, ^C, ... in text
messages to make them visible
Example combining image and text (enter the ^A character as CTRL-V CTRL-A):
sudo ./led-badge-11x44.py -p gfx/heart.png I^Ayou
</pre>

@ -14,7 +14,7 @@
#
# v0.1, 2019-03-05, jw initial draught. HID code is much simpler than expected.
# v0.2, 2019-03-07, jw support for loading bitmaps added.
# v0.3 jw option -l to load graphics for inline use in text.
# v0.3 jw option -p to preload graphics for inline use in text.
# v0.4, 2019-03-08, jw Warning about unused images added. Examples added to the README.
import sys, os, re, array, time, argparse
@ -151,7 +151,7 @@ char_offset = {}
for i in range(len(charmap)):
char_offset[charmap[i]] = 11 * i
bitmap_loaded = [ ([],0) ]
bitmap_preloaded = [ ([],0) ]
bitmaps_unused = False
def bitmap_char(ch):
@ -162,7 +162,7 @@ def bitmap_char(ch):
if ord(ch) < 32:
global bitmaps_unused
bitmaps_unused = False
return bitmap_loaded[ord(ch)]
return bitmap_preloaded[ord(ch)]
o = char_offset[ch]
return (font_11x44[o:o+11],1)
@ -185,7 +185,7 @@ def bitmap_img(file):
from PIL import Image
im = Image.open(file)
print("loading bitmap from file %s -> (%d x %d)" % (file, im.width, im.height))
print("preloading bitmap from file %s -> (%d x %d)" % (file, im.width, im.height))
if im.height != 11:
sys.exit("%s: image height must be 11px. Seen %d" % (file, im.height))
buf = array.array('B')
@ -239,11 +239,11 @@ def header(lengths, speeds, modes):
return h
parser = argparse.ArgumentParser(description='%s Version %s -- upload messages to a 44x11 led badge via USB HID. https://github.com/jnweiger/led-badge-44x11' % (sys.argv[0], __version))
parser = argparse.ArgumentParser(description='Upload messages or graphics to a 44x11 led badge via USB HID. Version %s from https://github.com/jnweiger/led-badge-44x11 -- see there for more examples and for updates.' % __version, epilog="Example combining image and text (enter the ^A character as CTRL-V CTRL-A): sudo %s -p gfx/heart.png I^Ayou" % sys.argv[0])
parser.add_argument('-s', '--speed', default='4', help="Scroll speed. Up to 8 comma-seperated values (range 1..8)")
parser.add_argument('-m', '--mode', default='0', help="Up to 8 mode values: Scroll-left(0) -right(1) -up(2) -down(3); still-centered(4) -left(5); drop-down(6); curtain(7); laser(8)")
parser.add_argument('-l', '--load', metavar='FILE', action='append', help="Bitmap images, made available as ^A, ^B, ^C, ... in text messages")
parser.add_argument('message', nargs='+', help="Up to 8 message texts or image file names")
parser.add_argument('-p', '--preload', metavar='FILE', action='append', help="Load bitmap images. Use ^A, ^B, ^C, ... in text messages to make them visible")
parser.add_argument('message', metavar='MSG_OR_FILENAME', nargs='+', help="Up to 8 message texts or image file names")
args = parser.parse_args()
dev = usb.core.find(idVendor=0x0416, idProduct=0x5020)
@ -256,9 +256,9 @@ if dev.is_kernel_driver_active(0):
dev.set_configuration()
print("using [%s %s] bus=%d dev=%d" % (dev.manufacturer, dev.product, dev.bus, dev.address))
if args.load:
for file in args.load:
bitmap_loaded.append(bitmap_img(file))
if args.preload:
for file in args.preload:
bitmap_preloaded.append(bitmap_img(file))
bitmaps_unused = True
msgs = []
@ -266,7 +266,7 @@ for arg in args.message:
msgs.append(bitmap(arg))
if bitmaps_unused == True:
print("\nWARNING:\n Your preloaded images are not used.\n Try without '-l' or embed the control character '^A' in your message.\n")
print("\nWARNING:\n Your preloaded images are not used.\n Try without '-p' or embed the control character '^A' in your message.\n")
buf = array.array('B')
buf.extend(header(list(map(lambda x: x[1], msgs)), args.speed, args.mode))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 162 KiB

Loading…
Cancel
Save