From 1e3bf096d5e433c538b81e62ba97c00aaf4fb192 Mon Sep 17 00:00:00 2001 From: 20kdc Date: Tue, 12 Jun 2018 21:45:54 +0100 Subject: [PATCH] Fix app-batmon losing track of time --- code/apps/app-batmon.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/apps/app-batmon.lua b/code/apps/app-batmon.lua index 3503286..16fef41 100644 --- a/code/apps/app-batmon.lua +++ b/code/apps/app-batmon.lua @@ -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