From 99ea59a86b561c2c4d19fcf2a85dc005597fa68b Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sun, 16 Feb 2025 13:32:08 -0500 Subject: [PATCH] #526 coordinator front panel scale to term size --- coordinator/renderer.lua | 2 +- coordinator/startup.lua | 2 +- coordinator/ui/components/pkt_entry.lua | 8 +++++--- coordinator/ui/layout/front_panel.lua | 10 ++++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/coordinator/renderer.lua b/coordinator/renderer.lua index cfa5013..d3ca0cd 100644 --- a/coordinator/renderer.lua +++ b/coordinator/renderer.lua @@ -137,7 +137,7 @@ function renderer.try_start_fp() if not engine.fp_ready then -- show front panel view on terminal status, msg = pcall(function () - engine.ui.front_panel = DisplayBox{window=term.native(),fg_bg=style.fp.root} + engine.ui.front_panel = DisplayBox{window=term.current(),fg_bg=style.fp.root} panel_view(engine.ui.front_panel, #engine.monitors.unit_displays) end) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 7343145..4bb3412 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -19,7 +19,7 @@ local renderer = require("coordinator.renderer") local sounder = require("coordinator.sounder") local threads = require("coordinator.threads") -local COORDINATOR_VERSION = "v1.6.7" +local COORDINATOR_VERSION = "v1.6.8" local CHUNK_LOAD_DELAY_S = 30.0 diff --git a/coordinator/ui/components/pkt_entry.lua b/coordinator/ui/components/pkt_entry.lua index 78084f9..a377d0e 100644 --- a/coordinator/ui/components/pkt_entry.lua +++ b/coordinator/ui/components/pkt_entry.lua @@ -28,6 +28,8 @@ local function init(parent, id) local ps = iocontrol.get_db().fp.ps + local term_w, _ = term.getSize() + -- root div local root = Div{parent=parent,x=2,y=2,height=4,width=parent.get_width()-2} local entry = Div{parent=root,x=2,y=1,height=3,fg_bg=s_hi_bright} @@ -43,9 +45,9 @@ local function init(parent, id) local pkt_fw_v = TextBox{parent=entry,x=14,y=2,text=" ------- ",width=20,fg_bg=label_fg} pkt_fw_v.register(ps, ps_prefix .. "fw", pkt_fw_v.set_value) - TextBox{parent=entry,x=35,y=2,text="RTT:",width=4} - local pkt_rtt = DataIndicator{parent=entry,x=40,y=2,label="",unit="",format="%5d",value=0,width=5,fg_bg=label_fg} - TextBox{parent=entry,x=46,y=2,text="ms",width=4,fg_bg=label_fg} + TextBox{parent=entry,x=term_w-16,y=2,text="RTT:",width=4} + local pkt_rtt = DataIndicator{parent=entry,x=term_w-11,y=2,label="",unit="",format="%5d",value=0,width=5,fg_bg=label_fg} + TextBox{parent=entry,x=term_w-5,y=2,text="ms",width=4,fg_bg=label_fg} pkt_rtt.register(ps, ps_prefix .. "rtt", pkt_rtt.update) pkt_rtt.register(ps, ps_prefix .. "rtt_color", pkt_rtt.recolor) diff --git a/coordinator/ui/layout/front_panel.lua b/coordinator/ui/layout/front_panel.lua index b190468..1b32501 100644 --- a/coordinator/ui/layout/front_panel.lua +++ b/coordinator/ui/layout/front_panel.lua @@ -39,6 +39,8 @@ local led_grn = style.led_grn local function init(panel, num_units) local ps = iocontrol.get_db().fp.ps + local term_w, term_h = term.getSize() + TextBox{parent=panel,y=1,text="SCADA COORDINATOR",alignment=ALIGN.CENTER,fg_bg=style.fp_theme.header} local page_div = Div{parent=panel,x=1,y=3} @@ -131,9 +133,9 @@ local function init(panel, num_units) -- about footer -- - local about = Div{parent=main_page,width=15,height=3,x=1,y=16,fg_bg=style.fp.disabled_fg} - local fw_v = TextBox{parent=about,x=1,y=1,text="FW: v00.00.00"} - local comms_v = TextBox{parent=about,x=1,y=2,text="NT: v00.00.00"} + local about = Div{parent=main_page,width=15,height=2,y=term_h-3,fg_bg=style.fp.disabled_fg} + local fw_v = TextBox{parent=about,text="FW: v00.00.00"} + local comms_v = TextBox{parent=about,text="NT: v00.00.00"} fw_v.register(ps, "version", function (version) fw_v.set_value(util.c("FW: ", version)) end) comms_v.register(ps, "comms_version", function (version) comms_v.set_value(util.c("NT: v", version)) end) @@ -145,7 +147,7 @@ local function init(panel, num_units) -- API page local api_page = Div{parent=page_div,x=1,y=1,hidden=true} - local api_list = ListBox{parent=api_page,x=1,y=1,height=17,width=51,scroll_height=1000,fg_bg=style.fp.text_fg,nav_fg_bg=cpair(colors.gray,colors.lightGray),nav_active=cpair(colors.black,colors.gray)} + local api_list = ListBox{parent=api_page,y=1,height=term_h-2,width=term_w,scroll_height=1000,fg_bg=style.fp.text_fg,nav_fg_bg=cpair(colors.gray,colors.lightGray),nav_active=cpair(colors.black,colors.gray)} local _ = Div{parent=api_list,height=1} -- padding -- assemble page panes