diff --git a/coordinator/coordinator.lua b/coordinator/coordinator.lua index 0054436..bc97c99 100644 --- a/coordinator/coordinator.lua +++ b/coordinator/coordinator.lua @@ -95,9 +95,9 @@ function coordinator.load_config() ---@class monitors_struct local monitors = { - primary = nil, ---@type table|nil - primary_name = "", - flow = nil, ---@type table|nil + main = nil, ---@type table|nil + main_name = "", + flow = nil, ---@type table|nil flow_name = "", unit_displays = {}, unit_name_map = {} @@ -121,11 +121,11 @@ function coordinator.load_config() return 2, "Main monitor is not connected." end - monitors.primary = ppm.get_periph(config.MainDisplay) - monitors.primary_name = config.MainDisplay + monitors.main = ppm.get_periph(config.MainDisplay) + monitors.main_name = config.MainDisplay - monitors.primary.setTextScale(0.5) - w, _ = ppm.monitor_block_size(monitors.primary.getSize()) + monitors.main.setTextScale(0.5) + w, _ = ppm.monitor_block_size(monitors.main.getSize()) if w ~= 8 then return 2, util.c("Main monitor width is incorrect (was ", w, ", must be 8).") end diff --git a/coordinator/renderer.lua b/coordinator/renderer.lua index a1826e4..541b1a7 100644 --- a/coordinator/renderer.lua +++ b/coordinator/renderer.lua @@ -52,6 +52,16 @@ local function _init_display(monitor) end end +-- print out that the monitor is too small +---@param monitor table monitor +local function _print_too_small(monitor) + monitor.setCursorPos(1, 1) + monitor.setBackgroundColor(colors.black) + monitor.setTextColor(colors.red) + monitor.clear() + monitor.write("monitor too small") +end + -- disable the flow view ---@param disable boolean function renderer.legacy_disable_flow_view(disable) @@ -64,15 +74,15 @@ function renderer.set_displays(monitors) engine.monitors = monitors -- report to front panel as connected - iocontrol.fp_monitor_state("main", engine.monitors.primary ~= nil) + iocontrol.fp_monitor_state("main", engine.monitors.main ~= nil) iocontrol.fp_monitor_state("flow", engine.monitors.flow ~= nil) for i = 1, #engine.monitors.unit_displays do iocontrol.fp_monitor_state(i, true) end end -- init all displays in use by the renderer function renderer.init_displays() - -- init primary and flow monitors - _init_display(engine.monitors.primary) + -- init main and flow monitors + _init_display(engine.monitors.main) if not engine.disable_flow_view then _init_display(engine.monitors.flow) end -- init unit displays @@ -94,8 +104,8 @@ end -- initialize the dmesg output window function renderer.init_dmesg() - local disp_w, disp_h = engine.monitors.primary.getSize() - engine.dmesg_window = window.create(engine.monitors.primary, 1, 1, disp_w, disp_h) + local disp_w, disp_h = engine.monitors.main.getSize() + engine.dmesg_window = window.create(engine.monitors.main, 1, 1, disp_w, disp_h) log.direct_dmesg(engine.dmesg_window) end @@ -166,8 +176,8 @@ function renderer.try_start_ui() status, msg = pcall(function () -- show main view on main monitor - if engine.monitors.primary ~= nil then - engine.ui.main_display = DisplayBox{window=engine.monitors.primary,fg_bg=style.root} + if engine.monitors.main ~= nil then + engine.ui.main_display = DisplayBox{window=engine.monitors.main,fg_bg=style.root} main_view(engine.ui.main_display) end @@ -244,14 +254,14 @@ function renderer.handle_disconnect(device) if not engine.monitors then return false end - if engine.monitors.primary == device then + if engine.monitors.main == device then if engine.ui.main_display ~= nil then -- delete element tree and clear root UI elements engine.ui.main_display.delete() end is_used = true - engine.monitors.primary = nil + engine.monitors.main = nil engine.ui.main_display = nil iocontrol.fp_monitor_state("main", false) @@ -298,9 +308,9 @@ function renderer.handle_reconnect(name, device) -- note: handle_resize is a more adaptive way of re-initializing a connected monitor -- since it can handle a monitor being reconnected that isn't the right size - if engine.monitors.primary_name == name then + if engine.monitors.main_name == name then is_used = true - engine.monitors.primary = device + engine.monitors.main = device renderer.handle_resize(name) elseif engine.monitors.flow_name == name then @@ -334,8 +344,8 @@ function renderer.handle_resize(name) if not engine.monitors then return false, false end - if engine.monitors.primary_name == name and engine.monitors.primary then - local device = engine.monitors.primary ---@type table + if engine.monitors.main_name == name and engine.monitors.main then + local device = engine.monitors.main ---@type table -- this is necessary if the bottom left block was broken and on reconnect _init_display(device) @@ -343,9 +353,9 @@ function renderer.handle_resize(name) is_used = true -- resize dmesg window if needed, but don't make it thinner - local disp_w, disp_h = engine.monitors.primary.getSize() + local disp_w, disp_h = engine.monitors.main.getSize() local dmsg_w, _ = engine.dmesg_window.getSize() - engine.dmesg_window.reposition(1, 1, math.max(disp_w, dmsg_w), disp_h, engine.monitors.primary) + engine.dmesg_window.reposition(1, 1, math.max(disp_w, dmsg_w), disp_h, engine.monitors.main) if ui.main_display then ui.main_display.delete() @@ -368,11 +378,7 @@ function renderer.handle_resize(name) ui.main_display = nil end - device.setCursorPos(1, 1) - device.setBackgroundColor(colors.black) - device.setTextColor(colors.red) - device.clear() - device.write("monitor too small") + _print_too_small(device) iocontrol.fp_monitor_state("main", false) is_ok = false @@ -407,11 +413,7 @@ function renderer.handle_resize(name) ui.flow_display = nil end - device.setCursorPos(1, 1) - device.setBackgroundColor(colors.black) - device.setTextColor(colors.red) - device.clear() - device.write("monitor too small") + _print_too_small(device) iocontrol.fp_monitor_state("flow", false) is_ok = false @@ -448,11 +450,7 @@ function renderer.handle_resize(name) ui.unit_displays[idx] = nil end - device.setCursorPos(1, 1) - device.setBackgroundColor(colors.black) - device.setTextColor(colors.red) - device.clear() - device.write("monitor too small") + _print_too_small(device) iocontrol.fp_monitor_state(idx, false) is_ok = false @@ -474,7 +472,7 @@ function renderer.handle_mouse(event) if engine.fp_ready and event.monitor == "terminal" then engine.ui.front_panel.handle_mouse(event) elseif engine.ui_ready then - if event.monitor == engine.monitors.primary_name then + if event.monitor == engine.monitors.main_name then if engine.ui.main_display then engine.ui.main_display.handle_mouse(event) end elseif event.monitor == engine.monitors.flow_name then if engine.ui.flow_display then engine.ui.flow_display.handle_mouse(event) end diff --git a/coordinator/startup.lua b/coordinator/startup.lua index d3e0f5c..10294f8 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v1.2.10" +local COORDINATOR_VERSION = "v1.2.11" local CHUNK_LOAD_DELAY_S = 30.0 diff --git a/reactor-plc/databus.lua b/reactor-plc/databus.lua index 937b954..7436dbb 100644 --- a/reactor-plc/databus.lua +++ b/reactor-plc/databus.lua @@ -70,7 +70,7 @@ function databus.tx_link_state(state) end -- transmit reactor enable state across the bus ----@param active boolean|nil reactor active +---@param active any reactor active function databus.tx_reactor_state(active) databus.ps.publish("reactor_active", active == true) end