MicrosoftDocs / winrt-api

WinRT reference content for developing Microsoft Universal Windows Platform (UWP) apps
Creative Commons Attribution 4.0 International
230 stars 494 forks source link

Issue in values returned by Battery.GetReport() #2456

Closed contactgc closed 7 months ago

contactgc commented 7 months ago

Hello,

We tried this method to get the battery on a hololens 2 but the values returned are not consistent:

#if WINDOWS_UWP
using Windows.Devices.Power;
#endif
    ...
#if WINDOWS_UWP    
        var aggBattery = Battery.AggregateBattery; 
        var report = aggBattery.GetReport();

        Debug.Log("Battery Report: DeviceId - " +aggBattery.DeviceId.ToString());
        Debug.Log("Battery Report: Status - " + report.Status.ToString());
        Debug.Log("Battery Report: FullCharge - " + report.FullChargeCapacityInMilliwattHours.ToString());
        Debug.Log("Battery Report: Remaining - " + report.RemainingCapacityInMilliwattHours.ToString());
        Debug.Log("Battery Report: Charge Rate - " + report.ChargeRateInMilliwatts.ToString());
        Debug.Log("Battery Report: Design Capacity - " + report.DesignCapacityInMilliwattHours.ToString());
#endif
Battery Report: DeviceId - AggregateBattery
Battery Report: Status - Discharging
Battery Report: FullCharge - 4481
Battery Report: Remaining - 3305
Battery Report: Charge Rate - -6751
Battery Report: Design Capacity - 4400

The headset was ~70% charged, which was correct from the point of view of FullCharge and Remaining, but the drain rate seems far too high. Remaining autonomy would be 0.48 hour with the battery at 70% (when discharging, RemainingCapacityInMilliwattHours / Abs(ChargeRateInMilliwatts) = remainingTimeInHours). The autnotnomie is actually much higher (between 2h and 2h30).

In this post https://forums.hololens.com/discussion/3133/is-there-a-way-to-get-the-battery-level-from-the-hololens-through-unity, the given values were:

Battery Report: DeviceId - AggregateBattery
Battery Report: Status - Discharging
Battery Report: FullCharge - 16710
Battery Report: Remaining - 15664
Battery Report: Charge Rate - -3409
Battery Report: Design Capacity - 16500

Both results are from Hololens 2, but capacities are different. 16500 looks like the capacity in mAh, while 4400 looks like the capacity in mWh (i guess). But Charge rate looks to be still in mAh in both.

Is there a unit issue in the values returned by Battery.GetReport() ?

Regards


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

stevewhims commented 7 months ago

Hi, and thanks for filing this issue. The feedback channel you're using here (Submit and view feedback for > This page) is for feedback about the documentation in this topic itself, as published. For example, if the content is incorrect or incomplete.

But this particular issue doesn't feel like it's saying that something needs changing in the docs.

For questions (or requests for help) regarding a specific scenario, like this, one option is to click Submit and view feedback for > This product, and you'll be taken to Microsoft Q&A (more info about that below).

Here are all of the developer support resources, for completeness.

I'll go ahead and close this issue now, since there's no action to take in the documentation. You can always reply to a closed issue, or even re-open it if you feel it's been closed in error.

Thanks! -Steve