GithubHelp home page GithubHelp logo

jnweiger / led-name-badge-ls32 Goto Github PK

View Code? Open in Web Editor NEW
222.0 222.0 81.0 18.22 MB

Upload tool for an led name tag with USB-HID interface

License: GNU General Public License v2.0

Python 97.12% Shell 2.88%

led-name-badge-ls32's Introduction

led-name-badge-ls32's People

Contributors

anbo-de avatar coldtobi avatar ian57 avatar jnweiger avatar kitazaki avatar linuscde avatar mik-at avatar pcfe avatar ralfzen avatar s-light avatar syspart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

led-name-badge-ls32's Issues

[featurerequest] restructure for reuse

would be great if the script has the form of a python 'module'
so it could be easily used by other scripts
best case: be installed via pypi ๐Ÿ˜€

this would also mean to restructure & define some module-level API -
after a first look it could make sens to extract the real upload functions into one module
and the fancy font and bitmap things into another..
(the second one could have a classic __main__ for the current standalone/commandline use)

(common tutorial about python packaging)

Error when writing to device

I get this message on Ubuntu 22.04

using [wch.cn CH546] bus=3 dev=16
Type: 11x44
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/usb/core.py", line 236, in get_interface_and_endpoint
return self._ep_info[endpoint_address]
KeyError: 1

led-name-badge-ls32/led-badge-11x44.py", line 570, in
dev.write(1, buf[i * 64:i * 64 + 64])

I'm not into Python. Sorry for not beeing able to resolve that.

usb.core.USBError: timeout error

Hi there

Thanks for making this script. It works well. I wanted to provide some clarification for those who encounter the following error when trying to write to the led matrix S1144 on Windows 11 (using libusb, not pyhidapi):

usb.core.USBError: [Errno None] b'libusb0-dll:err [_usb_reap_async] timeout error\n'

I managed to get around this by adding else branch at the end of the script, as follows:

if have_pyhidapi:
  pyhidapi.hid_close(dev)
else:
  dev.reset()  

It seems that calling dev.reset() is necessary to avoid device hang-ups, and is essential for the "no charging screen" hack that you mentioned before.

This is what I ran:
python.exe "C:\Users\X\Downloads\led_py\led-badge-11x44.py" -s8 -m4 ++++++

python.exe "C:\Users\X\Downloads\led_py\led-badge-11x44.py" -m9 hello

For clock (run in cmd):

for /L %i in (1,0,1) do @start /B C:\Users\X\Python\Python311\python.exe "C:\Users\X\Downloads\led_py\led-badge-11x44.py" -m9 %TIME:~0,5% & timeout /t 60 /nobreak >nul

Thanks

Error

I am getting a error /usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python: can't open file './led-badge-11x44.py': [Errno 2] No such file or directory when running the Hello World! Example on OSX 10.14.6. Any idea whats going on?

Thanks and doc suggestions for Windows

