diff --git a/README.md b/README.md index 3705a37..bad6558 100644 --- a/README.md +++ b/README.md @@ -48,68 +48,103 @@ access to the badge via USB. Using a venv will allow to use pip to install dependencies without the danger that the installed modules will interfere with the system installed ones. +On some systems (esp. those with Python 2 *and* 3 installed), you have to +address Python 3 explicitly by using the commands `python3` / `pip3` instead +of `python` / `pip`. sudo apt install python3-venv - python3 -m venv ledtag + python -m venv ledtag source ledtag/bin/activate pip install pyhidapi pyusb pillow # this should now work: - # python3 led-badge-11x44.py -m 6 -s 8 "Hello" "World!" + # python led-badge-11x44.py -m 6 -s 8 "Hello" "World!" if the udev rules are installed, you should be able to access the badge without sudo / root privileges. To reuse the venv again at a later point: source ledtag/bin/activate - python3 led-badge-11x44.py … + python led-badge-11x44.py … ### Required dependencies on Fedora Systems sudo dnf install hidapi python3-hidapi python3-pillow python3-pyusb +### Manual link the HID API lib for some Linuxes + +For some distributions there is a discrepancy in where pyhidapi searches for the +lib and where the package hidapi places it. A simple solution is to link the +library to the needed place, e.g. + + ln -s /usr/lib/libhidapi-hidraw.so.0 /usr/local/lib/ + ### Required dependencies on Mac Systems +On some systems (esp. those with Python 2 *and* 3 installed), you have to +address Python 3 explicitly by using the command `pip3` instead of `pip`. + sudo easy_install pip pip install pyhidapi pip install pillow ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null brew install hidapi - or - Try with `pip3 install pyhidapi` -### Required dependencies on Windows 10 +### Required dependencies on Windows 7/10 - Download win/inf-wizard.exe to your desktop. Right click 'Run as Administrator' - -> Click 0x0416 0x5020 LS32 Custm HID - -> Next -> Next -> Documents LS32_Sustm_HID.inf -> Save (we don't need that file) - -> Install Now... -> Driver Install Complete -> OK +For Windows, we need to set up the libusb API for the LED badge device. +The way described here, uses [libusb-win32](https://github.com/mcuee/libusb-win32/wiki) +in a quite low level way and in a quite old version: - Download python from python.org - [x] install Launcher for all Users - [x] Add Python 3.7 to PATH - -> Click the 'Install Now ...' text message. +- Please use version 1.2.6.0 of 'usblib-win32`. It's still available on the + [old project repo on SourceForge](https://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.6.0/) +- Then + - Extract `bin/inf-wizard.exe` from the downloaded zip file. Right click and `Run as Administrator` + - `Next` -> Select `0x0416 0x5020 LS32 Custm HID` (or similar with the same IDs) + - `Next` -> `Next` -> Save as dialog `LS32_Sustm_HID.inf` -> `Save` (just to proceed, we don't need that file) + - `Install Now...` -> Driver Install Complete -> `OK` - Run cmd.exe as Administrator, enter: - pip install pyusb - pip install pillow +There are other - meanwhile recommended, but untested here - ways to install and setup +newer versions of `libus-win32`: use +[Zadig](https://zadig.akeo.ie/) (it is also available from the old libusb-win32 repo on +[GitHub repo](https://github.com/mcuee/libusb-win32/releases) of newer releases) +or [libusbK](https://libusbk.sourceforge.net/UsbK3/index.html) -### Required dependencies on Windows 7 +Of course, Python is needed: - Download win/win32-bin-1.2.6.0.zip to your desktop. Extract. - Find the inf-wizard.exe in the bin folder. Right click 'Run as Administrator' - Then continue as with windows 10 above. +- Download latest python from [python.org](https://www.python.org/downloads/), +or specific versions from [here](https://www.python.org/downloads/windows/) + - Checkmark the following options + - `[x]` install Launcher for all Users + - `[x]` Add Python X.Y to PATH + - Click the `Install Now ...` text message. + +Install needed the Python packages. On some systems (esp. those with Python 2 +*and* 3 installed), you have to address Python 3 explicitly by using the +command `pip3` instead of `pip`. + +- Run cmd.exe as Administrator, enter: + + pip install pyusb + pip install pillow #### Examples: -Sudo may or may not be needed for accessing the USB device, depending on your system. +To run these examples on linux, you might have to prepend `sudo` for accessing +the USB device or install a udev rule as stated above. On Windows, maybe you +have to run the `cmd.exe`, where you enter the commands, with `Run as administrator`, +which is similar to the `sudo`on linux. + +On some systems (esp. those with Python 2 *and* 3 installed), you have to +address Python 3 explicitly by using `python3` instead of `python`. Run +`python -V` to see which version of python is configured as default. - sudo python3 ./led-badge-11x44.py "Hello World!" + python ./led-badge-11x44.py "Hello World!" loads the text 'Hello World!' as the first message, and scrolls it from right to left (default scroll mode=0) and speed 4 (default). After an upload the device shows the first message once and returns to the charging screen if still connected to USB. Either pull the plug or press the small button next to the USB connector. - sudo python3 ./led-badge-11x44.py -m 6 -s 8 "Hello" "World!" + python ./led-badge-11x44.py -m 6 -s 8 "Hello" "World!" loads the text 'Hello' as message one and 'World!' as message two. Compare the difference in quoting to the previous example. Up to 8 messages can be uploaded. This example uses mode 6, which drops the words with a nice little animation @@ -118,13 +153,13 @@ vertically into the display area. Speed is set to maximum here, for smoothness. Per default, you will only see 'Hello'. To see all messages, press the small button next to the USB connector multiple times, until you briefly see 'M1-8'. Now the display loops through all uploaded messages. - sudo python3 ./led-badge-11x44.py -m 5 :gfx/fablabnbg_logo_44x11.png: + python ./led-badge-11x44.py -m 5 :gfx/fablabnbg_logo_44x11.png: loads a fullscreen still image. Avoid whitespace between colons and name. If you receive a message `ImportError: cannot import name '_imaging'`, then try to update the corresponding -package: `sudo pip install -U Pillow` +package: `sudo pip install -U pillow` - sudo python3 ./led-badge-11x44.py "I:HEART2:my:gfx/fablab_logo_16x11.png:fablab:1:" + python ./led-badge-11x44.py "I:HEART2:my:gfx/fablab_logo_16x11.png:fablab:1:" uses one builtin and one loaded image. The heart is builtin, and the fablab-logo is loaded from file. The fablab logo is used twice, once before the word 'fablab' and again behind through the reference ':1:' (which references the first @@ -132,7 +167,7 @@ loaded image). ![LED Mini Board](photos/love_my_fablab.jpg) - sudo python3 ./led-badge-11x44.py -s7 -m0,1 :bicycle: :bicycle_r: + python ./led-badge-11x44.py -s7 -m0,1 :bicycle: :bicycle_r: shows a bicycle crossing the display in left-to-right and right-to-left (as a second message). If you select the 'M1-8' mode, the bike permanently runs back and forth the display. You may add a short message to one or both, to make it @@ -140,7 +175,7 @@ appear the bike is pulling the text around. ![LED Mini Board](photos/bicycle.gif) - sudo python3 ./led-badge-11-x44.py -b0,1 -s1 -m5 " :heart2: :HEART2:" " :HEART2:" + python ./led-badge-11-x44.py -b0,1 -s1 -m5 " :heart2: :HEART2:" " :HEART2:" shows a simple animation of a slowly beating heart on the first message, and a blinking heart on the second message. @@ -148,28 +183,28 @@ shows a simple animation of a slowly beating heart on the first message, and a b ![M2 ishm](photos/m2ishm.gif) - python3 ./led-badge-11x44.py --list-names + python ./led-badge-11x44.py --list-names prints the list of builtin icon names, including :happy: :happy2: :heart: :HEART: :heart2: :HEART2: :fablab: :bicycle: : bicycle_r: :owncloud: :: - python3 ./led-badge-11x44.py --help + python ./led-badge-11x44.py --help lists all write methods. Does not write anything to the device. - python3 ./led-badge-11x44.py -M list "dummy message" + python ./led-badge-11x44.py -M list "dummy message" lists all devices available with write method 'hidapi'. Does not write anything to the device. - python3 ./led-badge-11x44.py -M hidapi -D list "dummy message" + python ./led-badge-11x44.py -M hidapi -D list "dummy message" programs a specific device with a specific write method. - python3 ./led-badge-11x44.py -M hidapi -D "3-1:1.0" "Hello World!" + python ./led-badge-11x44.py -M hidapi -D "3-1:1.0" "Hello World!" prints some condensed help: - python3 ./led-badge-11x44.py -h + python ./led-badge-11x44.py -h
usage: lednamebadge.py [-h] [-t TYPE] [-H HID] [-M METHOD] [-D DEVICE_ID] @@ -224,13 +259,13 @@ Example combining image and text: There are some options defining the default type: - use `lednamebadge.py` directly: default type is 11x44 -- rename `lednamebadge.py` to something with `12` and use that: default type is 12x48 +- rename `lednamebadge.py` to something with `12` (e.g. `badge12.py`) and use that: default type is 12x48 - use `led-badge-11x44.py`: default type is 11x44 - use `led-badge-12x48.py`: default type is 12x48 For all these options you can override the default type with command line option `-t` -There are two options to controll which device is programmed with which method. At this time there are two write +There are two options to control which device is programmed with which method. At this time there are two write methods: one is using the python package pyusb (`libusb`), the other one is using pyhidapi (`hidapi`). @@ -272,13 +307,13 @@ Your own content has to be a byte array with the bitmap data for all scenes. Of See the following graphic for better understanding: -![bitmap_data_onebyte.png](photos%2Fbitmap_data_onebyte.png) +![bitmap_data_onebyte.png](photos/bitmap_data_onebyte.png) -![bitmap_data_onescene.png](photos%2Fbitmap_data_onescene.png) +![bitmap_data_onescene.png](photos/bitmap_data_onescene.png) For a 12x48 device there have to be 12 bytes for each byte-column instead of 11, of course. -![bitmap_data_all.png](photos%2Fbitmap_data_all.png) +![bitmap_data_all.png](photos/bitmap_data_all.png) Example: @@ -316,7 +351,7 @@ if used as a module. Therefore, there are 2 methods for retrieving this informat 1. `get_available_methods()` which returns all implemented write methods as a dict with the method names as the keys and a boolean each as the values. The boolean indicates if the method is basically usable (means the corresponding import succeeded) -1. `get_available_device_ids(method)` which returns information about all connected / available devices, also as +2. `get_available_device_ids(method)` which returns information about all connected / available devices, also as a dict with the device ids as the keys and a descriptive string each as the values. ``` diff --git a/photos/bitmap_data_descr.puml b/photos/bitmap_data_descr.puml index 7268993..ccd55c6 100644 --- a/photos/bitmap_data_descr.puml +++ b/photos/bitmap_data_descr.puml @@ -1,9 +1,11 @@ +' Using .. for three dots / ellipsis, els it would be a dotted line + @startuml bitmap_data_onebyte salt title One byte {# { most significant bit 7 - leftmost pixel } | bit 6 | ... | bit 1 | { least significant bit 0 + leftmost pixel } | bit 6 | .. | bit 1 | { least significant bit 0 rightmost pixel } } @enduml @@ -12,17 +14,17 @@ title One byte salt title One scene {# - byte 0 == 8 pixel | byte 11 == 8 pixel | byte 22 == 8 pixel | ... - byte 1 ... | byte 12 ... | byte 23 ... | ... - byte 2 ... | byte 13 ... | byte 24 ... | ... - byte 3 ... | byte 14 ... | byte 25 ... | ... - byte 4 ... | byte 15 ... | byte 26 ... | ... - byte 5 ... | byte 16 ... | byte 27 ... | ... - byte 6 ... | byte 17 ... | byte 28 ... | ... - byte 7 ... | byte 18 ... | byte 29 ... | ... - byte 8 ... | byte 19 ... | byte 30 ... | ... - byte 9 ... | byte 20 ... | byte 31 ... | ... - byte 10 ... | byte 21 ... | byte 32 ... | ... + byte 0 == 8 pixel | byte 11 == 8 pixel | byte 22 == 8 pixel | .. + byte 1 ... | byte 12 ... | byte 23 ... | .. + byte 2 ... | byte 13 ... | byte 24 ... | .. + byte 3 ... | byte 14 ... | byte 25 ... | .. + byte 4 ... | byte 15 ... | byte 26 ... | .. + byte 5 ... | byte 16 ... | byte 27 ... | .. + byte 6 ... | byte 17 ... | byte 28 ... | .. + byte 7 ... | byte 18 ... | byte 29 ... | .. + byte 8 ... | byte 19 ... | byte 30 ... | .. + byte 9 ... | byte 20 ... | byte 31 ... | .. + byte 10 ... | byte 21 ... | byte 32 ... | .. } @enduml @@ -30,6 +32,6 @@ title One scene salt title Complete bitmap data {# - scene 0 == x bytes | ... | scene n == z bytes + scene 0 == x bytes | .. | scene n == z bytes } @enduml