diff --git a/coordinator/configure.lua b/coordinator/configure.lua index b2576c5..5b223e8 100644 --- a/coordinator/configure.lua +++ b/coordinator/configure.lua @@ -55,21 +55,7 @@ local style = {} style.root = cpair(colors.black, colors.lightGray) style.header = cpair(colors.white, colors.gray) -style.colors = { - { c = colors.red, hex = 0xdf4949 }, - { c = colors.orange, hex = 0xffb659 }, - { c = colors.yellow, hex = 0xfffc79 }, - { c = colors.lime, hex = 0x80ff80 }, - { c = colors.green, hex = 0x4aee8a }, - { c = colors.cyan, hex = 0x34bac8 }, - { c = colors.lightBlue, hex = 0x6cc0f2 }, - { c = colors.blue, hex = 0x0096ff }, - { c = colors.purple, hex = 0xb156ee }, - { c = colors.pink, hex = 0xf26ba2 }, - { c = colors.magenta, hex = 0xf9488a }, - { c = colors.lightGray, hex = 0xcacaca }, - { c = colors.gray, hex = 0x575757 } -} +style.colors = themes.smooth_stone.colors local bw_fg_bg = cpair(colors.black, colors.white) local g_lg_fg_bg = cpair(colors.gray, colors.lightGray) @@ -841,30 +827,26 @@ local function config_view(display) TextBox{parent=clr_c_2,x=1,y=1,height=6,text="By default, this project uses green/red heavily to distinguish ok and not, with some indicators also using multiple colors. By selecting a color blindness below, blues will be used instead of greens on indicators and multi-color indicators will be split up as space permits."} local function recolor(value) + local c = themes.smooth_stone.color_modes[value] + if value == 1 then for i = 1, #style.colors do term.setPaletteColor(style.colors[i].c, style.colors[i].hex) end - elseif value == 2 then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf5e633) - term.setPaletteColor(colors.red, 0xff521a) - elseif value == 3 then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf7c311) - term.setPaletteColor(colors.red, 0xfb5615) - elseif value == 4 then - term.setPaletteColor(colors.green, 0x00ecff) - term.setPaletteColor(colors.yellow, 0xffbc00) - term.setPaletteColor(colors.red, 0xff0000) + else + term.setPaletteColor(colors.green, c[1].hex) + term.setPaletteColor(colors.yellow, c[2].hex) + term.setPaletteColor(colors.red, c[3].hex) end end - local c_mode = RadioButton{parent=clr_c_2,x=1,y=8,default=ini_cfg.ColorMode,options=themes.COLOR_MODE_NAMES,callback=recolor,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} + TextBox{parent=clr_c_2,x=1,y=8,height=1,text="Color Mode"} + local c_mode = RadioButton{parent=clr_c_2,x=1,y=9,default=ini_cfg.ColorMode,options=themes.COLOR_MODE_NAMES,callback=recolor,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} - local _ = IndLight{parent=clr_c_2,x=20,y=8,label="Good",colors=cpair(colors.black,colors.green),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=9,label="Warning",colors=cpair(colors.black,colors.yellow),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=10,label="Bad",colors=cpair(colors.black,colors.red),value=true} + TextBox{parent=clr_c_2,x=20,y=8,height=1,text="Preview"} + local _ = IndLight{parent=clr_c_2,x=20,y=9,label="Good",colors=cpair(colors.black,colors.green)} + _ = IndLight{parent=clr_c_2,x=20,y=10,label="Warning",colors=cpair(colors.black,colors.yellow)} + _ = IndLight{parent=clr_c_2,x=20,y=11,label="Bad",colors=cpair(colors.black,colors.red)} - TextBox{parent=clr_c_2,x=20,y=12,height=6,text="Exact color varies by theme.",fg_bg=g_lg_fg_bg} + TextBox{parent=clr_c_2,x=1,y=14,height=6,text="Note: exact color varies by theme.",fg_bg=g_lg_fg_bg} PushButton{parent=clr_c_2,x=44,y=14,min_width=6,text="Done",callback=function()clr_pane.set_value(1)end,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg} diff --git a/coordinator/iocontrol.lua b/coordinator/iocontrol.lua index 312d194..0cb50e4 100644 --- a/coordinator/iocontrol.lua +++ b/coordinator/iocontrol.lua @@ -403,7 +403,7 @@ function iocontrol.fp_pkt_rtt(session_id, rtt) elseif rtt > WARN_RTT then io.fp.ps.publish("pkt_" .. session_id .. "_rtt_color", colors.yellow_hc) else - io.fp.ps.publish("pkt_" .. session_id .. "_rtt_color", colors.green) + io.fp.ps.publish("pkt_" .. session_id .. "_rtt_color", colors.green_hc) end end diff --git a/coordinator/renderer.lua b/coordinator/renderer.lua index c05afee..d9e4b58 100644 --- a/coordinator/renderer.lua +++ b/coordinator/renderer.lua @@ -24,6 +24,7 @@ local renderer = {} -- render engine local engine = { + color_mode = 1, ---@type COLOR_MODE monitors = nil, ---@type monitors_struct|nil dmesg_window = nil, ---@type table|nil ui_ready = false, @@ -50,6 +51,12 @@ local function _init_display(monitor) for i = 1, #style.theme.colors do monitor.setPaletteColor(style.theme.colors[i].c, style.theme.colors[i].hex) end + + -- apply color mode + local c_mode_overrides = style.theme.color_modes[engine.color_mode] + for i = 1, #c_mode_overrides do + monitor.setPaletteColor(c_mode_overrides[i].c, c_mode_overrides[i].hex) + end end -- print out that the monitor is too small @@ -62,10 +69,13 @@ local function _print_too_small(monitor) monitor.write("monitor too small") end --- disable the flow view ----@param disable boolean -function renderer.legacy_disable_flow_view(disable) - engine.disable_flow_view = disable +-- apply renderer configurations +---@param config crd_config +function renderer.configure(config) + style.set_themes(config.MainTheme, config.FrontPanelTheme, config.ColorMode) + + engine.color_mode = config.ColorMode + engine.disable_flow_view = config.DisableFlowView end -- link to the monitor peripherals @@ -100,6 +110,12 @@ function renderer.init_displays() for i = 1, #style.fp_theme.colors do term.setPaletteColor(style.fp_theme.colors[i].c, style.fp_theme.colors[i].hex) end + + -- apply color mode + local c_mode_overrides = style.fp_theme.color_modes[engine.color_mode] + for i = 1, #c_mode_overrides do + term.setPaletteColor(c_mode_overrides[i].c, c_mode_overrides[i].hex) + end end -- initialize the dmesg output window diff --git a/coordinator/startup.lua b/coordinator/startup.lua index feeafd0..5b3c46b 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,9 +22,7 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local style = require("coordinator.ui.style") - -local COORDINATOR_VERSION = "v1.2.12" +local COORDINATOR_VERSION = "v1.3.0" local CHUNK_LOAD_DELAY_S = 30.0 @@ -122,8 +120,7 @@ local function main() iocontrol.init_fp(COORDINATOR_VERSION, comms.version) -- init renderer - style.set_themes(config.MainTheme, config.FrontPanelTheme) - renderer.legacy_disable_flow_view(config.DisableFlowView) + renderer.configure(config) renderer.set_displays(monitors) renderer.init_displays() renderer.init_dmesg() diff --git a/coordinator/ui/components/process_ctl.lua b/coordinator/ui/components/process_ctl.lua index e1c3252..fb0c939 100644 --- a/coordinator/ui/components/process_ctl.lua +++ b/coordinator/ui/components/process_ctl.lua @@ -30,11 +30,6 @@ local border = core.border local bw_fg_bg = style.bw_fg_bg -local ind_grn = style.ind_grn -local ind_yel = style.ind_yel -local ind_red = style.ind_red -local ind_wht = style.ind_wht - local period = core.flasher.PERIOD -- new process control view @@ -50,6 +45,11 @@ local function new_view(root, x, y) local dis_colors = style.dis_colors local arrow_fg_bg = cpair(style.theme.label, s_hi_box.bkg) + local ind_grn = style.ind_grn + local ind_yel = style.ind_yel + local ind_red = style.ind_red + local ind_wht = style.ind_wht + assert(root.get_height() >= (y + 24), "main display not of sufficient vertical resolution (add an additional row of monitors)") local black = cpair(colors.black, colors.black) @@ -68,7 +68,7 @@ local function new_view(root, x, y) facility.ack_alarms_ack = ack_a.on_response local all_ok = IndicatorLight{parent=main,y=5,label="Unit Systems Online",colors=ind_grn} - local rad_mon = TriIndicatorLight{parent=main,label="Radiation Monitor",c1=colors.gray,c2=colors.yellow,c3=colors.green} + local rad_mon = TriIndicatorLight{parent=main,label="Radiation Monitor",c1=style.ind_bkg,c2=ind_yel.fgd,c3=ind_grn.fgd} local ind_mat = IndicatorLight{parent=main,label="Induction Matrix",colors=ind_grn} local sps = IndicatorLight{parent=main,label="SPS Connected",colors=ind_grn} @@ -219,7 +219,7 @@ local function new_view(root, x, y) if i <= facility.num_units then tag_fg_bg = cpair(colors.black, colors.cyan) ind_fg_bg = cpair(style.theme.text, s_hi_box.bkg) - ind_off = style.theme.label + ind_off = style.ind_hi_box_bg end local _y = ((i - 1) * 5) + 1 @@ -228,8 +228,8 @@ local function new_view(root, x, y) TextBox{parent=unit_tag,x=2,y=2,text="Unit "..i.." Status",width=7,height=2} local lights = Div{parent=stat_div,x=9,y=_y,width=14,height=4,fg_bg=ind_fg_bg} - local ready = IndicatorLight{parent=lights,x=2,y=2,label="Ready",colors=cpair(colors.green,ind_off)} - local degraded = IndicatorLight{parent=lights,x=2,y=3,label="Degraded",colors=cpair(colors.red,ind_off),flash=true,period=period.BLINK_250_MS} + local ready = IndicatorLight{parent=lights,x=2,y=2,label="Ready",colors=cpair(ind_grn.fgd,ind_off)} + local degraded = IndicatorLight{parent=lights,x=2,y=3,label="Degraded",colors=cpair(ind_red.fgd,ind_off),flash=true,period=period.BLINK_250_MS} if i <= facility.num_units then local unit = units[i] ---@type ioctl_unit @@ -341,7 +341,7 @@ local function new_view(root, x, y) status.register(facility.ps, "current_waste_product", status.update) local waste_prod = RadioButton{parent=rect,x=2,y=3,options=style.waste.options,callback=process.set_process_waste,radio_colors=cpair(style.theme.accent_dark,style.theme.accent_light),select_color=colors.brown} - local pu_fallback = Checkbox{parent=rect,x=2,y=7,label="Pu Fallback",callback=process.set_pu_fallback,box_fg_bg=cpair(colors.green,style.theme.accent_light)} + local pu_fallback = Checkbox{parent=rect,x=2,y=7,label="Pu Fallback",callback=process.set_pu_fallback,box_fg_bg=cpair(colors.green,style.theme.checkbox_bg)} waste_prod.register(facility.ps, "process_waste_product", waste_prod.set_value) pu_fallback.register(facility.ps, "process_pu_fallback", pu_fallback.set_value) diff --git a/coordinator/ui/components/unit_detail.lua b/coordinator/ui/components/unit_detail.lua index d76c9d8..2264b00 100644 --- a/coordinator/ui/components/unit_detail.lua +++ b/coordinator/ui/components/unit_detail.lua @@ -37,11 +37,6 @@ local border = core.border local bw_fg_bg = style.bw_fg_bg local gry_wht = style.gray_white -local ind_grn = style.ind_grn -local ind_yel = style.ind_yel -local ind_red = style.ind_red -local ind_wht = style.ind_wht - local period = core.flasher.PERIOD -- create a unit view @@ -58,6 +53,12 @@ local function init(parent, id) local dis_colors = style.dis_colors local arrow_fg_bg = cpair(style.theme.label, s_hi_box.bkg) + local ind_bkg = style.ind_bkg + local ind_grn = style.ind_grn + local ind_yel = style.ind_yel + local ind_red = style.ind_red + local ind_wht = style.ind_wht + local db = iocontrol.get_db() local unit = db.units[id] ---@type ioctl_unit local f_ps = db.facility.ps @@ -158,9 +159,9 @@ local function init(parent, id) local annunciator = Div{parent=main,width=23,height=18,x=22,y=3} -- connectivity - local plc_online = IndicatorLight{parent=annunciator,label="PLC Online",colors=cpair(colors.green,colors.red)} + local plc_online = IndicatorLight{parent=annunciator,label="PLC Online",colors=cpair(ind_grn.fgd,ind_red.fgd)} local plc_hbeat = IndicatorLight{parent=annunciator,label="PLC Heartbeat",colors=ind_wht} - local rad_mon = TriIndicatorLight{parent=annunciator,label="Radiation Monitor",c1=colors.gray,c2=colors.yellow,c3=colors.green} + local rad_mon = TriIndicatorLight{parent=annunciator,label="Radiation Monitor",c1=ind_bkg,c2=ind_yel.fgd,c3=ind_grn.fgd} plc_online.register(u_ps, "PLCOnline", plc_online.update) plc_hbeat.register(u_ps, "PLCHeartbeat", plc_hbeat.update) @@ -217,7 +218,7 @@ local function init(parent, id) local rps_loc = IndicatorLight{parent=rps_annunc,label="Coolant Level Low Low",colors=ind_yel} local rps_flt = IndicatorLight{parent=rps_annunc,label="PPM Fault",colors=ind_yel,flash=true,period=period.BLINK_500_MS} local rps_tmo = IndicatorLight{parent=rps_annunc,label="Connection Timeout",colors=ind_yel,flash=true,period=period.BLINK_500_MS} - local rps_sfl = IndicatorLight{parent=rps_annunc,label="System Failure",colors=cpair(colors.orange,colors.gray),flash=true,period=period.BLINK_500_MS} + local rps_sfl = IndicatorLight{parent=rps_annunc,label="System Failure",colors=ind_red,flash=true,period=period.BLINK_500_MS} rps_trp.register(u_ps, "rps_tripped", rps_trp.update) rps_dmg.register(u_ps, "high_dmg", rps_dmg.update) @@ -238,7 +239,7 @@ local function init(parent, id) local rcs_tags = Div{parent=rcs,width=2,height=16,x=1,y=7} local c_flt = IndicatorLight{parent=rcs_annunc,label="RCS Hardware Fault",colors=ind_yel} - local c_emg = TriIndicatorLight{parent=rcs_annunc,label="Emergency Coolant",c1=colors.gray,c2=colors.white,c3=colors.green} + local c_emg = TriIndicatorLight{parent=rcs_annunc,label="Emergency Coolant",c1=ind_bkg,c2=ind_wht.fgd,c3=ind_grn.fgd} local c_cfm = IndicatorLight{parent=rcs_annunc,label="Coolant Feed Mismatch",colors=ind_yel} local c_brm = IndicatorLight{parent=rcs_annunc,label="Boil Rate Mismatch",colors=ind_yel} local c_sfm = IndicatorLight{parent=rcs_annunc,label="Steam Feed Mismatch",colors=ind_yel} @@ -294,7 +295,7 @@ local function init(parent, id) if available_space > 1 then _add_space() end TextBox{parent=rcs_tags,text="T1",width=2,height=1,fg_bg=hc_text} - local t1_sdo = TriIndicatorLight{parent=rcs_annunc,label="Steam Relief Valve Open",c1=colors.gray,c2=colors.yellow,c3=colors.red} + local t1_sdo = TriIndicatorLight{parent=rcs_annunc,label="Steam Relief Valve Open",c1=ind_bkg,c2=ind_yel.fgd,c3=ind_red.fgd} t1_sdo.register(t_ps[1], "SteamDumpOpen", t1_sdo.update) TextBox{parent=rcs_tags,text="T1",width=2,height=1,fg_bg=hc_text} @@ -315,7 +316,7 @@ local function init(parent, id) end TextBox{parent=rcs_tags,text="T2",width=2,height=1,fg_bg=hc_text} - local t2_sdo = TriIndicatorLight{parent=rcs_annunc,label="Steam Relief Valve Open",c1=colors.gray,c2=colors.yellow,c3=colors.red} + local t2_sdo = TriIndicatorLight{parent=rcs_annunc,label="Steam Relief Valve Open",c1=ind_bkg,c2=ind_yel.fgd,c3=ind_red.fgd} t2_sdo.register(t_ps[2], "SteamDumpOpen", t2_sdo.update) TextBox{parent=rcs_tags,text="T2",width=2,height=1,fg_bg=hc_text} @@ -335,7 +336,7 @@ local function init(parent, id) if available_space > 3 then _add_space() end TextBox{parent=rcs_tags,text="T3",width=2,height=1,fg_bg=hc_text} - local t3_sdo = TriIndicatorLight{parent=rcs_annunc,label="Steam Relief Valve Open",c1=colors.gray,c2=colors.yellow,c3=colors.red} + local t3_sdo = TriIndicatorLight{parent=rcs_annunc,label="Steam Relief Valve Open",c1=ind_bkg,c2=ind_yel.fgd,c3=ind_red.fgd} t3_sdo.register(t_ps[3], "SteamDumpOpen", t3_sdo.update) TextBox{parent=rcs_tags,text="T3",width=2,height=1,fg_bg=hc_text} @@ -405,20 +406,20 @@ local function init(parent, id) local alarm_panel = Div{parent=main,x=2,y=36,width=29,height=16,fg_bg=s_hi_bright} - local a_brc = AlarmLight{parent=alarm_panel,x=6,y=2,label="Containment Breach",c1=colors.gray,c2=colors.red,c3=colors.green,flash=true,period=period.BLINK_250_MS} - local a_rad = AlarmLight{parent=alarm_panel,x=6,label="Containment Radiation",c1=colors.gray,c2=colors.red,c3=colors.green,flash=true,period=period.BLINK_250_MS} - local a_dmg = AlarmLight{parent=alarm_panel,x=6,label="Critical Damage",c1=colors.gray,c2=colors.red,c3=colors.green,flash=true,period=period.BLINK_250_MS} + local a_brc = AlarmLight{parent=alarm_panel,x=6,y=2,label="Containment Breach",c1=ind_bkg,c2=ind_red.fgd,c3=ind_grn.fgd,flash=true,period=period.BLINK_250_MS} + local a_rad = AlarmLight{parent=alarm_panel,x=6,label="Containment Radiation",c1=ind_bkg,c2=ind_red.fgd,c3=ind_grn.fgd,flash=true,period=period.BLINK_250_MS} + local a_dmg = AlarmLight{parent=alarm_panel,x=6,label="Critical Damage",c1=ind_bkg,c2=ind_red.fgd,c3=ind_grn.fgd,flash=true,period=period.BLINK_250_MS} alarm_panel.line_break() - local a_rcl = AlarmLight{parent=alarm_panel,x=6,label="Reactor Lost",c1=colors.gray,c2=colors.red,c3=colors.green,flash=true,period=period.BLINK_250_MS} - local a_rcd = AlarmLight{parent=alarm_panel,x=6,label="Reactor Damage",c1=colors.gray,c2=colors.red,c3=colors.green,flash=true,period=period.BLINK_250_MS} - local a_rot = AlarmLight{parent=alarm_panel,x=6,label="Reactor Over Temp",c1=colors.gray,c2=colors.red,c3=colors.green,flash=true,period=period.BLINK_250_MS} - local a_rht = AlarmLight{parent=alarm_panel,x=6,label="Reactor High Temp",c1=colors.gray,c2=colors.yellow,c3=colors.green,flash=true,period=period.BLINK_500_MS} - local a_rwl = AlarmLight{parent=alarm_panel,x=6,label="Reactor Waste Leak",c1=colors.gray,c2=colors.red,c3=colors.green,flash=true,period=period.BLINK_250_MS} - local a_rwh = AlarmLight{parent=alarm_panel,x=6,label="Reactor Waste High",c1=colors.gray,c2=colors.yellow,c3=colors.green,flash=true,period=period.BLINK_500_MS} + local a_rcl = AlarmLight{parent=alarm_panel,x=6,label="Reactor Lost",c1=ind_bkg,c2=ind_red.fgd,c3=ind_grn.fgd,flash=true,period=period.BLINK_250_MS} + local a_rcd = AlarmLight{parent=alarm_panel,x=6,label="Reactor Damage",c1=ind_bkg,c2=ind_red.fgd,c3=ind_grn.fgd,flash=true,period=period.BLINK_250_MS} + local a_rot = AlarmLight{parent=alarm_panel,x=6,label="Reactor Over Temp",c1=ind_bkg,c2=ind_red.fgd,c3=ind_grn.fgd,flash=true,period=period.BLINK_250_MS} + local a_rht = AlarmLight{parent=alarm_panel,x=6,label="Reactor High Temp",c1=ind_bkg,c2=ind_yel.fgd,c3=ind_grn.fgd,flash=true,period=period.BLINK_500_MS} + local a_rwl = AlarmLight{parent=alarm_panel,x=6,label="Reactor Waste Leak",c1=ind_bkg,c2=ind_red.fgd,c3=ind_grn.fgd,flash=true,period=period.BLINK_250_MS} + local a_rwh = AlarmLight{parent=alarm_panel,x=6,label="Reactor Waste High",c1=ind_bkg,c2=ind_yel.fgd,c3=ind_grn.fgd,flash=true,period=period.BLINK_500_MS} alarm_panel.line_break() - local a_rps = AlarmLight{parent=alarm_panel,x=6,label="RPS Transient",c1=colors.gray,c2=colors.yellow,c3=colors.green,flash=true,period=period.BLINK_500_MS} - local a_clt = AlarmLight{parent=alarm_panel,x=6,label="RCS Transient",c1=colors.gray,c2=colors.yellow,c3=colors.green,flash=true,period=period.BLINK_500_MS} - local a_tbt = AlarmLight{parent=alarm_panel,x=6,label="Turbine Trip",c1=colors.gray,c2=colors.red,c3=colors.green,flash=true,period=period.BLINK_250_MS} + local a_rps = AlarmLight{parent=alarm_panel,x=6,label="RPS Transient",c1=ind_bkg,c2=ind_yel.fgd,c3=ind_grn.fgd,flash=true,period=period.BLINK_500_MS} + local a_clt = AlarmLight{parent=alarm_panel,x=6,label="RCS Transient",c1=ind_bkg,c2=ind_yel.fgd,c3=ind_grn.fgd,flash=true,period=period.BLINK_500_MS} + local a_tbt = AlarmLight{parent=alarm_panel,x=6,label="Turbine Trip",c1=ind_bkg,c2=ind_red.fgd,c3=ind_grn.fgd,flash=true,period=period.BLINK_250_MS} a_brc.register(u_ps, "Alarm_1", a_brc.update) a_rad.register(u_ps, "Alarm_2", a_rad.update) diff --git a/coordinator/ui/components/unit_flow.lua b/coordinator/ui/components/unit_flow.lua index 115450b..39c2c00 100644 --- a/coordinator/ui/components/unit_flow.lua +++ b/coordinator/ui/components/unit_flow.lua @@ -30,9 +30,6 @@ local pipe = core.pipe local wh_gray = style.wh_gray local lg_gray = style.lg_gray -local ind_grn = style.ind_grn -local ind_wht = style.ind_wht - -- make a new unit flow window ---@param parent graphics_element parent ---@param x integer top left x @@ -46,6 +43,9 @@ local function make(parent, x, y, wide, unit) local lu_c = style.lu_colors local lu_c_d = style.lu_colors_dark + local ind_grn = style.ind_grn + local ind_wht = style.ind_wht + local height = 16 local v_start = 1 + ((unit.unit_id - 1) * 5) @@ -112,7 +112,7 @@ local function make(parent, x, y, wide, unit) cc_rate.register(unit.unit_ps, "boiler_boil_sum", function (sum) cc_rate.update(sum * 10) end) hc_rate.register(unit.unit_ps, "heating_rate", hc_rate.update) - local boiler = Rectangle{parent=root,x=_wide(47,40),y=1,border=border(1, colors.gray, true),width=19,height=5,fg_bg=wh_gray} + local boiler = Rectangle{parent=root,x=_wide(47,40),y=1,border=border(1,colors.gray,true),width=19,height=5,fg_bg=wh_gray} TextBox{parent=boiler,y=1,text="THERMO-ELECTRIC",alignment=ALIGN.CENTER,height=1} TextBox{parent=boiler,y=3,text=util.trinary(unit.num_boilers>1,"BOILERS","BOILER"),alignment=ALIGN.CENTER,height=1} TextBox{parent=root,x=_wide(47,40),y=2,text="\x1b \x80 \x1a",width=1,height=3,fg_bg=lg_gray} @@ -131,7 +131,7 @@ local function make(parent, x, y, wide, unit) st_rate.register(unit.unit_ps, "heating_rate", st_rate.update) end - local turbine = Rectangle{parent=root,x=_wide(93,79),y=1,border=border(1, colors.gray, true),width=19,height=5,fg_bg=wh_gray} + local turbine = Rectangle{parent=root,x=_wide(93,79),y=1,border=border(1,colors.gray,true),width=19,height=5,fg_bg=wh_gray} TextBox{parent=turbine,y=1,text="STEAM TURBINE",alignment=ALIGN.CENTER,height=1} TextBox{parent=turbine,y=3,text=util.trinary(unit.num_turbines>1,"GENERATORS","GENERATOR"),alignment=ALIGN.CENTER,height=1} TextBox{parent=root,x=_wide(93,79),y=2,text="\x1b \x80 \x1a",width=1,height=3,fg_bg=lg_gray} @@ -139,7 +139,7 @@ local function make(parent, x, y, wide, unit) for i = 1, unit.num_turbines do local ry = 1 + (2 * (i - 1)) + prv_yo TextBox{parent=root,x=_wide(125,103),y=ry,text="\x10\x11\x7f",fg_bg=text_c,width=3,height=1} - local state = TriIndicatorLight{parent=root,x=_wide(129,107),y=ry,label=v_names[i+4],c1=colors.gray,c2=colors.yellow,c3=colors.red} + local state = TriIndicatorLight{parent=root,x=_wide(129,107),y=ry,label=v_names[i+4],c1=style.ind_bkg,c2=style.ind_yel.fgd,c3=style.ind_red.fgd} state.register(unit.turbine_ps_tbl[i], "SteamDumpOpen", state.update) end diff --git a/coordinator/ui/layout/front_panel.lua b/coordinator/ui/layout/front_panel.lua index d2eb8ff..455e42e 100644 --- a/coordinator/ui/layout/front_panel.lua +++ b/coordinator/ui/layout/front_panel.lua @@ -22,8 +22,11 @@ local TextBox = require("graphics.elements.textbox") local TabBar = require("graphics.elements.controls.tabbar") local LED = require("graphics.elements.indicators.led") +local LEDPair = require("graphics.elements.indicators.ledpair") local RGBLED = require("graphics.elements.indicators.ledrgb") +local LINK_STATE = types.PANEL_LINK_STATE + local ALIGN = core.ALIGN local cpair = core.cpair @@ -56,12 +59,43 @@ local function init(panel, num_units) heartbeat.register(ps, "heartbeat", heartbeat.update) local modem = LED{parent=system,label="MODEM",colors=led_grn} - local network = RGBLED{parent=system,label="NETWORK",colors={colors.green,colors.red,colors.orange,colors.yellow,colors.gray}} - network.update(types.PANEL_LINK_STATE.DISCONNECTED) + + if not style.colorblind then + local network = RGBLED{parent=system,label="NETWORK",colors={colors.green,colors.red,colors.orange,colors.yellow,colors.gray}} + network.update(types.PANEL_LINK_STATE.DISCONNECTED) + network.register(ps, "link_state", network.update) + else + local nt_lnk = LEDPair{parent=system,label="NT LINKED",off=colors.red_off,c1=colors.red,c2=colors.green} + local nt_ver = LEDPair{parent=system,label="NT VERSION",off=colors.red_off,c1=colors.red,c2=colors.green} + + nt_lnk.register(ps, "link_state", function (state) + local value = 2 + + if state == LINK_STATE.DISCONNECTED then + value = 1 + elseif state == LINK_STATE.LINKED then + value = 3 + end + + nt_lnk.update(value) + end) + + nt_ver.register(ps, "link_state", function (state) + local value = 3 + + if state == LINK_STATE.BAD_VERSION then + value = 2 + elseif state == LINK_STATE.DISCONNECTED then + value = 1 + end + + nt_ver.update(value) + end) + end + system.line_break() modem.register(ps, "has_modem", modem.update) - network.register(ps, "link_state", network.update) local speaker = LED{parent=system,label="SPEAKER",colors=led_grn} speaker.register(ps, "has_speaker", speaker.update) diff --git a/coordinator/ui/style.lua b/coordinator/ui/style.lua index afa6b7b..13379b7 100644 --- a/coordinator/ui/style.lua +++ b/coordinator/ui/style.lua @@ -2,6 +2,8 @@ -- Graphics Style Options -- +local util = require("scada-common.util") + local core = require("graphics.core") local themes = require("graphics.themes") @@ -27,6 +29,7 @@ local smooth_stone = { label_dark = colors.gray, disabled = colors.lightGray, bg = colors.lightGray, + checkbox_bg = colors.black, accent_light = colors.white, accent_dark = colors.gray, @@ -42,24 +45,10 @@ local smooth_stone = { highlight_box_bright = cpair(colors.black, colors.white), field_box = cpair(colors.black, colors.white), - colors = { - { c = colors.red, hex = 0xdf4949 }, - { c = colors.orange, hex = 0xffb659 }, - { c = colors.yellow, hex = 0xfffc79 }, - { c = colors.lime, hex = 0x80ff80 }, - { c = colors.green, hex = 0x4aee8a }, - { c = colors.cyan, hex = 0x34bac8 }, - { c = colors.lightBlue, hex = 0x6cc0f2 }, - { c = colors.blue, hex = 0x0096ff }, - { c = colors.purple, hex = 0xb156ee }, - { c = colors.pink, hex = 0xf26ba2 }, - { c = colors.magenta, hex = 0xf9488a }, - { c = colors.white, hex = 0xf0f0f0 }, - { c = colors.lightGray, hex = 0xcacaca }, - { c = colors.gray, hex = 0x575757 }, - { c = colors.black, hex = 0x191919 }, - { c = colors.brown, hex = 0x7f664c } - } + colors = themes.smooth_stone.colors, + + -- color re-mappings for assistive modes + color_modes = themes.smooth_stone.color_modes } ---@type theme @@ -70,6 +59,7 @@ local deepslate = { label_dark = colors.gray, disabled = colors.gray, bg = colors.black, + checkbox_bg = colors.gray, accent_light = colors.gray, accent_dark = colors.lightGray, @@ -85,61 +75,54 @@ local deepslate = { highlight_box_bright = cpair(colors.black, colors.lightGray), field_box = cpair(colors.white, colors.gray), - colors = { - { c = colors.red, hex = 0xeb6a6c }, - { c = colors.orange, hex = 0xf2b86c }, - { c = colors.yellow, hex = 0xd9cf81 }, - { c = colors.lime, hex = 0x80ff80 }, - { c = colors.green, hex = 0x70e19b }, - { c = colors.cyan, hex = 0x7ccdd0 }, - { c = colors.lightBlue, hex = 0x99ceef }, - { c = colors.blue, hex = 0x60bcff }, - { c = colors.purple, hex = 0xc38aea }, - { c = colors.pink, hex = 0xff7fb8 }, - { c = colors.magenta, hex = 0xf980dd }, - { c = colors.white, hex = 0xd9d9d9 }, - { c = colors.lightGray, hex = 0x949494 }, - { c = colors.gray, hex = 0x575757 }, - { c = colors.black, hex = 0x262626 }, - { c = colors.brown, hex = 0xb18f6a } - } + colors = themes.deepslate.colors, + + -- color re-mappings for assistive modes + color_modes = themes.deepslate.color_modes } style.theme = smooth_stone -style.root = cpair(style.theme.text, style.theme.bg) -style.label = cpair(style.theme.label, style.theme.bg) - --- high contrast text (also tags) -style.hc_text = cpair(style.theme.text, style.theme.text_inv) --- text on default background -style.text_colors = cpair(style.theme.text, style.theme.bg) --- label & unit colors -style.lu_colors = cpair(style.theme.label, style.theme.label) --- label & unit colors (darker if set) -style.lu_colors_dark = cpair(style.theme.label_dark, style.theme.label_dark) - -- set themes per configurations ----@param main integer main theme ID (1 = smooth_stone, 2 = deepslate) ----@param fp integer fp theme ID (1 = sandstone, 2 = basalt) -function style.set_themes(main, fp) - if main == 1 then +---@param main UI_THEME main UI theme +---@param fp FP_THEME front panel theme +---@param color_mode COLOR_MODE the color mode to use +function style.set_themes(main, fp, color_mode) + local colorblind = color_mode ~= themes.COLOR_MODE.STANDARD + + style.ind_bkg = colors.gray + style.ind_hi_box_bg = util.trinary(colorblind, colors.black, colors.gray) + + if main == themes.UI_THEME.SMOOTH_STONE then style.theme = smooth_stone - elseif main == 2 then + style.ind_bkg = util.trinary(colorblind, colors.black, colors.gray) + elseif main == themes.UI_THEME.DEEPSLATE then style.theme = deepslate + style.ind_hi_box_bg = util.trinary(colorblind, colors.black, colors.lightGray) end + style.colorblind = colorblind + style.root = cpair(style.theme.text, style.theme.bg) style.label = cpair(style.theme.label, style.theme.bg) + -- high contrast text (also tags) style.hc_text = cpair(style.theme.text, style.theme.text_inv) + -- text on default background style.text_colors = cpair(style.theme.text, style.theme.bg) + -- label & unit colors style.lu_colors = cpair(style.theme.label, style.theme.label) + -- label & unit colors (darker if set) style.lu_colors_dark = cpair(style.theme.label_dark, style.theme.label_dark) - if fp == 1 then + style.ind_grn = cpair(util.trinary(colorblind, colors.blue, colors.green), style.ind_bkg) + style.ind_yel = cpair(colors.yellow, style.ind_bkg) + style.ind_red = cpair(colors.red, style.ind_bkg) + style.ind_wht = cpair(colors.white, style.ind_bkg) + + if fp == themes.FP_THEME.SANDSTONE then style.fp_theme = themes.sandstone - elseif fp == 2 then + elseif fp == themes.FP_THEME.BASALT then style.fp_theme = themes.basalt end @@ -159,11 +142,6 @@ style.lg_gray = cpair(colors.lightGray, colors.gray) style.lg_white = cpair(colors.lightGray, colors.white) style.gray_white = cpair(colors.gray, colors.white) -style.ind_grn = cpair(colors.green, colors.gray) -style.ind_yel = cpair(colors.yellow, colors.gray) -style.ind_red = cpair(colors.red, colors.gray) -style.ind_wht = style.wh_gray - -- UI COMPONENTS -- style.reactor = { diff --git a/graphics/core.lua b/graphics/core.lua index e2587fc..b931a3e 100644 --- a/graphics/core.lua +++ b/graphics/core.lua @@ -7,7 +7,7 @@ local flasher = require("graphics.flasher") local core = {} -core.version = "2.2.1" +core.version = "2.2.2" core.flasher = flasher core.events = events diff --git a/graphics/themes.lua b/graphics/themes.lua index c454aab..b59b504 100644 --- a/graphics/themes.lua +++ b/graphics/themes.lua @@ -11,6 +11,7 @@ local themes = {} -- add color mappings for front panels colors.ivory = colors.pink +colors.green_hc = colors.cyan colors.yellow_hc = colors.purple colors.red_off = colors.brown colors.yellow_off = colors.magenta @@ -100,7 +101,7 @@ themes.sandstone = { { c = colors.yellow, hex = 0xf9fb53 }, { c = colors.green_off, hex = 0x16665a }, { c = colors.green, hex = 0x6be551 }, - { c = colors.cyan, hex = 0x34bac8 }, + { c = colors.green_hc, hex = 0x6be551 }, { c = colors.lightBlue, hex = 0x6cc0f2 }, { c = colors.blue, hex = 0x0096ff }, { c = colors.yellow_hc, hex = 0xe3bc2a }, @@ -111,6 +112,42 @@ themes.sandstone = { { c = colors.gray, hex = 0x575757 }, { c = colors.black, hex = 0x191919 }, { c = colors.red_off, hex = 0x672223 } + }, + + -- color re-mappings for assistive modes + color_modes = { + -- standard + {}, + -- deuteranopia + { + { c = colors.green, hex = 0x1081ff }, + { c = colors.green_hc, hex = 0x1081ff }, + { c = colors.green_off, hex = 0x141414 }, + { c = colors.yellow, hex = 0xf7c311 }, + { c = colors.yellow_off, hex = 0x141414 }, + { c = colors.red, hex = 0xfb5615 }, + { c = colors.red_off, hex = 0x141414 } + }, + -- protanopia + { + { c = colors.green, hex = 0x1081ff }, + { c = colors.green_hc, hex = 0x1081ff }, + { c = colors.green_off, hex = 0x141414 }, + { c = colors.yellow, hex = 0xf5e633 }, + { c = colors.yellow_off, hex = 0x141414 }, + { c = colors.red, hex = 0xff521a }, + { c = colors.red_off, hex = 0x141414 } + }, + -- tritanopia + { + { c = colors.green, hex = 0x40cbd7 }, + { c = colors.green_hc, hex = 0x40cbd7 }, + { c = colors.green_off, hex = 0x141414 }, + { c = colors.yellow, hex = 0xffbc00 }, + { c = colors.yellow_off, hex = 0x141414 }, + { c = colors.red, hex = 0xff0000 }, + { c = colors.red_off, hex = 0x141414 } + } } } @@ -134,7 +171,7 @@ themes.basalt = { { c = colors.yellow, hex = 0xefe37c }, { c = colors.green_off, hex = 0x436b41 }, { c = colors.green, hex = 0x7ae175 }, - { c = colors.cyan, hex = 0x5ec7d1 }, + { c = colors.green_hc, hex = 0x7ae175 }, { c = colors.lightBlue, hex = 0x7dc6f2 }, { c = colors.blue, hex = 0x56aae6 }, { c = colors.yellow_hc, hex = 0xe9cd68 }, @@ -145,6 +182,41 @@ themes.basalt = { { c = colors.gray, hex = 0x5c5f68 }, { c = colors.black, hex = 0x262626 }, { c = colors.red_off, hex = 0x653839 } + }, + + color_modes = { + -- standard + {}, + -- deuteranopia + { + { c = colors.green, hex = 0x65aeff }, + { c = colors.green_hc, hex = 0x99c9ff }, + { c = colors.green_off, hex = 0x333333 }, + { c = colors.yellow, hex = 0xf7c311 }, + { c = colors.yellow_off, hex = 0x333333 }, + { c = colors.red, hex = 0xf18486 }, + { c = colors.red_off, hex = 0x333333 } + }, + -- protanopia + { + { c = colors.green, hex = 0x65aeff }, + { c = colors.green_hc, hex = 0x99c9ff }, + { c = colors.green_off, hex = 0x333333 }, + { c = colors.yellow, hex = 0xf5e633 }, + { c = colors.yellow_off, hex = 0x333333 }, + { c = colors.red, hex = 0xff8058 }, + { c = colors.red_off, hex = 0x333333 } + }, + -- tritanopia + { + { c = colors.green, hex = 0x00ecff }, + { c = colors.green_hc, hex = 0x00ecff }, + { c = colors.green_off, hex = 0x333333 }, + { c = colors.yellow, hex = 0xffbc00 }, + { c = colors.yellow_off, hex = 0x333333 }, + { c = colors.red, hex = 0xdf4949 }, + { c = colors.red_off, hex = 0x333333 } + } } } @@ -169,4 +241,100 @@ end --#endregion +--#region Main UI Color Palettes + +---@class ui_palette +themes.smooth_stone = { + colors = { + { c = colors.red, hex = 0xdf4949 }, + { c = colors.orange, hex = 0xffb659 }, + { c = colors.yellow, hex = 0xfffc79 }, + { c = colors.lime, hex = 0x80ff80 }, + { c = colors.green, hex = 0x4aee8a }, + { c = colors.cyan, hex = 0x34bac8 }, + { c = colors.lightBlue, hex = 0x6cc0f2 }, + { c = colors.blue, hex = 0x0096ff }, + { c = colors.purple, hex = 0xb156ee }, + { c = colors.pink, hex = 0xf26ba2 }, + { c = colors.magenta, hex = 0xf9488a }, + { c = colors.white, hex = 0xf0f0f0 }, + { c = colors.lightGray, hex = 0xcacaca }, + { c = colors.gray, hex = 0x575757 }, + { c = colors.black, hex = 0x191919 }, + { c = colors.brown, hex = 0x7f664c } + }, + + -- color re-mappings for assistive modes + color_modes = { + -- standard + {}, + -- deuteranopia + { + { c = colors.blue, hex = 0x1081ff }, + { c = colors.yellow, hex = 0xf7c311 }, + { c = colors.red, hex = 0xfb5615 }, + }, + -- protanopia + { + { c = colors.blue, hex = 0x1081ff }, + { c = colors.yellow, hex = 0xf5e633 }, + { c = colors.red, hex = 0xff521a }, + }, + -- tritanopia + { + { c = colors.blue, hex = 0x40cbd7 }, + { c = colors.yellow, hex = 0xffbc00 }, + { c = colors.red, hex = 0xff0000 }, + } + } +} + +---@type ui_palette +themes.deepslate = { + colors = { + { c = colors.red, hex = 0xeb6a6c }, + { c = colors.orange, hex = 0xf2b86c }, + { c = colors.yellow, hex = 0xd9cf81 }, + { c = colors.lime, hex = 0x80ff80 }, + { c = colors.green, hex = 0x70e19b }, + { c = colors.cyan, hex = 0x7ccdd0 }, + { c = colors.lightBlue, hex = 0x99ceef }, + { c = colors.blue, hex = 0x60bcff }, + { c = colors.purple, hex = 0xc38aea }, + { c = colors.pink, hex = 0xff7fb8 }, + { c = colors.magenta, hex = 0xf980dd }, + { c = colors.white, hex = 0xd9d9d9 }, + { c = colors.lightGray, hex = 0x949494 }, + { c = colors.gray, hex = 0x575757 }, + { c = colors.black, hex = 0x262626 }, + { c = colors.brown, hex = 0xb18f6a } + }, + + -- color re-mappings for assistive modes + color_modes = { + -- standard + {}, + -- deuteranopia + { + { c = colors.blue, hex = 0x65aeff }, + { c = colors.yellow, hex = 0xf7c311 }, + { c = colors.red, hex = 0xfb5615 }, + }, + -- protanopia + { + { c = colors.blue, hex = 0x65aeff }, + { c = colors.yellow, hex = 0xf5e633 }, + { c = colors.red, hex = 0xff8058 }, + }, + -- tritanopia + { + { c = colors.blue, hex = 0x00ecff }, + { c = colors.yellow, hex = 0xffbc00 }, + { c = colors.red, hex = 0xdf4949 }, + } + } +} + +--#endregion + return themes diff --git a/pocket/configure.lua b/pocket/configure.lua index 908ea4c..80f91bc 100644 --- a/pocket/configure.lua +++ b/pocket/configure.lua @@ -7,6 +7,7 @@ local tcd = require("scada-common.tcd") local util = require("scada-common.util") local core = require("graphics.core") +local themes = require("graphics.themes") local DisplayBox = require("graphics.elements.displaybox") local Div = require("graphics.elements.div") @@ -41,21 +42,7 @@ local style = {} style.root = cpair(colors.black, colors.lightGray) style.header = cpair(colors.white, colors.gray) -style.colors = { - { c = colors.red, hex = 0xdf4949 }, - { c = colors.orange, hex = 0xffb659 }, - { c = colors.yellow, hex = 0xfffc79 }, - { c = colors.lime, hex = 0x80ff80 }, - { c = colors.green, hex = 0x4aee8a }, - { c = colors.cyan, hex = 0x34bac8 }, - { c = colors.lightBlue, hex = 0x6cc0f2 }, - { c = colors.blue, hex = 0x0096ff }, - { c = colors.purple, hex = 0xb156ee }, - { c = colors.pink, hex = 0xf26ba2 }, - { c = colors.magenta, hex = 0xf9488a }, - { c = colors.lightGray, hex = 0xcacaca }, - { c = colors.gray, hex = 0x575757 } -} +style.colors = themes.smooth_stone.colors local bw_fg_bg = cpair(colors.black, colors.white) local g_lg_fg_bg = cpair(colors.gray, colors.lightGray) diff --git a/reactor-plc/configure.lua b/reactor-plc/configure.lua index 5676a91..a2c223c 100644 --- a/reactor-plc/configure.lua +++ b/reactor-plc/configure.lua @@ -8,6 +8,7 @@ local tcd = require("scada-common.tcd") local util = require("scada-common.util") local core = require("graphics.core") +local themes = require("graphics.themes") local DisplayBox = require("graphics.elements.displaybox") local Div = require("graphics.elements.div") @@ -49,21 +50,7 @@ local style = {} style.root = cpair(colors.black, colors.lightGray) style.header = cpair(colors.white, colors.gray) -style.colors = { - { c = colors.red, hex = 0xdf4949 }, - { c = colors.orange, hex = 0xffb659 }, - { c = colors.yellow, hex = 0xfffc79 }, - { c = colors.lime, hex = 0x80ff80 }, - { c = colors.green, hex = 0x4aee8a }, - { c = colors.cyan, hex = 0x34bac8 }, - { c = colors.lightBlue, hex = 0x6cc0f2 }, - { c = colors.blue, hex = 0x0096ff }, - { c = colors.purple, hex = 0xb156ee }, - { c = colors.pink, hex = 0xf26ba2 }, - { c = colors.magenta, hex = 0xf9488a }, - { c = colors.lightGray, hex = 0xcacaca }, - { c = colors.gray, hex = 0x575757 } -} +style.colors = themes.smooth_stone.colors local bw_fg_bg = cpair(colors.black, colors.white) local g_lg_fg_bg = cpair(colors.gray, colors.lightGray) @@ -473,35 +460,31 @@ local function config_view(display) TextBox{parent=clr_c_1,x=1,y=4,height=2,text="Click 'Accessibility' below to access colorblind assistive options.",fg_bg=g_lg_fg_bg} TextBox{parent=clr_c_1,x=1,y=7,height=1,text="Front Panel Theme"} - local fp_theme = RadioButton{parent=clr_c_1,x=1,y=8,default=ini_cfg.FrontPanelTheme,options={"Sandstone","Basalt"},callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} + local fp_theme = RadioButton{parent=clr_c_1,x=1,y=8,default=ini_cfg.FrontPanelTheme,options=themes.FP_THEME_NAMES,callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} TextBox{parent=clr_c_2,x=1,y=1,height=6,text="By default, this project uses green/red heavily to distinguish ok and not, with some indicators also using multiple colors. By selecting a color blindness below, blues will be used instead of greens on indicators and multi-color indicators will be split up as space permits."} local function recolor(value) + local c = themes.smooth_stone.color_modes[value] + if value == 1 then for i = 1, #style.colors do term.setPaletteColor(style.colors[i].c, style.colors[i].hex) end - elseif value == 2 then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf5e633) - term.setPaletteColor(colors.red, 0xff521a) - elseif value == 3 then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf7c311) - term.setPaletteColor(colors.red, 0xfb5615) - elseif value == 4 then - term.setPaletteColor(colors.green, 0x00ecff) - term.setPaletteColor(colors.yellow, 0xffbc00) - term.setPaletteColor(colors.red, 0xff0000) + else + term.setPaletteColor(colors.green, c[1].hex) + term.setPaletteColor(colors.yellow, c[2].hex) + term.setPaletteColor(colors.red, c[3].hex) end end - local c_mode = RadioButton{parent=clr_c_2,x=1,y=8,default=ini_cfg.ColorMode,options={"None","Protanopia","Deuteranopia","Tritanopia"},callback=recolor,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} + TextBox{parent=clr_c_2,x=1,y=8,height=1,text="Color Mode"} + local c_mode = RadioButton{parent=clr_c_2,x=1,y=9,default=ini_cfg.ColorMode,options=themes.COLOR_MODE_NAMES,callback=recolor,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} - local _ = IndLight{parent=clr_c_2,x=20,y=8,label="Good",colors=cpair(colors.black,colors.green),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=9,label="Warning",colors=cpair(colors.black,colors.yellow),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=10,label="Bad",colors=cpair(colors.black,colors.red),value=true} + TextBox{parent=clr_c_2,x=20,y=8,height=1,text="Preview"} + local _ = IndLight{parent=clr_c_2,x=20,y=9,label="Good",colors=cpair(colors.black,colors.green)} + _ = IndLight{parent=clr_c_2,x=20,y=10,label="Warning",colors=cpair(colors.black,colors.yellow)} + _ = IndLight{parent=clr_c_2,x=20,y=11,label="Bad",colors=cpair(colors.black,colors.red)} - TextBox{parent=clr_c_2,x=20,y=12,height=6,text="Exact color varies by theme.",fg_bg=g_lg_fg_bg} + TextBox{parent=clr_c_2,x=1,y=14,height=6,text="Note: exact color varies by theme.",fg_bg=g_lg_fg_bg} PushButton{parent=clr_c_2,x=44,y=14,min_width=6,text="Done",callback=function()clr_pane.set_value(1)end,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg} @@ -750,9 +733,9 @@ local function config_view(display) elseif f[1] == "LogMode" then val = util.trinary(raw == log.MODE.APPEND, "append", "replace") elseif f[1] == "EmerCoolColor" and raw ~= nil then val = rsio.color_name(raw) elseif f[1] == "FrontPanelTheme" then - if raw == 1 then val = "Sandstone" elseif raw == 2 then val = "Basalt" end + val = util.strval(themes.fp_theme_name(raw)) elseif f[1] == "ColorMode" then - if raw == 1 then val = "Standard" elseif raw == 2 then val = "Protanopia" elseif raw == 3 then val = "Deuteranopia" elseif raw == 4 then val = "Tritanopia" end + val = util.strval(themes.color_mode_name(raw)) end if val == "nil" then val = "" end diff --git a/reactor-plc/panel/front_panel.lua b/reactor-plc/panel/front_panel.lua index 7c087a8..b54cd04 100644 --- a/reactor-plc/panel/front_panel.lua +++ b/reactor-plc/panel/front_panel.lua @@ -23,6 +23,8 @@ local LED = require("graphics.elements.indicators.led") local LEDPair = require("graphics.elements.indicators.ledpair") local RGBLED = require("graphics.elements.indicators.ledrgb") +local LINK_STATE = types.PANEL_LINK_STATE + local ALIGN = core.ALIGN local cpair = core.cpair @@ -56,13 +58,47 @@ local function init(panel) local reactor = LEDPair{parent=system,label="REACTOR",off=colors.red,c1=colors.yellow,c2=colors.green} local modem = LED{parent=system,label="MODEM",colors=ind_grn} - local network = RGBLED{parent=system,label="NETWORK",colors={colors.green,colors.red,colors.orange,colors.yellow,colors.gray}} - network.update(types.PANEL_LINK_STATE.DISCONNECTED) + + if not style.colorblind then + local network = RGBLED{parent=system,label="NETWORK",colors={colors.green,colors.red,colors.orange,colors.yellow,colors.gray}} + network.update(types.PANEL_LINK_STATE.DISCONNECTED) + network.register(databus.ps, "link_state", network.update) + else + local nt_lnk = LEDPair{parent=system,label="NT LINKED",off=colors.red_off,c1=colors.red,c2=colors.green} + local nt_ver = LEDPair{parent=system,label="NT VERSION",off=colors.red_off,c1=colors.red,c2=colors.green} + local nt_col = LED{parent=system,label="NT COLLISION",colors=ind_red} + + nt_lnk.register(databus.ps, "link_state", function (state) + local value = 2 + + if state == LINK_STATE.DISCONNECTED then + value = 1 + elseif state == LINK_STATE.LINKED then + value = 3 + end + + nt_lnk.update(value) + end) + + nt_ver.register(databus.ps, "link_state", function (state) + local value = 3 + + if state == LINK_STATE.BAD_VERSION then + value = 2 + elseif state == LINK_STATE.DISCONNECTED then + value = 1 + end + + nt_ver.update(value) + end) + + nt_col.register(databus.ps, "link_state", function (state) nt_col.update(state == LINK_STATE.COLLISION) end) + end + system.line_break() reactor.register(databus.ps, "reactor_dev_state", reactor.update) modem.register(databus.ps, "has_modem", modem.update) - network.register(databus.ps, "link_state", network.update) local rt_main = LED{parent=system,label="RT MAIN",colors=ind_grn} local rt_rps = LED{parent=system,label="RT RPS",colors=ind_grn} diff --git a/reactor-plc/panel/style.lua b/reactor-plc/panel/style.lua index 5aca524..08c1192 100644 --- a/reactor-plc/panel/style.lua +++ b/reactor-plc/panel/style.lua @@ -12,20 +12,24 @@ local cpair = core.cpair style.theme = themes.sandstone style.fp = themes.get_fp_style(style.theme) +style.colorblind = false style.ind_grn = cpair(colors.green, colors.green_off) style.ind_red = cpair(colors.red, colors.red_off) -- set theme per configuration ----@param fp integer fp theme ID (1 = sandstone, 2 = basalt) -function style.set_theme(fp) - if fp == 1 then +---@param fp FP_THEME front panel theme +---@param color_mode COLOR_MODE the color mode to use +function style.set_theme(fp, color_mode) + if fp == themes.FP_THEME.SANDSTONE then style.theme = themes.sandstone - elseif fp == 2 then + elseif fp == themes.FP_THEME.BASALT then style.theme = themes.basalt end style.fp = themes.get_fp_style(style.theme) + + style.colorblind = color_mode ~= themes.COLOR_MODE.STANDARD end return style diff --git a/reactor-plc/renderer.lua b/reactor-plc/renderer.lua index 31af361..aa62e63 100644 --- a/reactor-plc/renderer.lua +++ b/reactor-plc/renderer.lua @@ -18,14 +18,15 @@ local ui = { } -- try to start the UI ----@param theme integer front panel theme ID (1 = sandstone, 2 = basalt) +---@param theme FP_THEME front panel theme +---@param color_mode COLOR_MODE color mode ---@return boolean success, any error_msg -function renderer.try_start_ui(theme) +function renderer.try_start_ui(theme, color_mode) local status, msg = true, nil if ui.display == nil then -- set theme - style.set_theme(theme) + style.set_theme(theme, color_mode) -- reset terminal term.setTextColor(colors.white) @@ -38,6 +39,12 @@ function renderer.try_start_ui(theme) term.setPaletteColor(style.theme.colors[i].c, style.theme.colors[i].hex) end + -- apply color mode + local c_mode_overrides = style.theme.color_modes[color_mode] + for i = 1, #c_mode_overrides do + term.setPaletteColor(c_mode_overrides[i].c, c_mode_overrides[i].hex) + end + -- init front panel view status, msg = pcall(function () ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root} diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index 66f6d77..ea51bf6 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.6.15" +local R_PLC_VERSION = "v1.7.0" local println = util.println local println_ts = util.println_ts @@ -183,7 +183,7 @@ local function main() -- front panel time! if not renderer.ui_ready() then local message - plc_state.fp_ok, message = renderer.try_start_ui(config.FrontPanelTheme) + plc_state.fp_ok, message = renderer.try_start_ui(config.FrontPanelTheme, config.ColorMode) if not plc_state.fp_ok then println_ts(util.c("UI error: ", message)) diff --git a/rtu/configure.lua b/rtu/configure.lua index 1ec2aec..2fb8703 100644 --- a/rtu/configure.lua +++ b/rtu/configure.lua @@ -9,6 +9,7 @@ local tcd = require("scada-common.tcd") local util = require("scada-common.util") local core = require("graphics.core") +local themes = require("graphics.themes") local DisplayBox = require("graphics.elements.displaybox") local Div = require("graphics.elements.div") @@ -101,21 +102,7 @@ local style = {} style.root = cpair(colors.black, colors.lightGray) style.header = cpair(colors.white, colors.gray) -style.colors = { - { c = colors.red, hex = 0xdf4949 }, - { c = colors.orange, hex = 0xffb659 }, - { c = colors.yellow, hex = 0xfffc79 }, - { c = colors.lime, hex = 0x80ff80 }, - { c = colors.green, hex = 0x4aee8a }, - { c = colors.cyan, hex = 0x34bac8 }, - { c = colors.lightBlue, hex = 0x6cc0f2 }, - { c = colors.blue, hex = 0x0096ff }, - { c = colors.purple, hex = 0xb156ee }, - { c = colors.pink, hex = 0xf26ba2 }, - { c = colors.magenta, hex = 0xf9488a }, - { c = colors.lightGray, hex = 0xcacaca }, - { c = colors.gray, hex = 0x575757 } -} +style.colors = themes.smooth_stone.colors local bw_fg_bg = cpair(colors.black, colors.white) local g_lg_fg_bg = cpair(colors.gray, colors.lightGray) @@ -528,35 +515,31 @@ local function config_view(display) TextBox{parent=clr_c_1,x=1,y=4,height=2,text="Click 'Accessibility' below to access colorblind assistive options.",fg_bg=g_lg_fg_bg} TextBox{parent=clr_c_1,x=1,y=7,height=1,text="Front Panel Theme"} - local fp_theme = RadioButton{parent=clr_c_1,x=1,y=8,default=ini_cfg.FrontPanelTheme,options={"Sandstone","Basalt"},callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} + local fp_theme = RadioButton{parent=clr_c_1,x=1,y=8,default=ini_cfg.FrontPanelTheme,options=themes.FP_THEME_NAMES,callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} TextBox{parent=clr_c_2,x=1,y=1,height=6,text="By default, this project uses green/red heavily to distinguish ok and not, with some indicators also using multiple colors. By selecting a color blindness below, blues will be used instead of greens on indicators and multi-color indicators will be split up as space permits."} local function recolor(value) + local c = themes.smooth_stone.color_modes[value] + if value == 1 then for i = 1, #style.colors do term.setPaletteColor(style.colors[i].c, style.colors[i].hex) end - elseif value == 2 then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf5e633) - term.setPaletteColor(colors.red, 0xff521a) - elseif value == 3 then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf7c311) - term.setPaletteColor(colors.red, 0xfb5615) - elseif value == 4 then - term.setPaletteColor(colors.green, 0x00ecff) - term.setPaletteColor(colors.yellow, 0xffbc00) - term.setPaletteColor(colors.red, 0xff0000) + else + term.setPaletteColor(colors.green, c[1].hex) + term.setPaletteColor(colors.yellow, c[2].hex) + term.setPaletteColor(colors.red, c[3].hex) end end - local c_mode = RadioButton{parent=clr_c_2,x=1,y=8,default=ini_cfg.ColorMode,options={"None","Protanopia","Deuteranopia","Tritanopia"},callback=recolor,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} + TextBox{parent=clr_c_2,x=1,y=8,height=1,text="Color Mode"} + local c_mode = RadioButton{parent=clr_c_2,x=1,y=9,default=ini_cfg.ColorMode,options=themes.COLOR_MODE_NAMES,callback=recolor,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} - local _ = IndLight{parent=clr_c_2,x=20,y=8,label="Good",colors=cpair(colors.black,colors.green),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=9,label="Warning",colors=cpair(colors.black,colors.yellow),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=10,label="Bad",colors=cpair(colors.black,colors.red),value=true} + TextBox{parent=clr_c_2,x=20,y=8,height=1,text="Preview"} + local _ = IndLight{parent=clr_c_2,x=20,y=9,label="Good",colors=cpair(colors.black,colors.green)} + _ = IndLight{parent=clr_c_2,x=20,y=10,label="Warning",colors=cpair(colors.black,colors.yellow)} + _ = IndLight{parent=clr_c_2,x=20,y=11,label="Bad",colors=cpair(colors.black,colors.red)} - TextBox{parent=clr_c_2,x=20,y=12,height=6,text="Exact color varies by theme.",fg_bg=g_lg_fg_bg} + TextBox{parent=clr_c_2,x=1,y=14,height=6,text="Note: exact color varies by theme.",fg_bg=g_lg_fg_bg} PushButton{parent=clr_c_2,x=44,y=14,min_width=6,text="Done",callback=function()clr_pane.set_value(1)end,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg} @@ -1439,9 +1422,9 @@ local function config_view(display) if f[1] == "AuthKey" then val = string.rep("*", string.len(val)) elseif f[1] == "LogMode" then val = util.trinary(raw == log.MODE.APPEND, "append", "replace") elseif f[1] == "FrontPanelTheme" then - if raw == 1 then val = "Sandstone" elseif raw == 2 then val = "Basalt" end + val = util.strval(themes.fp_theme_name(raw)) elseif f[1] == "ColorMode" then - if raw == 1 then val = "Standard" elseif raw == 2 then val = "Protanopia" elseif raw == 3 then val = "Deuteranopia" elseif raw == 4 then val = "Tritanopia" end + val = util.strval(themes.color_mode_name(raw)) end if val == "nil" then val = "" end diff --git a/rtu/panel/front_panel.lua b/rtu/panel/front_panel.lua index 9989e9a..d479302 100644 --- a/rtu/panel/front_panel.lua +++ b/rtu/panel/front_panel.lua @@ -16,8 +16,11 @@ local TextBox = require("graphics.elements.textbox") local DataIndicator = require("graphics.elements.indicators.data") local LED = require("graphics.elements.indicators.led") +local LEDPair = require("graphics.elements.indicators.ledpair") local RGBLED = require("graphics.elements.indicators.ledrgb") +local LINK_STATE = types.PANEL_LINK_STATE + local ALIGN = core.ALIGN local cpair = core.cpair @@ -48,12 +51,43 @@ local function init(panel, units) heartbeat.register(databus.ps, "heartbeat", heartbeat.update) local modem = LED{parent=system,label="MODEM",colors=ind_grn} - local network = RGBLED{parent=system,label="NETWORK",colors={colors.green,colors.red,colors.orange,colors.yellow,colors.gray}} - network.update(types.PANEL_LINK_STATE.DISCONNECTED) + + if not style.colorblind then + local network = RGBLED{parent=system,label="NETWORK",colors={colors.green,colors.red,colors.orange,colors.yellow,colors.gray}} + network.update(types.PANEL_LINK_STATE.DISCONNECTED) + network.register(databus.ps, "link_state", network.update) + else + local nt_lnk = LEDPair{parent=system,label="NT LINKED",off=colors.red_off,c1=colors.red,c2=colors.green} + local nt_ver = LEDPair{parent=system,label="NT VERSION",off=colors.red_off,c1=colors.red,c2=colors.green} + + nt_lnk.register(databus.ps, "link_state", function (state) + local value = 2 + + if state == LINK_STATE.DISCONNECTED then + value = 1 + elseif state == LINK_STATE.LINKED then + value = 3 + end + + nt_lnk.update(value) + end) + + nt_ver.register(databus.ps, "link_state", function (state) + local value = 3 + + if state == LINK_STATE.BAD_VERSION then + value = 2 + elseif state == LINK_STATE.DISCONNECTED then + value = 1 + end + + nt_ver.update(value) + end) + end + system.line_break() modem.register(databus.ps, "has_modem", modem.update) - network.register(databus.ps, "link_state", network.update) local rt_main = LED{parent=system,label="RT MAIN",colors=ind_grn} local rt_comm = LED{parent=system,label="RT COMMS",colors=ind_grn} diff --git a/rtu/panel/style.lua b/rtu/panel/style.lua index 36fd542..a72df2a 100644 --- a/rtu/panel/style.lua +++ b/rtu/panel/style.lua @@ -12,19 +12,23 @@ local cpair = core.cpair style.theme = themes.sandstone style.fp = themes.get_fp_style(style.theme) +style.colorblind = false style.ind_grn = cpair(colors.green, colors.green_off) -- set theme per configuration ----@param fp integer fp theme ID (1 = sandstone, 2 = basalt) -function style.set_theme(fp) - if fp == 1 then +---@param fp FP_THEME front panel theme +---@param color_mode COLOR_MODE the color mode to use +function style.set_theme(fp, color_mode) + if fp == themes.FP_THEME.SANDSTONE then style.theme = themes.sandstone - elseif fp == 2 then + elseif fp == themes.FP_THEME.BASALT then style.theme = themes.basalt end style.fp = themes.get_fp_style(style.theme) + + style.colorblind = color_mode ~= themes.COLOR_MODE.STANDARD end return style diff --git a/rtu/renderer.lua b/rtu/renderer.lua index 2a1a235..bdbc25b 100644 --- a/rtu/renderer.lua +++ b/rtu/renderer.lua @@ -19,14 +19,15 @@ local ui = { -- try to start the UI ---@param units table RTU units ----@param theme integer front panel theme ID (1 = sandstone, 2 = basalt) +---@param theme FP_THEME front panel theme +---@param color_mode COLOR_MODE color mode ---@return boolean success, any error_msg -function renderer.try_start_ui(units, theme) +function renderer.try_start_ui(units, theme, color_mode) local status, msg = true, nil if ui.display == nil then -- set theme - style.set_theme(theme) + style.set_theme(theme, color_mode) -- reset terminal term.setTextColor(colors.white) @@ -39,6 +40,12 @@ function renderer.try_start_ui(units, theme) term.setPaletteColor(style.theme.colors[i].c, style.theme.colors[i].hex) end + -- apply color mode + local c_mode_overrides = style.theme.color_modes[color_mode] + for i = 1, #c_mode_overrides do + term.setPaletteColor(c_mode_overrides[i].c, c_mode_overrides[i].hex) + end + -- init front panel view status, msg = pcall(function () ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root} diff --git a/rtu/startup.lua b/rtu/startup.lua index 4429c5d..4b92756 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu") local sps_rtu = require("rtu.dev.sps_rtu") local turbinev_rtu = require("rtu.dev.turbinev_rtu") -local RTU_VERSION = "v1.7.16" +local RTU_VERSION = "v1.8.0" local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE @@ -506,7 +506,7 @@ local function main() if sys_config() then -- start UI local message - rtu_state.fp_ok, message = renderer.try_start_ui(units, config.FrontPanelTheme) + rtu_state.fp_ok, message = renderer.try_start_ui(units, config.FrontPanelTheme, config.ColorMode) if not rtu_state.fp_ok then println_ts(util.c("UI error: ", message)) diff --git a/supervisor/configure.lua b/supervisor/configure.lua index 2f7bcd6..6163bbb 100644 --- a/supervisor/configure.lua +++ b/supervisor/configure.lua @@ -7,6 +7,7 @@ local tcd = require("scada-common.tcd") local util = require("scada-common.util") local core = require("graphics.core") +local themes = require("graphics.themes") local DisplayBox = require("graphics.elements.displaybox") local Div = require("graphics.elements.div") @@ -46,21 +47,7 @@ local style = {} style.root = cpair(colors.black, colors.lightGray) style.header = cpair(colors.white, colors.gray) -style.colors = { - { c = colors.red, hex = 0xdf4949 }, - { c = colors.orange, hex = 0xffb659 }, - { c = colors.yellow, hex = 0xfffc79 }, - { c = colors.lime, hex = 0x80ff80 }, - { c = colors.green, hex = 0x4aee8a }, - { c = colors.cyan, hex = 0x34bac8 }, - { c = colors.lightBlue, hex = 0x6cc0f2 }, - { c = colors.blue, hex = 0x0096ff }, - { c = colors.purple, hex = 0xb156ee }, - { c = colors.pink, hex = 0xf26ba2 }, - { c = colors.magenta, hex = 0xf9488a }, - { c = colors.lightGray, hex = 0xcacaca }, - { c = colors.gray, hex = 0x575757 } -} +style.colors = themes.smooth_stone.colors local bw_fg_bg = cpair(colors.black, colors.white) local g_lg_fg_bg = cpair(colors.gray, colors.lightGray) @@ -772,35 +759,31 @@ local function config_view(display) TextBox{parent=clr_c_1,x=1,y=4,height=2,text="Click 'Accessibility' below to access colorblind assistive options.",fg_bg=g_lg_fg_bg} TextBox{parent=clr_c_1,x=1,y=7,height=1,text="Front Panel Theme"} - local fp_theme = RadioButton{parent=clr_c_1,x=1,y=8,default=ini_cfg.FrontPanelTheme,options={"Sandstone","Basalt"},callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} + local fp_theme = RadioButton{parent=clr_c_1,x=1,y=8,default=ini_cfg.FrontPanelTheme,options=themes.FP_THEME_NAMES,callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} TextBox{parent=clr_c_2,x=1,y=1,height=6,text="By default, this project uses green/red heavily to distinguish ok and not, with some indicators also using multiple colors. By selecting a color blindness below, blues will be used instead of greens on indicators and multi-color indicators will be split up as space permits."} local function recolor(value) + local c = themes.smooth_stone.color_modes[value] + if value == 1 then for i = 1, #style.colors do term.setPaletteColor(style.colors[i].c, style.colors[i].hex) end - elseif value == 2 then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf5e633) - term.setPaletteColor(colors.red, 0xff521a) - elseif value == 3 then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf7c311) - term.setPaletteColor(colors.red, 0xfb5615) - elseif value == 4 then - term.setPaletteColor(colors.green, 0x00ecff) - term.setPaletteColor(colors.yellow, 0xffbc00) - term.setPaletteColor(colors.red, 0xff0000) + else + term.setPaletteColor(colors.green, c[1].hex) + term.setPaletteColor(colors.yellow, c[2].hex) + term.setPaletteColor(colors.red, c[3].hex) end end - local c_mode = RadioButton{parent=clr_c_2,x=1,y=8,default=ini_cfg.ColorMode,options={"None","Protanopia","Deuteranopia","Tritanopia"},callback=recolor,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} + TextBox{parent=clr_c_2,x=1,y=8,height=1,text="Color Mode"} + local c_mode = RadioButton{parent=clr_c_2,x=1,y=9,default=ini_cfg.ColorMode,options=themes.COLOR_MODE_NAMES,callback=recolor,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.magenta} - local _ = IndLight{parent=clr_c_2,x=20,y=8,label="Good",colors=cpair(colors.black,colors.green),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=9,label="Warning",colors=cpair(colors.black,colors.yellow),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=10,label="Bad",colors=cpair(colors.black,colors.red),value=true} + TextBox{parent=clr_c_2,x=20,y=8,height=1,text="Preview"} + local _ = IndLight{parent=clr_c_2,x=20,y=9,label="Good",colors=cpair(colors.black,colors.green)} + _ = IndLight{parent=clr_c_2,x=20,y=10,label="Warning",colors=cpair(colors.black,colors.yellow)} + _ = IndLight{parent=clr_c_2,x=20,y=11,label="Bad",colors=cpair(colors.black,colors.red)} - TextBox{parent=clr_c_2,x=20,y=12,height=6,text="Exact color varies by theme.",fg_bg=g_lg_fg_bg} + TextBox{parent=clr_c_2,x=1,y=14,height=6,text="Note: exact color varies by theme.",fg_bg=g_lg_fg_bg} PushButton{parent=clr_c_2,x=44,y=14,min_width=6,text="Done",callback=function()clr_pane.set_value(1)end,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg} @@ -1107,9 +1090,9 @@ local function config_view(display) if f[1] == "AuthKey" then val = string.rep("*", string.len(val)) elseif f[1] == "LogMode" then val = util.trinary(raw == log.MODE.APPEND, "append", "replace") elseif f[1] == "FrontPanelTheme" then - if raw == 1 then val = "Sandstone" elseif raw == 2 then val = "Basalt" end + val = util.strval(themes.fp_theme_name(raw)) elseif f[1] == "ColorMode" then - if raw == 1 then val = "Standard" elseif raw == 2 then val = "Protanopia" elseif raw == 3 then val = "Deuteranopia" elseif raw == 4 then val = "Tritanopia" end + val = util.strval(themes.color_mode_name(raw)) elseif f[1] == "CoolingConfig" and type(cfg.CoolingConfig) == "table" then val = "" diff --git a/supervisor/databus.lua b/supervisor/databus.lua index 00185c7..f5daefb 100644 --- a/supervisor/databus.lua +++ b/supervisor/databus.lua @@ -64,7 +64,7 @@ function databus.tx_plc_rtt(reactor_id, rtt) elseif rtt > WARN_RTT then databus.ps.publish("plc_" .. reactor_id .. "_rtt_color", colors.yellow_hc) else - databus.ps.publish("plc_" .. reactor_id .. "_rtt_color", colors.green) + databus.ps.publish("plc_" .. reactor_id .. "_rtt_color", colors.green_hc) end end @@ -95,7 +95,7 @@ function databus.tx_rtu_rtt(session_id, rtt) elseif rtt > WARN_RTT then databus.ps.publish("rtu_" .. session_id .. "_rtt_color", colors.yellow_hc) else - databus.ps.publish("rtu_" .. session_id .. "_rtt_color", colors.green) + databus.ps.publish("rtu_" .. session_id .. "_rtt_color", colors.green_hc) end end @@ -134,7 +134,7 @@ function databus.tx_crd_rtt(rtt) elseif rtt > WARN_RTT then databus.ps.publish("crd_rtt_color", colors.yellow_hc) else - databus.ps.publish("crd_rtt_color", colors.green) + databus.ps.publish("crd_rtt_color", colors.green_hc) end end @@ -165,7 +165,7 @@ function databus.tx_pdg_rtt(session_id, rtt) elseif rtt > WARN_RTT then databus.ps.publish("pdg_" .. session_id .. "_rtt_color", colors.yellow_hc) else - databus.ps.publish("pdg_" .. session_id .. "_rtt_color", colors.green) + databus.ps.publish("pdg_" .. session_id .. "_rtt_color", colors.green_hc) end end diff --git a/supervisor/panel/front_panel.lua b/supervisor/panel/front_panel.lua index add7fcf..9bf8e7b 100644 --- a/supervisor/panel/front_panel.lua +++ b/supervisor/panel/front_panel.lua @@ -96,7 +96,7 @@ local function init(panel) TextBox{parent=plc_entry,x=1,y=2,text="UNIT "..i,alignment=ALIGN.CENTER,width=8,height=1,fg_bg=s_hi_box} TextBox{parent=plc_entry,x=1,y=3,text="",width=8,height=1,fg_bg=s_hi_box} - local conn = LED{parent=plc_entry,x=10,y=2,label="LINK",colors=ind_grn} + local conn = LED{parent=plc_entry,x=10,y=2,label="LINK",colors=cpair(colors.green_hc,colors.green_off)} conn.register(databus.ps, ps_prefix .. "conn", conn.update) local plc_addr = TextBox{parent=plc_entry,x=17,y=2,text=" --- ",width=5,height=1,fg_bg=label_d_fg} @@ -126,7 +126,7 @@ local function init(panel) local crd_page = Div{parent=page_div,x=1,y=1,hidden=true} local crd_box = Div{parent=crd_page,x=2,y=2,width=49,height=4,fg_bg=s_hi_bright} - local crd_conn = LED{parent=crd_box,x=2,y=2,label="CONNECTION",colors=ind_grn} + local crd_conn = LED{parent=crd_box,x=2,y=2,label="CONNECTION",colors=cpair(colors.green_hc,colors.green_off)} crd_conn.register(databus.ps, "crd_conn", crd_conn.update) TextBox{parent=crd_box,x=4,y=3,text="COMPUTER",width=8,height=1,fg_bg=label_d_fg} diff --git a/supervisor/panel/style.lua b/supervisor/panel/style.lua index efcc9b7..a0a8bb0 100644 --- a/supervisor/panel/style.lua +++ b/supervisor/panel/style.lua @@ -12,19 +12,23 @@ local cpair = core.cpair style.theme = themes.sandstone style.fp = themes.get_fp_style(style.theme) +style.colorblind = false style.ind_grn = cpair(colors.green, colors.green_off) -- set theme per configuration ----@param fp integer fp theme ID (1 = sandstone, 2 = basalt) -function style.set_theme(fp) - if fp == 1 then +---@param fp FP_THEME front panel theme +---@param color_mode COLOR_MODE the color mode to use +function style.set_theme(fp, color_mode) + if fp == themes.FP_THEME.SANDSTONE then style.theme = themes.sandstone - elseif fp == 2 then + elseif fp == themes.FP_THEME.BASALT then style.theme = themes.basalt end style.fp = themes.get_fp_style(style.theme) + + style.colorblind = color_mode ~= themes.COLOR_MODE.STANDARD end return style diff --git a/supervisor/renderer.lua b/supervisor/renderer.lua index 8f9389f..fde7fc3 100644 --- a/supervisor/renderer.lua +++ b/supervisor/renderer.lua @@ -19,14 +19,15 @@ local ui = { } -- try to start the UI ----@param theme integer front panel theme ID (1 = sandstone, 2 = basalt) +---@param theme FP_THEME front panel theme +---@param color_mode COLOR_MODE color mode ---@return boolean success, any error_msg -function renderer.try_start_ui(theme) +function renderer.try_start_ui(theme, color_mode) local status, msg = true, nil if ui.display == nil then -- set theme - style.set_theme(theme) + style.set_theme(theme, color_mode) -- reset terminal term.setTextColor(colors.white) @@ -39,6 +40,12 @@ function renderer.try_start_ui(theme) term.setPaletteColor(style.theme.colors[i].c, style.theme.colors[i].hex) end + -- apply color mode + local c_mode_overrides = style.theme.color_modes[color_mode] + for i = 1, #c_mode_overrides do + term.setPaletteColor(c_mode_overrides[i].c, c_mode_overrides[i].hex) + end + -- init front panel view status, msg = pcall(function () ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root} diff --git a/supervisor/startup.lua b/supervisor/startup.lua index d9c2229..4eae495 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor") local svsessions = require("supervisor.session.svsessions") -local SUPERVISOR_VERSION = "v1.2.12" +local SUPERVISOR_VERSION = "v1.3.0" local println = util.println local println_ts = util.println_ts @@ -118,7 +118,7 @@ local function main() databus.tx_hw_modem(true) -- start UI - local fp_ok, message = renderer.try_start_ui(config.FrontPanelTheme) + local fp_ok, message = renderer.try_start_ui(config.FrontPanelTheme, config.ColorMode) if not fp_ok then println_ts(util.c("UI error: ", message))