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

Change CapacityMode from 2 (%) to 1 (mWh) #14

Closed
wants to merge 1 commit into from

Conversation

forderud
Copy link
Contributor

@forderud forderud commented Aug 30, 2024

This fixes #11 by also reporting battery capacity percentage on Windows laptops that already has a battery. This makes the sample more interesting to demonstrate.

The CapacityMode units are documented in Usage Tables for HID Power Devices section 4.2.3 Battery Controls.

The total battery charge % reported by Windows appear to be a weighted sum of each battery, weighted by their respective capacities. The Arduino battery is currently harcoded to iFullChargeCapacity = 100 mWh, which is quite small. It does therefore have a relatively low influence on the total battery charge % on the laptop I've tested on.

Screenshots of 84% charge

On Windows, the Arduino appear as an additional battery with a separate charge %:
image

On MacOS the Arduino appear as a UPS battery with a separate charge %:
image

On Fedora Linux the Arduino appears as a UPS battery with separate charge %:
image

Test setup

Arduino micro on breadboard with a potentiometer connected to A7:
image

The bCharging variable is hardcoded, since I haven't connected any digital switch.

I also had to update linux/98-upower-hid.rules with ATTRS{idProduct}=="8037" to make Linux recognize the Arduino micro.

This fixes abratchik#11 by also reporting battery capacity percentage on Windows laptops that already has a battery. This makes the sample more interesting to demonstrate.

The `CapacityMode` units are documented in [Usage Tables for HID Power Devices](https://www.usb.org/sites/default/files/pdcv11.pdf) section 4.2.3 Battery Controls.

The total battery charge % reported by Windows appear to be a weighted sum of each battery, weighted by their respective capacities. The Arduino battery is currently harcoded to `iFullChargeCapacity = 100` mWh, which is quite small. It does therefore have a relatively low influence on the total battery charge % on the laptop I've tested on.
@forderud
Copy link
Contributor Author

forderud commented Sep 3, 2024

@abratchik Would it be possible for you to take a look at this PR?

The reason for proposing this change is to make the project appear more interesting and impressive "out of the box" for new developers that have not yet investigated all details.

@abratchik
Copy link
Owner

HI @forderud , as I mentioned above, changing the default will have effect on existing implementations. Having another battery for a Windows laptop is not the main use case for this library. You wrote an excellent manual so I think it makes sense to place it in Readme for those who still want to see 2 batteries in the Windows tray properly reflecting the remaining capacity.

forderud added a commit to forderud/HIDPowerDevice that referenced this pull request Sep 9, 2024
@forderud
Copy link
Contributor Author

forderud commented Sep 9, 2024

HI @forderud , as I mentioned above, changing the default will have effect on existing implementations. Having another battery for a Windows laptop is not the main use case for this library. You wrote an excellent manual so I think it makes sense to place it in Readme for those who still want to see 2 batteries in the Windows tray properly reflecting the remaining capacity.

Understood. I've now submitted #18 for updating the readme as proposed.

forderud added a commit to forderud/HIDPowerDevice that referenced this pull request Sep 9, 2024
forderud added a commit to forderud/HIDPowerDevice that referenced this pull request Sep 9, 2024
@abratchik
Copy link
Owner

Not accepted as changing defaults for Windows in order to support a special case (ACPI battery present) will break Linux and Mac compatibility.

@abratchik abratchik closed this Sep 16, 2024
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.

Windows: Device report 0% charge if additional batteries already exist
2 participants