Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

micropython/usb/usb-device/usb/device/core.py: Add alternate setting support plus a few fixes and improvements.#1031

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
HLammers wants to merge3 commits intomicropython:master
base:master
Choose a base branch
Loading
fromHLammers:master

Conversation

@HLammers
Copy link

Summary

  • AddedbAlternateSetting as argument toDescriptor.interface, because it is used for USB MIDI 2.0
  • Fixed the loop reserving other string indexes used by built-in driverswhile len(strs) < builtin_driver.str_max: towhile len(strs) < builtin\_driver.str\_max - 1: (row 169) becausestr_max equals to one more than the highest string descriptor index value used by any built-in descriptor according to thedocs and added a comment that this loop is probably unnecessary or even wrong
  • Removedimport time (not used)
  • Removed unused/duplicate_Device.config argumentconfig_str
  • Some code optimisations (in particular to theBuffer class)

Testing

  • Tested with micropython/usb/examples/device/midi_example.py
  • Tested the Buffer class with micropython/usb/usb-device/usb/device/tests/test_core_buffer.py
  • Tested with a soon to be made public multi-port MIDI module draft which adds port names tostrs

Trade-offs and Alternatives

None

⦁Removed `import time` (not used)⦁Removed unused/duplicate `_Device.config` argument `config_str`⦁Fixed the loop reserving other string indexes used by built-in drivers `while len(strs) < builtin_driver.str_max:` to `while len(strs) < builtin\_driver.str\_max - 1:` (row 169)because str_max equals to one more than the highest string descriptor index value used by any built-in descriptor according to the [docs](https://docs.micropython.org/en/latest/library/machine.USBDevice.html) and added a comment that this loop is probably unnecessary or even wrong⦁Added `bAlternateSetting` as argument to `Descriptor.interface`, because it is used for USB MIDI 2.0⦁Some code optimisations
Update fromatting
@HLammersHLammers changed the titlemicropython/usb/usb-device/usb/device/core.[: Add alternate setting support plus a few fixes and improvements.micropython/usb/usb-device/usb/device/core.py: Add alternate setting support plus a few fixes and improvements.Jul 5, 2025
@HLammers
Copy link
Author

The updated version ofcore.py is used in this project, which also shows that it is working:https://github.com/orgs/micropython/discussions/17640

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@HLammers

[8]ページ先頭

©2009-2025 Movatter.jp