Merge pull request #47 from bensartori/documantation

Some documentation improvements
pull/8/head
Jürgen Weigert 7 months ago committed by GitHub
commit 1f57853607
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 109
      README.md
  2. 1
      lednamebadge.py
  3. 28
      photos/bitmap_data_descr.puml

@ -47,89 +47,122 @@ 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`, where you enter the commands, with `Run as administrator`,
which is similar to the `sudo`on linux.
sudo python3 ./led-badge-11x44.py "Hello World!"
On some systems (esp. those with Python 2 *and* 3 installed), you have to
address Python 3 explicitly by using `python3` instead of `python`.
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 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.
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`
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 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 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.
@ -137,16 +170,16 @@ 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
prints some condensed help:
<pre>
usage: led-badge-11x44.py [-h] [-t TYPE] [-s SPEED] [-B BRIGHTNESS] [-m MODE] [-b BLINK] [-a ANTS] [-l] MESSAGE [MESSAGE ...]
usage: led-badge-11x44.py [-h] [-t TYPE] [-H HID] [-s SPEED] [-B BRIGHTNESS] [-m MODE] [-b BLINK] [-a ANTS] [-l] MESSAGE [MESSAGE ...]
Upload messages or graphics to a 11x44 led badge via USB HID.
Version 0.12 from https://github.com/jnweiger/led-name-badge-ls32
@ -158,6 +191,7 @@ positional arguments:
options:
-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.
-H HID, --hid HID' Set to 1 to ensure connect via HID API, program will then not fallback to usb.core library
-s SPEED, --speed SPEED
Scroll speed (Range 1..8). Up to 8 comma-separated values
-B BRIGHTNESS, --brightness BRIGHTNESS
@ -175,9 +209,10 @@ 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 -t
### Animations
@ -207,13 +242,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:
@ -253,7 +288,7 @@ scene_c_bitmap = creator.bitmap("gfx/starfield/starfield_020.png")
```
The resulting bitmaps are tuples with the byte array and the length each. These lengths can be used in header() directly
and the byte arrays can be concatenated to the header. Examle:
and the byte arrays can be concatenated to the header. Example:
```python
from lednamebadge import *

@ -551,6 +551,7 @@ or
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)
for i in range(int(len(buf)/64)):
# sendbuf must contain "report ID" as first byte. "0" does the job here.
sendbuf=array('B',[0])

@ -1,9 +1,11 @@
' Using <U+002E>.. 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 | <U+002E>.. | 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 | <U+002E>..
byte 1 ... | byte 12 ... | byte 23 ... | <U+002E>..
byte 2 ... | byte 13 ... | byte 24 ... | <U+002E>..
byte 3 ... | byte 14 ... | byte 25 ... | <U+002E>..
byte 4 ... | byte 15 ... | byte 26 ... | <U+002E>..
byte 5 ... | byte 16 ... | byte 27 ... | <U+002E>..
byte 6 ... | byte 17 ... | byte 28 ... | <U+002E>..
byte 7 ... | byte 18 ... | byte 29 ... | <U+002E>..
byte 8 ... | byte 19 ... | byte 30 ... | <U+002E>..
byte 9 ... | byte 20 ... | byte 31 ... | <U+002E>..
byte 10 ... | byte 21 ... | byte 32 ... | <U+002E>..
}
@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 | <U+002E>.. | scene n == z bytes
}
@enduml

Loading…
Cancel
Save