#469 induction matrix charge ETAs and misc cleanup/updates
This commit is contained in:
@@ -17,7 +17,7 @@ local max_distance = nil
|
||||
local comms = {}
|
||||
|
||||
-- protocol/data versions (protocol/data independent changes tracked by util.lua version)
|
||||
comms.version = "2.5.0"
|
||||
comms.version = "2.5.1"
|
||||
comms.api_version = "0.0.1"
|
||||
|
||||
---@enum PROTOCOL
|
||||
|
||||
@@ -22,7 +22,7 @@ local t_pack = table.pack
|
||||
local util = {}
|
||||
|
||||
-- scada-common version
|
||||
util.version = "1.3.0"
|
||||
util.version = "1.3.1"
|
||||
|
||||
util.TICK_TIME_S = 0.05
|
||||
util.TICK_TIME_MS = 50
|
||||
@@ -181,8 +181,7 @@ function util.round(x) return math.floor(x + 0.5) end
|
||||
-- get a new moving average object
|
||||
---@nodiscard
|
||||
---@param length integer history length
|
||||
---@param default number value to fill history with for first call to compute()
|
||||
function util.mov_avg(length, default)
|
||||
function util.mov_avg(length)
|
||||
local data = {}
|
||||
local index = 1
|
||||
local last_t = 0 ---@type number|nil
|
||||
@@ -215,12 +214,10 @@ function util.mov_avg(length, default)
|
||||
---@return number average
|
||||
function public.compute()
|
||||
local sum = 0
|
||||
for i = 1, length do sum = sum + data[i] end
|
||||
return sum / length
|
||||
for i = 1, #data do sum = sum + data[i] end
|
||||
return sum / #data
|
||||
end
|
||||
|
||||
public.reset(default)
|
||||
|
||||
return public
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user