From 18d093e72d102f1bd968a0e6a0a750293473829c Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sun, 16 Feb 2025 12:34:06 -0500 Subject: [PATCH] #526 reactor PLC front panel scale to term size --- reactor-plc/panel/front_panel.lua | 25 ++++++++++++++----------- reactor-plc/startup.lua | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/reactor-plc/panel/front_panel.lua b/reactor-plc/panel/front_panel.lua index ba6c27b..ab20365 100644 --- a/reactor-plc/panel/front_panel.lua +++ b/reactor-plc/panel/front_panel.lua @@ -40,6 +40,8 @@ local function init(panel) local disabled_fg = style.fp.disabled_fg + local term_w, term_h = term.getSize() + local header = TextBox{parent=panel,y=1,text="FISSION REACTOR PLC - UNIT ?",alignment=ALIGN.CENTER,fg_bg=style.theme.header} header.register(databus.ps, "unit_id", function (id) header.set_value(util.c("FISSION REACTOR PLC - UNIT ", id)) end) @@ -121,7 +123,7 @@ local function init(panel) -- status & controls -- - local status = Div{parent=panel,width=19,height=18,x=17,y=3} + local status = Div{parent=panel,width=term_w-32,height=18,x=17,y=3} local active = LED{parent=status,x=2,width=12,label="RCT ACTIVE",colors=ind_grn} @@ -131,14 +133,15 @@ local function init(panel) emer_cool.register(databus.ps, "emer_cool", emer_cool.update) end - local status_trip_rct = Rectangle{parent=status,width=20,height=3,x=1,border=border(1,s_hi_box.bkg,true),even_inner=true} - local status_trip = Div{parent=status_trip_rct,width=18,height=1,fg_bg=s_hi_box} + local status_trip_rct = Rectangle{parent=status,height=3,x=1,border=border(1,s_hi_box.bkg,true),even_inner=true} + local status_trip = Div{parent=status_trip_rct,height=1,fg_bg=s_hi_box} local scram = LED{parent=status_trip,width=10,label="RPS TRIP",colors=ind_red,flash=true,period=flasher.PERIOD.BLINK_250_MS} - local controls_rct = Rectangle{parent=status,width=17,height=3,x=1,border=border(1,s_hi_box.bkg,true),even_inner=true} - local controls = Div{parent=controls_rct,width=15,height=1,fg_bg=s_hi_box} - PushButton{parent=controls,x=1,y=1,min_width=7,text="SCRAM",callback=databus.rps_scram,fg_bg=cpair(colors.black,colors.red),active_fg_bg=cpair(colors.black,colors.red_off)} - PushButton{parent=controls,x=9,y=1,min_width=7,text="RESET",callback=databus.rps_reset,fg_bg=cpair(colors.black,colors.yellow),active_fg_bg=cpair(colors.black,colors.yellow_off)} + local controls_rct = Rectangle{parent=status,width=status.get_width()-2,height=3,x=1,border=border(1,s_hi_box.bkg,true),even_inner=true} + local controls = Div{parent=controls_rct,width=controls_rct.get_width()-2,height=1,fg_bg=s_hi_box} + local button_padding = math.floor((controls.get_width() - 14) / 3) + PushButton{parent=controls,x=button_padding+1,y=1,min_width=7,text="SCRAM",callback=databus.rps_scram,fg_bg=cpair(colors.black,colors.red),active_fg_bg=cpair(colors.black,colors.red_off)} + PushButton{parent=controls,x=(2*button_padding)+9,y=1,min_width=7,text="RESET",callback=databus.rps_reset,fg_bg=cpair(colors.black,colors.yellow),active_fg_bg=cpair(colors.black,colors.yellow_off)} active.register(databus.ps, "reactor_active", active.update) scram.register(databus.ps, "rps_scram", scram.update) @@ -147,9 +150,9 @@ local function init(panel) -- about footer -- - local about = Div{parent=panel,width=15,height=3,x=1,y=18,fg_bg=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=panel,width=15,height=2,x=1,y=term_h-1,fg_bg=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(databus.ps, "version", function (version) fw_v.set_value(util.c("FW: ", version)) end) comms_v.register(databus.ps, "comms_version", function (version) comms_v.set_value(util.c("NT: v", version)) end) @@ -158,7 +161,7 @@ local function init(panel) -- rps list -- - local rps = Rectangle{parent=panel,width=16,height=16,x=36,y=3,border=border(1,s_hi_box.bkg),thin=true,fg_bg=s_hi_box} + local rps = Rectangle{parent=panel,width=16,height=16,x=term_w-15,y=3,border=border(1,s_hi_box.bkg),thin=true,fg_bg=s_hi_box} local rps_man = LED{parent=rps,label="MANUAL",colors=ind_red} local rps_auto = LED{parent=rps,label="AUTOMATIC",colors=ind_red} local rps_tmo = LED{parent=rps,label="TIMEOUT",colors=ind_red} diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index f86657a..6431d3d 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc") local renderer = require("reactor-plc.renderer") local threads = require("reactor-plc.threads") -local R_PLC_VERSION = "v1.8.16" +local R_PLC_VERSION = "v1.8.17" local println = util.println local println_ts = util.println_ts