#460 moved connect/disconnect/resize to render thread

This commit is contained in:
Mikayla Fischler 2024-04-07 19:54:22 -04:00
parent 31a663e86b
commit 92a4277f73

View File

@ -24,8 +24,8 @@ local RENDER_SLEEP = 100 -- (100ms, 2 ticks)
local MQ__RENDER_CMD = { local MQ__RENDER_CMD = {
START_MAIN_UI = 1, START_MAIN_UI = 1,
MON_DISCONNECT = 2, MON_CONNECT = 2,
MON_CONNECT = 3, MON_DISCONNECT = 3,
MON_RESIZE = 4, MON_RESIZE = 4,
UPDATE = 5 UPDATE = 5
} }
@ -88,11 +88,7 @@ function threads.thread__main(smem)
log_sys("non-comms modem disconnected") log_sys("non-comms modem disconnected")
end end
elseif type == "monitor" then elseif type == "monitor" then
if renderer.handle_disconnect(device) then smem.q.mq_render.push_data(MQ__RENDER_CMD.MON_DISCONNECT, device)
log_sys("lost a configured monitor")
else
log_sys("lost an unused monitor")
end
elseif type == "speaker" then elseif type == "speaker" then
log_sys("lost alarm sounder speaker") log_sys("lost alarm sounder speaker")
iocontrol.fp_has_speaker(false) iocontrol.fp_has_speaker(false)
@ -114,11 +110,7 @@ function threads.thread__main(smem)
log_sys("wired modem reconnected") log_sys("wired modem reconnected")
end end
elseif type == "monitor" then elseif type == "monitor" then
if renderer.handle_reconnect(param1, device) then smem.q.mq_render.push_data(MQ__RENDER_CMD.MON_CONNECT, { name = param1, device = device })
log_sys(util.c("configured monitor ", param1, " reconnected"))
else
log_sys(util.c("unused monitor ", param1, " connected"))
end
elseif type == "speaker" then elseif type == "speaker" then
log_sys("alarm sounder speaker reconnected") log_sys("alarm sounder speaker reconnected")
sounder.reconnect(device) sounder.reconnect(device)
@ -126,10 +118,7 @@ function threads.thread__main(smem)
end end
end end
elseif event == "monitor_resize" then elseif event == "monitor_resize" then
local is_used, is_ok = renderer.handle_resize(param1) smem.q.mq_render.push_data(MQ__RENDER_CMD.MON_RESIZE, param1)
if is_used then
log_sys(util.c("configured monitor ", param1, " resized, ", util.trinary(is_ok, "display still fits", "display no longer fits")))
end
elseif event == "timer" then elseif event == "timer" then
if loop_clock.is_clock(param1) then if loop_clock.is_clock(param1) then
-- main loop tick -- main loop tick
@ -292,15 +281,34 @@ function threads.thread__render(smem)
else else
log_graphics("main UI draw took " .. (util.time_ms() - draw_start) .. "ms") log_graphics("main UI draw took " .. (util.time_ms() - draw_start) .. "ms")
end end
elseif msg.message == MQ__RENDER_CMD.MON_DISCONNECT then
-- monitor lost
elseif msg.message == MQ__RENDER_CMD.MON_CONNECT then
-- monitor connected
elseif msg.message == MQ__RENDER_CMD.UPDATE then elseif msg.message == MQ__RENDER_CMD.UPDATE then
-- new data -- new data
end end
elseif msg.qtype == mqueue.TYPE.DATA then elseif msg.qtype == mqueue.TYPE.DATA then
-- received data -- received data
local cmd = msg.message ---@type queue_data
if cmd.key == MQ__RENDER_CMD.MON_CONNECT then
-- monitor connected
if renderer.handle_reconnect(cmd.val.name, cmd.val.device) then
log_sys(util.c("configured monitor ", cmd.val.name, " reconnected"))
else
log_sys(util.c("unused monitor ", cmd.val.name, " connected"))
end
elseif cmd.key == MQ__RENDER_CMD.MON_DISCONNECT then
-- monitor disconnected
if renderer.handle_disconnect(cmd.val) then
log_sys("lost a configured monitor")
else
log_sys("lost an unused monitor")
end
elseif cmd.key == MQ__RENDER_CMD.MON_RESIZE then
-- monitor resized
local is_used, is_ok = renderer.handle_resize(cmd.val)
if is_used then
log_sys(util.c("configured monitor ", cmd.val, " resized, ", util.trinary(is_ok, "display fits", "display does not fit")))
end
end
elseif msg.qtype == mqueue.TYPE.PACKET then elseif msg.qtype == mqueue.TYPE.PACKET then
-- received a packet -- received a packet
end end