diff --git a/README.md b/README.md index 6b5c6fa..4c5e3e2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Led-Badge-44x11 Upload tool for an led name tag with USB-HID interface -![LED Mini Board](green_badge.jpg) +![LED Mini Board](photos/green_badge.jpg) ## Warning @@ -34,12 +34,15 @@ loads the text 'Hello' as message one and 'World!' as message two. Note the diff sudo python3 ./led-badge-11x44.py -m 5 gfx/fablabnbg_logo_44x11.png -loads a fullscreen still image. +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" 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) + +
Usage: led-badge-11x44.py [-h] [-s SPEED] [-m MODE] [-l FILE] message [message ...] diff --git a/gfx/heart.png b/gfx/heart.png new file mode 100644 index 0000000..91925a0 Binary files /dev/null and b/gfx/heart.png differ diff --git a/gfx/heart_full.png b/gfx/heart_full.png new file mode 100644 index 0000000..2f9bab3 Binary files /dev/null and b/gfx/heart_full.png differ diff --git a/led-badge-11x44.py b/led-badge-11x44.py index 329f900..8f69666 100755 --- a/led-badge-11x44.py +++ b/led-badge-11x44.py @@ -15,11 +15,12 @@ # 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.4, 2019-03-08, jw Warning about unused images added. Examples added to the README. import sys, os, re, array, time, argparse import usb.core -__version = "0.3" +__version = "0.4" font_11x44 = ( # 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' @@ -151,13 +152,17 @@ for i in range(len(charmap)): char_offset[charmap[i]] = 11 * i bitmap_loaded = [ ([],0) ] +bitmaps_unused = False def bitmap_char(ch): """ Returns a tuple of 11 bytes, ch = '_' returns (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255) The bits in each byte are horizontal, highest bit is left. """ - if ord(ch) < 32: return bitmap_loaded[ord(ch)] + if ord(ch) < 32: + global bitmaps_unused + bitmaps_unused = False + return bitmap_loaded[ord(ch)] o = char_offset[ch] return (font_11x44[o:o+11],1) @@ -254,11 +259,15 @@ print("using [%s %s] bus=%d dev=%d" % (dev.manufacturer, dev.product, dev.bus, d if args.load: for file in args.load: bitmap_loaded.append(bitmap_img(file)) + bitmaps_unused = True msgs = [] 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") + buf = array.array('B') buf.extend(header(list(map(lambda x: x[1], msgs)), args.speed, args.mode)) diff --git a/green_badge.jpg b/photos/green_badge.jpg similarity index 100% rename from green_badge.jpg rename to photos/green_badge.jpg diff --git a/photos/love_my_fablab.jpg b/photos/love_my_fablab.jpg new file mode 100644 index 0000000..c462eea Binary files /dev/null and b/photos/love_my_fablab.jpg differ