A question about the laptop’s battery icon

Asked By 15 points N/A Posted on -
qa-featured

Hello! I was wondering how does a laptop decide what portion of the battery is still left to run the laptop. Lets say at a certain time instance it says 63% remaining, how exactly does the machinery of the laptop calculate the remaining battery. Is there some sort of formula? And how does it calculate the remaining time like right now my laptop says 28 min(18%) remaining.

SHARE
Answered By 0 points N/A #183448

A question about the laptop’s battery icon

qa-featured

Hi,

Yes, there is a formula for calculating the remaining percentage of the battery of the laptop and the time left for the remaining battery. The calculation is being calculated by the OS of the laptop i.e. Windows. The calculation can be calculated by this formula:

t = wmi.WMI(moniker = "//./root/wmi")

batts = t.ExecQuery('Select * from BatteryStatus where Voltage > 0')

time_left = 0

for _i, b in enumerate(batts):

    time_left += float(b.RemainingCapacity) / float(b.DischargeRate)

hours = int(time_left)

mins = 60 * (time_left % 1.0)

return '%i hr %i min' % (hours, mins)

 

Hope this answer will help you a lot.

Related Questions