mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#112 fixed bug with flasher
This commit is contained in:
parent
004c960e4d
commit
d87dfb9ebd
@ -16,7 +16,7 @@ local config = require("coordinator.config")
|
|||||||
local coordinator = require("coordinator.coordinator")
|
local coordinator = require("coordinator.coordinator")
|
||||||
local renderer = require("coordinator.renderer")
|
local renderer = require("coordinator.renderer")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "alpha-v0.5.11"
|
local COORDINATOR_VERSION = "alpha-v0.5.12"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
|
@ -26,14 +26,14 @@ local callback_counter = 0
|
|||||||
-- this assumes it is called every 250ms, it does no checking of time on its own
|
-- this assumes it is called every 250ms, it does no checking of time on its own
|
||||||
local function callback_250ms()
|
local function callback_250ms()
|
||||||
if active then
|
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
|
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
|
end
|
||||||
|
|
||||||
if callback_counter % 4 == 0 then
|
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
|
end
|
||||||
|
|
||||||
callback_counter = callback_counter + 1
|
callback_counter = callback_counter + 1
|
||||||
@ -70,10 +70,10 @@ end
|
|||||||
---@param f function function callback registered
|
---@param f function function callback registered
|
||||||
function flasher.stop(f)
|
function flasher.stop(f)
|
||||||
for i = 1, #registry do
|
for i = 1, #registry do
|
||||||
for j = 1, #registry[i] do
|
for key, val in ipairs(registry[i]) do
|
||||||
if registry[i][j] == f then
|
if val == f then
|
||||||
registry[i][j] = nil
|
table.remove(registry[i], key)
|
||||||
break
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user