battery-widget: Simplify capacity computation
Increase cohesion of code that computes total charge and total capacity.
This commit is contained in:
parent
3bb3d56c26
commit
0aba2f2e13
|
@ -135,10 +135,6 @@ local function worker(user_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
local capacity = 0
|
local capacity = 0
|
||||||
for _, cap in ipairs(capacities) do
|
|
||||||
capacity = capacity + cap
|
|
||||||
end
|
|
||||||
|
|
||||||
local charge = 0
|
local charge = 0
|
||||||
local status
|
local status
|
||||||
for i, batt in ipairs(battery_info) do
|
for i, batt in ipairs(battery_info) do
|
||||||
|
@ -149,6 +145,7 @@ local function worker(user_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
charge = charge + batt.charge * capacities[i]
|
charge = charge + batt.charge * capacities[i]
|
||||||
|
capacity = capacity + capacities[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
charge = charge / capacity
|
charge = charge / capacity
|
||||||
|
|
Loading…
Reference in New Issue