Good stuff, thanks - it worked flawlessly. Two suggestions:

  • for Windows, zadig (https://zadig.akeo.ie/) is another (nicer?) option to install libusb as driver for the device, though it's easier to choose an incorrect version that does not work with pyusb
  • the suggestion for the Python installation (include the link?! auto-detect: https://www.python.org/downloads/, all releases: https://www.python.org/downloads/windows/) recommends the launcher, but usage examples start with sudo ... and lack an example call for Windows, e.g. 'py led-badge-11x44.py "Hello World!"`

BTW, my unit's microcontroller is marked "MM32L052PF" which seems to made by "MINDMOTION MICROELECTRONICS" and have an ARM Cortex M0 core (IC package: LQFP48).

So it's probably "hackable".

TypeError under Mac OS

Hi,

With MacOS I don't get the script running.

First I must additional run
sudo easy_install pip
to get sudo pip install pyhidapi running
and
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null to get sudo brew install hidapi running.

Maybe that's useful for the Help File.

Now the script is running but when I connect a device and try sudo python led-badge-11x44.py "Test" I get follow error code:

using [LSicroelectronics LS32 Custm HID] int=-1 page=1 via pyHIDAPI Traceback (most recent call last): File "led-badge-11x44.py", line 439, in <module> pyhidapi.hid_write(dev, buf[i*64:i*64+64]) File "/Library/Python/2.7/site-packages/pyhidapi/pyhidapi.py", line 638, in hid_write buf[n] = data[n] TypeError: one character string expected

Im Using MacOS Mojave 10.14.4.

more icon

Hello,

i want to inform that i like your progremm is so easy to work with but i notice a little issue if you want to realise with me, is that i want to add more icon like coofe icon and more, can you give me a little response from your part that show me how to get this issue .

Kinf regards
LEbda Ayoub

prevent charging screen when cable is connected

All this looks like we are exploiting a firmware bug.
A sequence of
sudo ./led-badge-11x44.py -s8 -m4 ++++++
sudo ./led-badge-11x44.py -m9 fragment

shows quite reliably the text 'fragme' permanently while still connected to USB.

The number of characters given in the first command appear to determine the start position of the text in the next command.
If only one character was given, we get 'fra:' at the right hand side, if two characters are given, we get 'frag'.

All this looks to me like we are exploiting a firmware bug.

Text length/image size

Hello
if i create a picture and send it as animation, what is the maximum size?
If I look on your code, the image width could be 255*8 (width of a char). But there is a second byte, and it looks like the high byte of an integer.
Or am I wrong?
greetings
syspart

What am I doing wrong?

Sorry, new to python!

I have the correct badge 0x0416 0x5020 (mine is the G1144) and I'm following all the steps for the dependancies, successfully uploaded driver, gone through python setup in CMD etc, but the badge is still stuck on the default chinese demo text and nothing I try to upload seems to affect it.

I didn't get any software from the seller so really hoping this can work for me!

The only difference I can see is I have python 3.8 not 3.7, will that be an issue?

Under Mac Access Denied

Stacktrace:

python ./led-badge-11x44.py "Hello World"
using [LSicroelectronics LS32 Custm HID] bus=20 dev=3
Traceback (most recent call last):
File "./led-badge-11x44.py", line 374, in
dev.write(1, buf[i64:i64+64])
File "/Users/anna-katharinarausch/dev/led-badge-44x11/girls_env/lib/python3.6/site-packages/usb/core.py", line 940, in write
intf, ep = self._ctx.setup_request(self, endpoint)
File "/Users/anna-katharinarausch/dev/led-badge-44x11/girls_env/lib/python3.6/site-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/Users/anna-katharinarausch/dev/led-badge-44x11/girls_env/lib/python3.6/site-packages/usb/core.py", line 216, in setup_request
self.managed_claim_interface(device, intf)
File "/Users/anna-katharinarausch/dev/led-badge-44x11/girls_env/lib/python3.6/site-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/Users/anna-katharinarausch/dev/led-badge-44x11/girls_env/lib/python3.6/site-packages/usb/core.py", line 167, in managed_claim_interface
self.backend.claim_interface(self.handle, i)
File "/Users/anna-katharinarausch/dev/led-badge-44x11/girls_env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 811, in claim_interface
_check(self.lib.libusb_claim_interface(dev_handle.handle, intf))
File "/Users/anna-katharinarausch/dev/led-badge-44x11/girls_env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)

The device has no langid error when icon used

Hello,

The "hello world" example is running ok : )
But I have an error when I want to use builtin icon : (

Windows 7 , Python 3.5.4 64 bits

D:\dev\sertronics\led-name-badge-ls32-master>python led-badge-11x44.py :ball:
Traceback (most recent call last):
File "led-badge-11x44.py", line 475, in
print("using [%s %s] bus=%d dev=%d" % (dev.manufacturer, dev.product, dev.bu
s, dev.address))
File "C:\Python35\lib\site-packages\usb\core.py", line 852, in manufacturer
self._manufacturer = util.get_string(self, self.iManufacturer)
File "C:\Python35\lib\site-packages\usb\util.py", line 314, in get_string
raise ValueError("The device has no langid")
ValueError: The device has no langid

operation time out on send multiple packets

The badge hangs if I send more than one packet. Got following errors:

[root@alarmpi led-name-badge-ls32]# python2 ./led-badge-11x44.py "Hello world!"
using [LSicroelectronics LS32 Custm HID] bus=1 dev=98
Type: 11x44
packet 0
packet 1
packet 2
Traceback (most recent call last):
File "./led-badge-11x44.py", line 524, in
dev.write(1, buf[i64:i64+64])
File "/usr/lib/python2.7/site-packages/usb/core.py", line 948, in write
self.__get_timeout(timeout)
File "/usr/lib/python2.7/site-packages/usb/backend/libusb1.py", line 842, in intr_write
timeout)
File "/usr/lib/python2.7/site-packages/usb/backend/libusb1.py", line 920, in __write
_check(retval)
File "/usr/lib/python2.7/site-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 110] Operation timed out

I have to unplug and re-plug it to get it reset to normal.

I found the bmpbadge application also read some bytes from endpoint 81. Would that be the missing pieces?

usb.core.USBTimeoutError on Linux (Fedora 38)

I get the following Error Message for every String that is longer than 6 Characters. The workaround from #40 doesn't work.

Note: Had to implement the Workaround from #36 to be able to write to the badge anyway.

sudo python3 ./led-badge-11x44.py "123456789"
using [wch.cn CH546] bus=1 dev=19
Type: 11x44
Traceback (most recent call last):
  File "/home/phil/git/led-name-badge-ls32/./led-badge-11x44.py", line 523, in <module>
    dev.write(2, buf[i*64:i*64+64])
  File "/usr/lib/python3.11/site-packages/usb/core.py", line 989, in write
    return fn(
           ^^^
  File "/usr/lib/python3.11/site-packages/usb/backend/libusb1.py", line 855, in intr_write
    return self.__write(self.lib.libusb_interrupt_transfer,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/usb/backend/libusb1.py", line 938, in __write
    _check(retval)
  File "/usr/lib/python3.11/site-packages/usb/backend/libusb1.py", line 602, in _check
    raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 110] Operation timed out

[featurerequest] cross-platform support?!

idea: would be nice to have a easy way (for a normal end-user) to install this cross-platform.

this is a collection of things i found during my search & how it could work -
all untested yet...

libusb

currently the script uses libusb to access the HID-Device.
its easy to install for linux but a little bit harder for Mac OS or windows:
(as fare as i found - please proof me wrong?! ;-) )

  • Linux (Ubuntu or other debian based...)
    simple as sudo apt install python3-usb (as written in the current instructions)
    this installs libusb and pyusb (info from package description)
  • macOS
    according to this answer libusb should be working with Homebrew
    brew install libusb
    additionally we need pyusb: pip3 install pyusb
  • Windows
    there is a libusb Windows WikiPage that tells us that there are Binary Snapshots as 7zip in the releases
    but these just containing the dlls - no installer:
    image
    so we need to copy theme to the correct location so the
    pyusb lib can find them?! (i have no clue ๐Ÿ™ˆ )

there is libusb at pypi (github) that states:

Requirements
It is fully independent package.
All necessary things are installed during the normal installation process.
ATTENTION: currently works and tested only for Windows.

and yes- if you look at the source it includes the dll.
but as mentioned - only for windows ๐Ÿ˜ฟ

other option: switch library ?

the libusb FAQ also recommends the HIDAPI library for HID things.
but it seems this lib is a bit in a unmaintained state currently..
on my search i found cython-hidapi as a python API for this. (called hidapi at pypi)
โ†’ this would mean Cython as dependency..
i also found pyhidapi (named hid in pypi)
but installation in osx seems trouble some too...

result

there is no easy to install solution already out there?

hope someone else has better news on this ;-)

