mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
flasher callback now private function
This commit is contained in:
parent
6d5af98310
commit
1bf8fe557c
@ -21,14 +21,35 @@ local active = false
|
|||||||
local registry = { {}, {}, {} } -- one registry table per period
|
local registry = { {}, {}, {} } -- one registry table per period
|
||||||
local callback_counter = 0
|
local callback_counter = 0
|
||||||
|
|
||||||
-- start the flasher task
|
-- blink registered indicators
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
|
||||||
|
if callback_counter % 2 == 0 then
|
||||||
|
for _, f in pairs(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
|
||||||
|
end
|
||||||
|
|
||||||
|
callback_counter = callback_counter + 1
|
||||||
|
|
||||||
|
tcd.dispatch(0.25, callback_250ms)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- start the flasher periodic
|
||||||
function flasher.init()
|
function flasher.init()
|
||||||
active = true
|
active = true
|
||||||
registry = { {}, {}, {} }
|
registry = { {}, {}, {} }
|
||||||
flasher.callback_250ms()
|
callback_250ms()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- clear all blinking indicators and stop the flasher task
|
-- clear all blinking indicators and stop the flasher periodic
|
||||||
function flasher.clear()
|
function flasher.clear()
|
||||||
active = false
|
active = false
|
||||||
registry = { {}, {}, {} }
|
registry = { {}, {}, {} }
|
||||||
@ -58,25 +79,4 @@ function flasher.stop(f)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- blink registered indicators
|
|
||||||
--
|
|
||||||
-- this assumes it is called every 250ms, it does no checking of time on its own
|
|
||||||
function flasher.callback_250ms()
|
|
||||||
if active then
|
|
||||||
for _, f in pairs(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
|
|
||||||
end
|
|
||||||
|
|
||||||
if callback_counter % 4 == 0 then
|
|
||||||
for _, f in pairs(registry[PERIOD.BLINK_1000_MS]) do f() end
|
|
||||||
end
|
|
||||||
|
|
||||||
callback_counter = callback_counter + 1
|
|
||||||
|
|
||||||
tcd.dispatch(0.25, flasher.callback_250ms)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return flasher
|
return flasher
|
||||||
|
Loading…
Reference in New Issue
Block a user