warning about unused images added, examples added to README.

pull/1/head
Jürgen Weigert 6 years ago
parent 6ac073f7b3
commit fc3892d977
  1. 7
      README.md
  2. BIN
      gfx/heart.png
  3. BIN
      gfx/heart_full.png
  4. 13
      led-badge-11x44.py
  5. 0
      photos/green_badge.jpg
  6. BIN
      photos/love_my_fablab.jpg

@ -1,7 +1,7 @@
# Led-Badge-44x11 # Led-Badge-44x11
Upload tool for an led name tag with USB-HID interface 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 ## 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 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" 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. 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)
<pre> <pre>
Usage: led-badge-11x44.py [-h] [-s SPEED] [-m MODE] [-l FILE] Usage: led-badge-11x44.py [-h] [-s SPEED] [-m MODE] [-l FILE]
message [message ...] message [message ...]

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

@ -15,11 +15,12 @@
# v0.1, 2019-03-05, jw initial draught. HID code is much simpler than expected. # 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.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 -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 sys, os, re, array, time, argparse
import usb.core import usb.core
__version = "0.3" __version = "0.4"
font_11x44 = ( font_11x44 = (
# 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' # 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
@ -151,13 +152,17 @@ for i in range(len(charmap)):
char_offset[charmap[i]] = 11 * i char_offset[charmap[i]] = 11 * i
bitmap_loaded = [ ([],0) ] bitmap_loaded = [ ([],0) ]
bitmaps_unused = False
def bitmap_char(ch): def bitmap_char(ch):
""" Returns a tuple of 11 bytes, """ Returns a tuple of 11 bytes,
ch = '_' returns (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255) ch = '_' returns (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255)
The bits in each byte are horizontal, highest bit is left. 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] o = char_offset[ch]
return (font_11x44[o:o+11],1) 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: if args.load:
for file in args.load: for file in args.load:
bitmap_loaded.append(bitmap_img(file)) bitmap_loaded.append(bitmap_img(file))
bitmaps_unused = True
msgs = [] msgs = []
for arg in args.message: for arg in args.message:
msgs.append(bitmap(arg)) 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 = array.array('B')
buf.extend(header(list(map(lambda x: x[1], msgs)), args.speed, args.mode)) buf.extend(header(list(map(lambda x: x[1], msgs)), args.speed, args.mode))

Before

Width:  |  Height:  |  Size: 301 KiB

After

Width:  |  Height:  |  Size: 301 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Loading…
Cancel
Save