HIDPowerDevice icon indicating copy to clipboard operation
HIDPowerDevice copied to clipboard

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

Open forderud opened this issue 1 year ago • 3 comments

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.

forderud avatar Aug 30 '24 17:08 forderud

@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.

forderud avatar Sep 03 '24 11:09 forderud

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.

abratchik avatar Sep 09 '24 10:09 abratchik

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 avatar Sep 09 '24 10:09 forderud

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

abratchik avatar Sep 16 '24 12:09 abratchik