-
-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Added power tracking api #12691
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
Added power tracking api #12691
Conversation
Tested on STM32F446, and atmega32u4, and atmega32u2. |
7a5fcda
to
7667026
Compare
While the code looks good, "power tracking" doesn't sound right to me. The point is getting the status from USB, correct? Then maybe "USB Power State" would be more accurate, maybe? That said, I know that naming stuff is hard. I have some truly atrociously named stuff that has made it into core, so I definitely understand that. |
Thank you for your contribution! |
74f3fc8
to
c084d5a
Compare
@drashna Let me know if any further changes are needed. |
Honestly, i'm still not too happy with the naming, as it doesn't really reflect what it is.
|
@drashna Renamed as you suggested. |
I re-tested the current version of a branch on an STM32F446-based keyboard. On the computer suspending I observed: On the computer exiting suspend I observed: On the 1Amp port of a 'powerzilla' power bank I observed: USB_DEVICE_STATE_INIT -> USB_DEVICE_STATE_SUSPEND Note: since I didn't analyze this with a logical analyzer, in theory there could be super fast state transitions that I missed with my eyes. |
Co-authored-by: Drashna Jaelre <[email protected]>
7aadee6
to
e4e7de9
Compare
Rebased (not cause this PR needed it, but because the dependent 12692 PR had a conflict) |
Can you explain the unused |
@tzarc In general, the configuration number matters to how much power the USB device is allowed to consume, because each USB device could have multiple configurations, only one of which is selected at any point in time (or none if not configured). One possible usecase in the future would be, if a keyboard has a 500mA-using solenoid driver, it could have one configuration to select 500mA, and another one to select 100mA, and disable the solenoid driver automatically, or set it into a 100mA current-limited mode. So when you plug the keyboard into a normal USB port, or powered hub, you get full solenoid operation, but in an unpowered usb hub, the solenoid is automatically disabled, or in slower current-limited mode. Or in case of keyboards with high current-consumption backlights, it could throttle the backlight intensity when plugged into a 100mA-only port. I'm not 100% sure if default HID operating system drivers are smart enough to select the alternative 100mA configuration, when they can't enable the 500mA one, or if they will just disable the USB device, so my specific example may not be a good one, but it's still worth keeping the interface, even if my example doesn't actually work in the real world, just in case we will add multiple-configuration support in the future for other reasons. |
* qmk/develop: (21 commits) massdrop alt/ctrl: support saving into nvm (qmk#6068) Added power tracking api (qmk#12691) Mechlovin Hannah60RGB touch-up (qmk#14646) [Core] Fix "6kro enable" and clarify naming (qmk#14563) [Keymap] Update to Drashna Code (qmk#14644) [Keyboard] add support for Quark_LP (qmk#14552) [Keyboard] Update Grandiceps to Rev2 (qmk#14618) [Keymap] Jonavin murphpad keymap update (qmk#14637) [Keyboard] Updates for Tractyl Manuform config (qmk#14641) [Keyboard] Fix end of file issue for Owlab suit80 (qmk#14640) [Keyboard] Add support for PaladinPad, Arya pcb and move keyboards by KapCave into their own directory (qmk#14194) [Keymap] Keychron Q1 user keymap (qmk#14636) Fix for mechlovin/adelais/standard_led/arm/rev4 (qmk#14639) convert checkerboards/quark_squared:via rules.mk to Unix line endings (qmk#14638) Mechlovin Delphine: add LAYOUT_numpad_6x4 (qmk#14635) Move "firmware size check skipped" note to message.mk (qmk#14632) [Keymap] fix NKRO - switch to get_mods() and refactor encoder action code (qmk#14278) [Keyboard] Yampad VIA support (qmk#14397) [Keyboard] Add OwLab Suit80 (qmk#14362) [Keymap] arkag userspace/keymap -- new macro and minor preonic keymap change (qmk#14623) ...
* Add power tracking API to lufa and chibios targets * power.c: Pass through power state to the notify function * power: added notify_power_state_change_user too. * making it pass the PR linter * Add a POWER_STATE_NO_INIT state, that we start in before calling power_init(); * Rename *power* to *usb_power* * removing stray newline * Rename usb_power* to usb_device_state* * Update quantum/usb_device_state.h Co-authored-by: Drashna Jaelre <[email protected]> * Fix comment * usb_device_state.h: Don't include quantum.h, only the necessary headers. Co-authored-by: Drashna Jaelre <[email protected]>
* Add power tracking API to lufa and chibios targets * power.c: Pass through power state to the notify function * power: added notify_power_state_change_user too. * making it pass the PR linter * Add a POWER_STATE_NO_INIT state, that we start in before calling power_init(); * Rename *power* to *usb_power* * removing stray newline * Rename usb_power* to usb_device_state* * Update quantum/usb_device_state.h Co-authored-by: Drashna Jaelre <[email protected]> * Fix comment * usb_device_state.h: Don't include quantum.h, only the necessary headers. Co-authored-by: Drashna Jaelre <[email protected]>
Description
This has now been tested on chibios, running on an STM32F446, and atmega32u4, and atmega32u2.
Types of Changes
Issues Fixed or Closed by This PR
Checklist