From b10d7e376e1c3f1d732fa2459c05f4cbd234223d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Weigert?= Date: Thu, 7 Mar 2019 23:57:56 +0100 Subject: [PATCH] =?UTF-8?q?Fablab=20logos=20added=20for=20F=C3=BCrth=20and?= =?UTF-8?q?=20N=C3=BCrnberg.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gfx/fablabnbg_logo_44x11.png | Bin 0 -> 394 bytes gfx/falafue_logo_44x11.png | Bin 0 -> 368 bytes gfx/owncloud_logo_18x11.png | Bin 256 -> 0 bytes led-badge-11x44.py | 22 ++++++++++++++++------ 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 gfx/fablabnbg_logo_44x11.png create mode 100644 gfx/falafue_logo_44x11.png delete mode 100644 gfx/owncloud_logo_18x11.png diff --git a/gfx/fablabnbg_logo_44x11.png b/gfx/fablabnbg_logo_44x11.png new file mode 100644 index 0000000000000000000000000000000000000000..d940c9c118e141df630254434c6bad214224b2c1 GIT binary patch literal 394 zcmeAS@N?(olHy`uVBq!ia0vp^IzY_L!3HE*bo2Xx6kC$Fy9>jA5L~c#`DCC7XMsm# zF;JB-2s1Lwnj--eWH0gbb!C6d%r2&>@@%fEEKo=`GbEzKIX^cyHLnE7WngeFN=+65jw^TaLjDDY|Ni?<`*u4cQ7ODa zYTDtH$C*l^3f^gKO^gi>vX$Do88{Rlu^D@p@6HeRoBZatU8gfg#C6k`&gouJOxKPTvM_{%mfqgco_J!v(6rif znX6w*T{cnOS eEf>8T-bDaS-Sz6R@0VAgAn|ndb6Mw<&;$UnmzP`s literal 0 HcmV?d00001 diff --git a/gfx/falafue_logo_44x11.png b/gfx/falafue_logo_44x11.png new file mode 100644 index 0000000000000000000000000000000000000000..8306095c3f01de43a7ee01c4190b437f5ea9f1fc GIT binary patch literal 368 zcmeAS@N?(olHy`uVBq!ia0vp^IzY_L!3HE*bo2Xx6kC$Fy9wy$!fk$L9 zP?azUGcwGYBLNg-FY)wsWq-`fE+(sd__DJnP)Ig2B%;JQKQ}iuuLQ_tU~n!8=r2UdKJyHe9AVS-%e|pUS027b9$+D^4D|LI!aq~ zPA}d2*karB3k#ps+Gl+%jZO5u-gV;Pz974=&nxd8u~UkBU$x43y&1^kp00i_>zopr E033^uR{#J2 literal 0 HcmV?d00001 diff --git a/gfx/owncloud_logo_18x11.png b/gfx/owncloud_logo_18x11.png deleted file mode 100644 index 5c2f19eb1eaf27b44ffa05f8a2e075d040e6397b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^LO{&T!2~4#mU;yPDb50q$YKTtJ!KGPtXOJa1{7p3 z@$_|Nf6UA-Br2`Kc#|0@B%2u$QR1ARo12 diff --git a/led-badge-11x44.py b/led-badge-11x44.py index b8c54d8..329f900 100755 --- a/led-badge-11x44.py +++ b/led-badge-11x44.py @@ -14,11 +14,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. import sys, os, re, array, time, argparse import usb.core -__version = "0.2" +__version = "0.3" font_11x44 = ( # 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' @@ -65,8 +66,8 @@ font_11x44 = ( 0x00, 0x00, 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, - 0x00, 0x00, 0x00, 0x7c, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, + 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, + 0x00, 0x00, 0x00, 0x00, 0x7c, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0xde, 0x76, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x70, 0x1c, 0xc6, 0x7c, 0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x34, 0x18, 0x00, @@ -149,23 +150,28 @@ char_offset = {} for i in range(len(charmap)): char_offset[charmap[i]] = 11 * i +bitmap_loaded = [ ([],0) ] 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)] o = char_offset[ch] - return font_11x44[o:o+11] + return (font_11x44[o:o+11],1) def bitmap_text(text): """ returns a tuple of (buffer, length_in_byte_columns_aka_chars) """ buf = array.array('B') + cols = 0 for c in text: - buf.extend(bitmap_char(c)) - return (buf, len(text)) + (b,n) = bitmap_char(c) + buf.extend(b) + cols += n + return (buf, cols) def bitmap_img(file): @@ -231,6 +237,7 @@ def header(lengths, speeds, modes): parser = argparse.ArgumentParser(description='%s Version %s -- upload messages to a 44x11 led badge via USB HID. https://github.com/jnweiger/led-badge-44x11' % (sys.argv[0], __version)) parser.add_argument('-s', '--speed', default='4', help="Scroll speed. Up to 8 comma-seperated values (range 1..8)") 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) -left(5); drop-down(6); curtain(7); laser(8)") +parser.add_argument('-l', '--load', metavar='FILE', action='append', help="Bitmap images, made available as ^A, ^B, ^C, ... in text messages") parser.add_argument('message', nargs='+', help="Up to 8 message texts or image file names") args = parser.parse_args() @@ -244,6 +251,9 @@ if dev.is_kernel_driver_active(0): dev.set_configuration() print("using [%s %s] bus=%d dev=%d" % (dev.manufacturer, dev.product, dev.bus, dev.address)) +if args.load: + for file in args.load: + bitmap_loaded.append(bitmap_img(file)) msgs = [] for arg in args.message: