From d53174f6942b39a7f495c3319b465337d3ebdbae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Weigert?= Date: Thu, 7 Mar 2019 08:53:24 +0100 Subject: [PATCH] upload of text strings works. Including hand crafted german umlaut chars. speed is hardcoded at 4 mode is hardcoded at 0 (aka scroll to left) --- doc/ABCDE.txt | 6 +++- led-badge-11x44.py | 69 +++++++++++++++++++++++++++++++++++++--------- 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/doc/ABCDE.txt b/doc/ABCDE.txt index 353b937..50dd5d7 100644 --- a/doc/ABCDE.txt +++ b/doc/ABCDE.txt @@ -206,6 +206,8 @@ Leftover Capture Data: 77616e67000000004040404040404040001a001a001f0011... 0010 b5 91 7f 5c 00 00 00 00 d0 d4 07 00 8d ff ff ff ...\............ 0020 40 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 @...@........... 0030 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + + 0040 77 61 6e 67 00 00 00 00 40 40 40 40 40 40 40 40 wang....@@@@@@@@ line lengths: 26 26 31 17 @@ -314,7 +316,9 @@ Leftover Capture Data: 00386cc6c6fec6c6c6c60000fc6666667c666666fc00007c... 0010 b5 91 7f 5c 00 00 00 00 84 d9 07 00 8d ff ff ff ...\............ 0020 40 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 @...@........... 0030 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0040 00 38 6c c6 c6 fe c6 c6 c6 c6 00 00 fc 66 66 66 .8l..........fff + +0040 00 38 6c c6 c6 fe c6 c6 c6 c6 00 + 00 fc 66 66 66 .8l..........fff 0050 7c 66 66 66 fc 00 00 7c c6 c6 c0 c0 c0 c6 c6 7c |fff...|.......| 0060 00 00 fc 66 66 66 66 66 66 66 fc 00 00 fe 66 62 ...fffffff....fb 0070 68 78 68 62 66 fe 00 00 fe 66 62 68 78 68 60 60 hxhbf....fbhxh`` diff --git a/led-badge-11x44.py b/led-badge-11x44.py index e78db97..1e835e6 100755 --- a/led-badge-11x44.py +++ b/led-badge-11x44.py @@ -2,13 +2,15 @@ # # (C) 2019 juergen@fabmail.org # -# This is an upload tool for e.g. +# This is an upload tool for e.g. # https://www.sertronics-shop.de/computer/pc-peripheriegeraete/usb-gadgets/led-name-tag-11x44-pixel-usb # The font_11x44[] data was downloaded from such a device. -# - -import sys, os +# +# Requires: +# sudo apt-get install python3-evdev +import sys, os, array, time +import usb.core font_11x44 = ( 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, @@ -37,6 +39,7 @@ font_11x44 = ( 0x00, 0xc6, 0xc6, 0x6c, 0x7c, 0x38, 0x7c, 0x6c, 0xc6, 0xc6, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0xfe, 0xc6, 0x86, 0x0c, 0x18, 0x30, 0x62, 0xc6, 0xfe, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, @@ -63,6 +66,7 @@ font_11x44 = ( 0x00, 0x00, 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x8c, 0x18, 0x30, 0x62, 0xfe, 0x00, + 0x00, 0x7c, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, @@ -112,12 +116,21 @@ font_11x44 = ( 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0x00, 0xcc, 0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00, + 0x00, 0xc6, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0x00, 0xcc, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, + + 0xc6, 0xc6, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, + 0xc6, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0xc6, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, + 0x00, 0x3c, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x6c, 0x60, ) charmap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + \ 'abcdefghijklmnopqrstuvwxyz' + \ - '0987654321^ !"\0$%&/()=?` \\}][{' + \ - "@ ~ |<>,;.:-_#'+* " + '0987654321^ !"\0$%&/()=?` °\\}][{' + \ + "@ ~ |<>,;.:-_#'+* " + "äöüÄÖÜß" char_offset = {} for i in range(len(charmap)): @@ -138,18 +151,48 @@ proto_header = ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ) -def header(lengths): - """ lengths[0] is the number of chars of the first text +def header(args): + """ len(args[0]) is the number of chars of the first text """ + lengths = [] + for l in range(len(args)): + lengths.append(len(args[l])) + h = list(proto_header) for i in range(len(lengths)): h[17+2*i] = lengths[i] return h - -text = sys.argv[1] +if len(sys.argv) < 2: + print("Usage:\n\n %s Message1 [Message2 .. 8]\n" % (sys.argv[0])) + sys.exit(0) + +dev = usb.core.find(idVendor=0x0416, idProduct=0x5020) +if dev is None: + print("No led tag with vendorID 0x0416 and productID 0x5020 found.") + print("Connect the led tag and run this tool as root.") + sys.exit(1) +if dev.is_kernel_driver_active(0): + dev.detach_kernel_driver(0) +dev.set_configuration() +print("using [%s %s] bus=%d dev=%d" % (dev.manufacturer, dev.product, dev.bus, dev.address)) + + +buf = array.array('B') +buf.extend(header(sys.argv[1:])) + +for text in sys.argv[1:]: + # print(text) + for c in text: + # print(bitmap(c)) + buf.extend(bitmap(c)) + +needpadding = len(buf)%64 +if needpadding: + buf.extend( (0,) * (64-needpadding) ) -print(text) -print(header([len(text),0,0,0])) -for c in text: print(bitmap(c)) +# print(buf) +for i in range(int(len(buf)/64)): + time.sleep(0.1) + dev.write(1, buf[i*64:i*64+64])