From d87dfb9ebdae6dc76c56b58c8fefd04e0ac9f251 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Wed, 2 Nov 2022 12:02:52 -0400 Subject: [PATCH] #112 fixed bug with flasher --- coordinator/startup.lua | 2 +- graphics/flasher.lua | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 83a445d..5416262 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -16,7 +16,7 @@ local config = require("coordinator.config") local coordinator = require("coordinator.coordinator") local renderer = require("coordinator.renderer") -local COORDINATOR_VERSION = "alpha-v0.5.11" +local COORDINATOR_VERSION = "alpha-v0.5.12" local print = util.print local println = util.println diff --git a/graphics/flasher.lua b/graphics/flasher.lua index 5fa856a..12c6670 100644 --- a/graphics/flasher.lua +++ b/graphics/flasher.lua @@ -2,7 +2,7 @@ -- Indicator Light Flasher -- -local tcd = require("scada-common.tcallbackdsp") +local tcd = require("scada-common.tcallbackdsp") local flasher = {} @@ -26,14 +26,14 @@ local callback_counter = 0 -- this assumes it is called every 250ms, it does no checking of time on its own local function callback_250ms() if active then - for _, f in pairs(registry[PERIOD.BLINK_250_MS]) do f() end + for _, f in ipairs(registry[PERIOD.BLINK_250_MS]) do f() end if callback_counter % 2 == 0 then - for _, f in pairs(registry[PERIOD.BLINK_500_MS]) do f() end + for _, f in ipairs(registry[PERIOD.BLINK_500_MS]) do f() end end if callback_counter % 4 == 0 then - for _, f in pairs(registry[PERIOD.BLINK_1000_MS]) do f() end + for _, f in ipairs(registry[PERIOD.BLINK_1000_MS]) do f() end end callback_counter = callback_counter + 1 @@ -70,10 +70,10 @@ end ---@param f function function callback registered function flasher.stop(f) for i = 1, #registry do - for j = 1, #registry[i] do - if registry[i][j] == f then - registry[i][j] = nil - break + for key, val in ipairs(registry[i]) do + if val == f then + table.remove(registry[i], key) + return end end end