""" lengths[0] is the number of chars of the first text
Speedscomeinas1..8,butareneeded0..7here.
"""
a=[int(x)forxinre.split(r'[\s,]+',ants)]
a=a+[a[-1]]*(8-len(a))# repeat last element
b=[int(x)forxinre.split(r'[\s,]+',blink)]
b=b+[b[-1]]*(8-len(b))# repeat last element
s=[int(x)forxinre.split(r'[\s,]+',speeds)]
s=s+[s[-1]]*(8-len(s))
s=[int(x)-1forxinre.split(r'[\s,]+',speeds)]
s=s+[s[-1]]*(8-len(s))# repeat last element
m=[int(x)forxinre.split(r'[\s,]+',modes)]
m=m+[m[-1]]*(8-len(m))
m=m+[m[-1]]*(8-len(m))# repeat last element
h=list(proto_header)
foriinrange(8):
h[6]+=b[i]<<i
h[7]+=a[i]<<i
foriinrange(8):
h[8+i]=16*s[i]+m[i]
foriinrange(len(lengths)):
h[17+2*i]=lengths[i]
returnh
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: sudo %s"I:HEART2:you"'%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('-p','--preload',metavar='FILE',action='append',help="Load bitmap images. Use ^A, ^B, ^C, ... in text messages to make them visible. Deprecated, embed within ':' instead")
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.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('-b','--blink',default='0',help="1: blinking, 0: normal. Up to 8 comma-seperated values")
parser.add_argument('-a','--ants',default='0',help="1: animated border, 0: normal. Up to 8 comma-seperated values")
parser.add_argument('-p','--preload',metavar='FILE',action='append',help=argparse.SUPPRESS)# "Load bitmap images. Use ^A, ^B, ^C, ... in text messages to make them visible. Deprecated, embed within ':' instead")
parser.add_argument('-l','--list-names',action='version',help="list named icons to be embedded in messages and exit",version=':'+': :'.join(bitmap_named.keys())+': :: or e.g. :path/to/some_icon.png:')
parser.add_argument('message',metavar='MESSAGE',nargs='+',help="Up to 8 message texts with embedded builtin icons or loaded images within colons(:) -- See -l for a list of builtins")