ValueError: Invalid endpoint address 0x1

Tried on Linux Mint 20.3 and 21 (debian - ubuntu based):
installed python3-usb through apt, python3-pil was already installed by default.
copied the udev rule and reloaded
Device: NB1144
tried running with and without sudo, even directly as root.

When I try the example I get the following error:
./led-badge-11x44.py "Hello"
using [wch.cn CH583] bus=5 dev=10
Type: 11x44
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/usb/core.py", line 223, in get_interface_and_endpoint
return self._ep_info[endpoint_address]
KeyError: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./led-badge-11x44.py", line 523, in
dev.write(1, buf[i64:i64+64])
File "/usr/lib/python3/dist-packages/usb/core.py", line 940, in write
intf, ep = self._ctx.setup_request(self, endpoint)
File "/usr/lib/python3/dist-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/usb/core.py", line 215, in setup_request
intf, ep = self.get_interface_and_endpoint(device, endpoint_address)
File "/usr/lib/python3/dist-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/usb/core.py", line 231, in get_interface_and_endpoint
raise ValueError('Invalid endpoint address ' + hex(endpoint_address))
ValueError: Invalid endpoint address 0x1

Crash after first use

The first use works fine, after that I get different errors:

Traceback (most recent call last):
  File "./led-badge-11x44.py", line 347, in <module>
    print("using [%s %s] bus=%d dev=%d" % (dev.manufacturer, dev.product, dev.bus, dev.address))
  File "/usr/lib/python3/dist-packages/usb/core.py", line 852, in manufacturer
    self._manufacturer = util.get_string(self, self.iManufacturer)
  File "/usr/lib/python3/dist-packages/usb/util.py", line 314, in get_string
    raise ValueError("The device has no langid")
ValueError: The device has no langid

dmsg is fine

