#469 induction matrix charge ETAs and misc cleanup/updates

This commit is contained in:
Mikayla Fischler
2024-04-27 16:27:01 -04:00
parent 7b8cea4a5c
commit 35bf56663f
8 changed files with 142 additions and 52 deletions

View File

@@ -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

View File

@@ -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