jnweiger / led-name-badge-ls32

Upload tool for an led name tag with USB-HID interface
GNU General Public License v2.0
223 stars 81 forks source link

Refactoring of write methods, adding device selection #48

Closed bensartori closed 1 week ago

bensartori commented 4 weeks ago

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 commented 1 week ago

Mega! ;) Thanks.