From 250db00794a28a225c74817fd9c954954764895a Mon Sep 17 00:00:00 2001 From: Mikayla Date: Sat, 28 Jun 2025 17:26:49 +0000 Subject: [PATCH] #580 supervisor front panel updates for wired modem support --- supervisor/panel/front_panel.lua | 24 +++++++++++++----------- supervisor/renderer.lua | 12 +++++------- supervisor/startup.lua | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/supervisor/panel/front_panel.lua b/supervisor/panel/front_panel.lua index fb865a3..14e224e 100644 --- a/supervisor/panel/front_panel.lua +++ b/supervisor/panel/front_panel.lua @@ -34,8 +34,8 @@ local ind_grn = style.ind_grn -- create new front panel view ---@param panel DisplayBox main displaybox ----@param wl_modem boolean if there is a separate wireless modem -local function init(panel, wl_modem) +---@param config svr_config configuraiton +local function init(panel, config) local s_hi_box = style.theme.highlight_box local s_hi_bright = style.theme.highlight_box_bright @@ -63,21 +63,23 @@ local function init(panel, wl_modem) heartbeat.register(databus.ps, "heartbeat", heartbeat.update) - local c_modem = LED{parent=system,label="MODEM"..util.trinary(wl_modem," A",""),colors=ind_grn} - system.line_break() - - c_modem.register(databus.ps, "has_modem_a", c_modem.update) - - if wl_modem then - local p_modem = LED{parent=system,label="MODEM B",colors=ind_grn} + if config.WirelessModem then + local wl_modem = LED{parent=system,label="WL MODEM",colors=ind_grn} system.line_break() - p_modem.register(databus.ps, "has_modem_b", p_modem.update) + wl_modem.register(databus.ps, "has_wl_modem", wl_modem.update) + end + + if config.WiredModem then + local wd_modem = LED{parent=system,label="WD MODEM",colors=ind_grn} + system.line_break() + + wd_modem.register(databus.ps, "has_wd_modem", wd_modem.update) end ---@diagnostic disable-next-line: undefined-field local comp_id = util.sprintf("(%d)", os.getComputerID()) - TextBox{parent=system,x=11,y=4,width=6,text=comp_id,fg_bg=style.fp.disabled_fg} + TextBox{parent=system,x=12,y=4,width=6,text=comp_id,fg_bg=style.fp.disabled_fg} -- -- about footer diff --git a/supervisor/renderer.lua b/supervisor/renderer.lua index 1acde3a..8db7a4a 100644 --- a/supervisor/renderer.lua +++ b/supervisor/renderer.lua @@ -19,16 +19,14 @@ local ui = { } -- try to start the UI ----@param wl_modem boolean if there is a separate wireless modem to display the status of ----@param theme FP_THEME front panel theme ----@param color_mode COLOR_MODE color mode +---@param config svr_config configuration ---@return boolean success, any error_msg -function renderer.try_start_ui(wl_modem, theme, color_mode) +function renderer.try_start_ui(config) local status, msg = true, nil if ui.display == nil then -- set theme - style.set_theme(theme, color_mode) + style.set_theme(config.FrontPanelTheme, config.ColorMode) -- reset terminal term.setTextColor(colors.white) @@ -42,7 +40,7 @@ function renderer.try_start_ui(wl_modem, theme, color_mode) end -- apply color mode - local c_mode_overrides = style.theme.color_modes[color_mode] + local c_mode_overrides = style.theme.color_modes[config.ColorMode] for i = 1, #c_mode_overrides do term.setPaletteColor(c_mode_overrides[i].c, c_mode_overrides[i].hex) end @@ -50,7 +48,7 @@ function renderer.try_start_ui(wl_modem, theme, color_mode) -- init front panel view status, msg = pcall(function () ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root} - panel_view(ui.display, wl_modem) + panel_view(ui.display, config) end) if status then diff --git a/supervisor/startup.lua b/supervisor/startup.lua index 3aa46f1..eab0000 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -130,7 +130,7 @@ local function main() if not pcie.init(config, println) then return end -- start UI - local fp_ok, message = renderer.try_start_ui(pcie.has_pocket_nic(), config.FrontPanelTheme, config.ColorMode) + local fp_ok, message = renderer.try_start_ui(config) if not fp_ok then println_ts(util.c("UI error: ", message))