Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of write methods, adding device selection #48

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

bensartori
Copy link
Contributor

@bensartori bensartori commented Jun 24, 2024

With this refactoring the handling of different write methods (up to now libusb and hidapi) has moved to an own class and its sub classes. This is a preparation to smoothly add bluetooth as a third write method in future and to be able to implement the following.

Additionally, there is the possibility list the connected devices and choose the one to be programmed. This way multiple devices may be connected to one computer and be programmed individually. With this change the endpoint number is not hardcoded anymore and the newer types of the name badge (with other USB chips) are found and programmed.

See command line options -M and -H / LedNameBadge.write(), LedNameBadge.get_available_methods(), LedNameBadge.get_available_device_ids() / class WriteMethod and its two sub classes.

All (ok, most) the decisions, validations and messages on choosing write mehtods and device ids are now concentrated in LedNameBadge._find_write_method().

It should still run on Windows (tested with pPython 3), MacOs (untested) and Python 2 (tested with Ubuntu linux)

Draft: some method documentation is still missing.

@bensartori bensartori force-pushed the refactoring-of-write-methods branch from 4e662b1 to aba522f Compare June 28, 2024 06:08
@bensartori bensartori changed the title Draft: Refactoring of write methods, adding device selection Refactoring of write methods, adding device selection Jun 28, 2024
To be backwards compatible, using Windows with hidapi is not forbidden. But now, you have to select it explicitly.
method = libusb.get_name()
print("Preferring method %s over %s with Python 2.x" % (libusb.get_name(), hidapi.get_name()))
print("because of https://github.com/jnweiger/led-badge-ls32/issues/9")
elif sys.platform.startswith('darwin'):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @s-light, Jürgen gave me the info, that you might be able to test this new version with MacOs? That would be great!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry - not really..
i have no led-badge myself - and the macos devices are owned by my mother & brother - currently not living near by...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks and sorry for bothering...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all fine :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants