support type 48x12

pull/1/head
Jürgen Weigert 5 years ago
parent 11febb93a7
commit 0f7b69242f
  1. 16
      README.md
  2. 18
      led-badge-11x44.py
  3. 1
      led-badge-12x48.py

@ -8,8 +8,12 @@ Upload tool for an led name tag with USB-HID interface
There are many different versions of LED Badges on the market. There are many different versions of LED Badges on the market.
This one uses an USB-HID interface, while others use USB-Serial (see references below). This one uses an USB-HID interface, while others use USB-Serial (see references below).
The type supported by this project has an array of 44 x 11 LEDs and The types supported by this project have an array of
identifies itself on the USB as
- 44 x 11 LEDs or
- 48 x 12 LEDs.
In both configurations, the badge identifies itself on the USB as
idVendor=0416, idProduct=5020 idVendor=0416, idProduct=5020
Mfr=1, Product=2, SerialNumber=0 Mfr=1, Product=2, SerialNumber=0
@ -91,8 +95,8 @@ prints the list of builtin icon names, including :happy: :happy2: :heart: :HEART
prints some condensed help: prints some condensed help:
<pre> <pre>
usage: led-badge-11x44.py [-h] [-s SPEED] [-m MODE] [-b BLINK] [-a ANTS] usage: led-badge-11x44.py [-h] [-t TYPE] [-s SPEED] [-m MODE] [-b BLINK]
[-p FILE] [-l] [-a ANTS] [-p FILE] [-l]
MESSAGE [MESSAGE ...] MESSAGE [MESSAGE ...]
Upload messages or graphics to a 44x11 led badge via USB HID. Upload messages or graphics to a 44x11 led badge via USB HID.
@ -106,6 +110,10 @@ positional arguments:
optional arguments: optional arguments:
-h, --help show this help message and exit -h, --help show this help message and exit
-t TYPE, --type TYPE
Type of display: supported values are 12x48 or
(default) 11x44. Rename the program to led-badge-12x48,
to switch the default.
-s SPEED, --speed SPEED -s SPEED, --speed SPEED
Scroll speed (Range 1..8). Up to 8 comma-seperated Scroll speed (Range 1..8). Up to 8 comma-seperated
values values

@ -43,11 +43,12 @@
# Options -b --blink, -a --ants added. Removed -p from usage. # Options -b --blink, -a --ants added. Removed -p from usage.
# v0.7, 2019-05-20, jw Support pyhidapi, fallback to usb.core. Added python2 compatibility. # v0.7, 2019-05-20, jw Support pyhidapi, fallback to usb.core. Added python2 compatibility.
# v0.8, 2019-05-23, jw Support usb.core on windows via libusb-win32 # v0.8, 2019-05-23, jw Support usb.core on windows via libusb-win32
# v0.9, 2019-07-17, jw Support 48x12 configuration too.
import sys, os, re, time, argparse import sys, os, re, time, argparse
from array import array from array import array
try: try:
if sys.version_info[0] < 3: raise Exception("prefer usb.core with python-2.x because of https://github.com/jnweiger/led-badge-44x11/issues/9") if sys.version_info[0] < 3: raise Exception("prefer usb.core with python-2.x because of https://github.com/jnweiger/led-badge-ls32/issues/9")
import pyhidapi import pyhidapi
pyhidapi.hid_init() pyhidapi.hid_init()
have_pyhidapi = True have_pyhidapi = True
@ -73,7 +74,7 @@ or
sys.exit(1) sys.exit(1)
__version = "0.8" __version = "0.9"
font_11x44 = ( font_11x44 = (
# 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' # 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
@ -381,7 +382,8 @@ def header(lengths, speeds, modes, blink, ants):
return h return h
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description='Upload messages or graphics to a 44x11 led badge via USB HID.\nVersion %s from https://github.com/jnweiger/led-badge-44x11\n -- see there for more examples and for updates.' % __version, epilog='Example combining image and text:\n sudo %s "I:HEART2:you"' % sys.argv[0]) parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description='Upload messages or graphics to a 44x11 led badge via USB HID.\nVersion %s from https://github.com/jnweiger/led-badge-ls32\n -- see there for more examples and for updates.' % __version, epilog='Example combining image and text:\n sudo %s "I:HEART2:you"' % sys.argv[0])
parser.add_argument('-t', '--type', default='11x44', help="Type of display: supported values are 12x48 or (default) 11x44. Rename the program to led-badge-12x48, to switch the default.")
parser.add_argument('-s', '--speed', default='4', help="Scroll speed (Range 1..8). Up to 8 comma-seperated values") parser.add_argument('-s', '--speed', default='4', help="Scroll speed (Range 1..8). Up to 8 comma-seperated values")
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); animation(5); drop-down(6); curtain(7); laser(8); See '--mode-help' for more details.") 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); animation(5); drop-down(6); curtain(7); laser(8); See '--mode-help' for more details.")
parser.add_argument('-b', '--blink', default='0', help="1: blinking, 0: normal. Up to 8 comma-seperated values") parser.add_argument('-b', '--blink', default='0', help="1: blinking, 0: normal. Up to 8 comma-seperated values")
@ -451,6 +453,16 @@ for arg in args.message:
if bitmaps_preloaded_unused == True: if bitmaps_preloaded_unused == True:
print("\nWARNING:\n Your preloaded images are not used.\n Try without '-p' 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")
if '12' in args.type or '12' in sys.argv[0]:
print("Type: 12x48")
for msg in msgs:
# trivial hack to support 12x48 badges:
# patch extra empty lines into the message stream.
for o in reversed(range(1, int(len(msg[0])/11)+1)):
msg[0][o*11:o*11] = array('B', [0])
else:
print("Type: 11x44")
buf = array('B') buf = array('B')
buf.extend(header(list(map(lambda x: x[1], msgs)), args.speed, args.mode, args.blink, args.ants)) buf.extend(header(list(map(lambda x: x[1], msgs)), args.speed, args.mode, args.blink, args.ants))

@ -0,0 +1 @@
led-badge-11x44.py
Loading…
Cancel
Save