[ 1623.818891] usb 3-2: new full-speed USB device number 24 using xhci_hcd
[ 1623.967869] usb 3-2: New USB device found, idVendor=0416, idProduct=5020, bcdDevice= 0.00
[ 1623.967873] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1623.967874] usb 3-2: Product: LS32 Custm HID
[ 1623.967876] usb 3-2: Manufacturer: LSicroelectronics
[ 1623.968925] input: LSicroelectronics LS32 Custm HID as /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/0003:0416:5020.0004/input/input28
[ 1623.969089] hid-generic 0003:0416:5020.0004: input,hidraw2: USB HID v1.10 Device [LSicroelectronics LS32 Custm HID] on usb-0000:00:14.0-2/input0

Combine with another Python script

Thank you for sharing the code. It is working great!
I am not familiar with python and would like to ask you if you can help me out to combine your code with another one.

An import into your code of this code (https://github.com/Zacki84/Wien-Abfahrtsmonitor) did not give the output to the LED Badge.

Can you give me here a tip how to print output of codes to the LED Badge?

Using : in text is not Posible

Hi all

I would like to use the LED Badge as Status Monitor for Linux.
All i want is to output the uptime command to the LED. see example below.
Problem is, that the ":" characters have a buildin funktion for the bitmaps so i cannot show a Timestamp.
Is there a way that i can escape the ":" character so that they are not interpreted as Picture ?

Thanks is advance, and a happy new year 2021
Ciao
Sandro

---example--
sandro@schleppy:~/led-name-badge-ls32$ uptime
11:16:27 up 26 min, 1 user, load average: 0,56, 0,38, 0,21

sandro@schleppy:~/led-name-badge-ls32$ python3 ./led-badge-11x44.py "11:07:53 up 17 min, 1 user, load average: 0,00, 0,05, 0,09"
using [LSicroelectronics LS32 Custm HID] bus=1 dev=13
Traceback (most recent call last):
File "./led-badge-11x44.py", line 487, in
msgs.append(bitmap(arg))
File "./led-badge-11x44.py", line 360, in bitmap
return bitmap_text(arg)
File "./led-badge-11x44.py", line 315, in bitmap_text
(b,n) = bitmap_char(c)
File "./led-badge-11x44.py", line 284, in bitmap_char
return bitmap_preloaded[ord(ch)]
IndexError: list index out of range

Suppress M1-8

Love this code! I have a LED badge that I am wanting to use as a notification mechanism on my Mac. If new mail comes in, I'd call you script and send the message "New Mail", etc. Unfortunately, every time I send a message, my badge briefly displays M1-8 and then the screen clears and it works perfectly.

I'm guessing it's not your code but my badge. Can anyone recommend one that does NOT do this? It's purely cosmetic but frustratingly annoying.

Usability and missed features

Hi ...

i used the Windows-Gui and the changed to Python on Linux, because commandline is faster. *g

But ...

... in the Windows-Gui i can manage all messages separately ... and attached deifferent modes to them (speed, appearance, e.g.) in python this possibility is missing (or i can't see it).

Also the Windows-Gui gives me the ability to save the whole setup of the badge in a File, so i can use different setups for 1 Tag for different possible applications.

Is there an intentention to create a gui for python or to integrate all features of the Windows-Gui?

Greets
Stefan

Different 11x40 Device?

I got a generic 11x40 LED badge from China (white)
It identifies itself as 0483:5750 (MM32 custom HID) instead of 0416:5020.
Obviously, led-badge-11x44.py won't run correctly, because the IDs do not match.
Anyone else run into this?

Came with a baidu cloud link to download their software "MiniLED9.92" if it helps
https://pan.baidu.com/s/1bp29yaj
The box claims it's a B1248, but I don't think that's correct, as this is a 11x40 LED badge.

Add more icons and animations

Can we add some more icons and animations to the gfx folder?
Attached is one I created, feel free to add it to the code, share and enjoy.
python3 ./led-badge-11x44.py -s4 -m5 :gfx/animated_alien_48x11.png:

animated_alien_48x11

How to suppress initial message "M1-8"

Hello Jรผrgen, thank you for the great tool.
I am using it with Rasbian "Buster" on a Raspberry Pi 3b.
I works out of the box.
I want to use it in a Co2-Ampel; to show concentration of carbon-dioxide in a classroom.
When I want to show a new value and run the script again, it's always showing "M1-8" before it shows my text.
Can I suppress this init message?

Model: https://www.berrybase.de/computer/pc-peripheriegeraete/usb-gadgets/led-name-tag-11x44-pixel-usb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.