1
0
mirror of https://github.com/20kdc/OC-KittenOS.git synced 2024-11-27 04:48:05 +11:00

Fix app-batmon losing track of time

This commit is contained in:
20kdc 2018-06-12 21:45:54 +01:00
parent 6237871d36
commit 1e3bf096d5

View File

@ -5,8 +5,8 @@
-- Port of the original 'batmon.lua' from KittenOS Legacy.
local window = neo.requireAccess("x.neo.pub.window", "window")(10, 2)
-- OCE/s, OCE at last check, uptime of last check
local lastChange, lastValue, lastTimer = 0
-- OCE/s, OCE at last check, uptime of last timer set, uptime of last check
local lastChange, lastValue, lastTimer, lpTimer = 0
local usage = {
"[####]:",
"[###:]:",
@ -45,8 +45,9 @@ end
local function update()
local nv = os.energy()
if lastValue then
lastChange = (nv - lastValue) / (os.uptime() - lastTimer)
lastChange = (nv - lastValue) / (os.uptime() - lpTimer)
end
lpTimer = os.uptime()
lastValue = nv
lastTimer = os.uptime() + 10
if lastChange then