From b3f29566ea2204ffbe04ffada205b3c7a1b4d9fb Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Mon, 11 Mar 2024 21:25:34 -0400 Subject: [PATCH 1/9] #340 colorblind modes for rtu, reactor-plc, and supervisor --- graphics/themes.lua | 73 ++++++++++++++++++++++++++++++- reactor-plc/configure.lua | 21 ++++----- reactor-plc/panel/front_panel.lua | 46 +++++++++++++++++-- reactor-plc/renderer.lua | 13 ++++-- reactor-plc/startup.lua | 4 +- rtu/configure.lua | 21 ++++----- rtu/panel/front_panel.lua | 43 ++++++++++++++++-- rtu/renderer.lua | 13 ++++-- rtu/startup.lua | 4 +- supervisor/configure.lua | 21 ++++----- supervisor/databus.lua | 8 ++-- supervisor/panel/front_panel.lua | 4 +- supervisor/renderer.lua | 11 ++++- supervisor/startup.lua | 4 +- 14 files changed, 226 insertions(+), 60 deletions(-) diff --git a/graphics/themes.lua b/graphics/themes.lua index c454aab..85928ac 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,39 @@ 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_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_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_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 +168,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 +179,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 = 0x3393ff }, + { 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 = 0x3393ff }, + { 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 } + } } } diff --git a/reactor-plc/configure.lua b/reactor-plc/configure.lua index 80ef86c..c084e7d 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") @@ -473,29 +474,29 @@ local function config_view(display) TextBox{parent=clr_c_1,x=1,y=4,height=2,text="Click 'Accessibility' below to access color blind 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) 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 + elseif value == themes.COLOR_MODE.DEUTERANOPIA then term.setPaletteColor(colors.green, 0x1081ff) term.setPaletteColor(colors.yellow, 0xf7c311) term.setPaletteColor(colors.red, 0xfb5615) - elseif value == 4 then + elseif value == themes.COLOR_MODE.PROTANOPIA then + term.setPaletteColor(colors.green, 0x1081ff) + term.setPaletteColor(colors.yellow, 0xf5e633) + term.setPaletteColor(colors.red, 0xff521a) + elseif value == themes.COLOR_MODE.TRITANOPIA then term.setPaletteColor(colors.green, 0x00ecff) term.setPaletteColor(colors.yellow, 0xffbc00) term.setPaletteColor(colors.red, 0xff0000) 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} + 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} 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} @@ -749,9 +750,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..5797c2b 100644 --- a/reactor-plc/panel/front_panel.lua +++ b/reactor-plc/panel/front_panel.lua @@ -12,6 +12,7 @@ local style = require("reactor-plc.panel.style") local core = require("graphics.core") local flasher = require("graphics.flasher") +local themes = require("graphics.themes") local Div = require("graphics.elements.div") local Rectangle = require("graphics.elements.rectangle") @@ -23,6 +24,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 @@ -33,7 +36,8 @@ local ind_red = style.ind_red -- create new front panel view ---@param panel graphics_element main displaybox -local function init(panel) +---@param color_mode COLOR_MODE color mode +local function init(panel, color_mode) local s_hi_box = style.theme.highlight_box local disabled_fg = style.fp.disabled_fg @@ -56,13 +60,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 color_mode == themes.COLOR_MODE.STANDARD 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 = RGBLED{parent=system,label="NT LINKED",colors={colors.red_off,colors.red,colors.green}} + local nt_ver = RGBLED{parent=system,label="NT VERSION",colors={colors.red_off,colors.red,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/renderer.lua b/reactor-plc/renderer.lua index 31af361..8748cae 100644 --- a/reactor-plc/renderer.lua +++ b/reactor-plc/renderer.lua @@ -18,9 +18,10 @@ 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 @@ -38,10 +39,16 @@ 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} - panel_view(ui.display) + panel_view(ui.display, color_mode) end) if status then 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 cfda26d..e9f50eb 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") @@ -528,29 +529,29 @@ local function config_view(display) TextBox{parent=clr_c_1,x=1,y=4,height=2,text="Click 'Accessibility' below to access color blind 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) 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 + elseif value == themes.COLOR_MODE.DEUTERANOPIA then term.setPaletteColor(colors.green, 0x1081ff) term.setPaletteColor(colors.yellow, 0xf7c311) term.setPaletteColor(colors.red, 0xfb5615) - elseif value == 4 then + elseif value == themes.COLOR_MODE.PROTANOPIA then + term.setPaletteColor(colors.green, 0x1081ff) + term.setPaletteColor(colors.yellow, 0xf5e633) + term.setPaletteColor(colors.red, 0xff521a) + elseif value == themes.COLOR_MODE.TRITANOPIA then term.setPaletteColor(colors.green, 0x00ecff) term.setPaletteColor(colors.yellow, 0xffbc00) term.setPaletteColor(colors.red, 0xff0000) 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} + 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} 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} @@ -1426,9 +1427,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..36e72f4 100644 --- a/rtu/panel/front_panel.lua +++ b/rtu/panel/front_panel.lua @@ -10,6 +10,7 @@ local databus = require("rtu.databus") local style = require("rtu.panel.style") local core = require("graphics.core") +local themes = require("graphics.themes") local Div = require("graphics.elements.div") local TextBox = require("graphics.elements.textbox") @@ -18,6 +19,8 @@ local DataIndicator = require("graphics.elements.indicators.data") local LED = require("graphics.elements.indicators.led") local RGBLED = require("graphics.elements.indicators.ledrgb") +local LINK_STATE = types.PANEL_LINK_STATE + local ALIGN = core.ALIGN local cpair = core.cpair @@ -29,7 +32,8 @@ local UNIT_TYPE_LABELS = { "UNKNOWN", "REDSTONE", "BOILER", "TURBINE", "DYNAMIC -- create new front panel view ---@param panel graphics_element main displaybox ---@param units table unit list -local function init(panel, units) +---@param color_mode COLOR_MODE color mode +local function init(panel, units, color_mode) local disabled_fg = style.fp.disabled_fg TextBox{parent=panel,y=1,text="RTU GATEWAY",alignment=ALIGN.CENTER,height=1,fg_bg=style.theme.header} @@ -48,12 +52,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 color_mode == themes.COLOR_MODE.STANDARD 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 = RGBLED{parent=system,label="NT LINKED",colors={colors.red_off,colors.red,colors.green}} + local nt_ver = RGBLED{parent=system,label="NT VERSION",colors={colors.red_off,colors.red,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/renderer.lua b/rtu/renderer.lua index 2a1a235..8d56a40 100644 --- a/rtu/renderer.lua +++ b/rtu/renderer.lua @@ -19,9 +19,10 @@ 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 @@ -39,10 +40,16 @@ 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} - panel_view(ui.display, units) + panel_view(ui.display, units, color_mode) end) if status then diff --git a/rtu/startup.lua b/rtu/startup.lua index 8888d05..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.15" +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 0b63519..1ea1677 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") @@ -772,29 +773,29 @@ local function config_view(display) TextBox{parent=clr_c_1,x=1,y=4,height=2,text="Click 'Accessibility' below to access color blind 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) 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 + elseif value == themes.COLOR_MODE.DEUTERANOPIA then term.setPaletteColor(colors.green, 0x1081ff) term.setPaletteColor(colors.yellow, 0xf7c311) term.setPaletteColor(colors.red, 0xfb5615) - elseif value == 4 then + elseif value == themes.COLOR_MODE.PROTANOPIA then + term.setPaletteColor(colors.green, 0x1081ff) + term.setPaletteColor(colors.yellow, 0xf5e633) + term.setPaletteColor(colors.red, 0xff521a) + elseif value == themes.COLOR_MODE.TRITANOPIA then term.setPaletteColor(colors.green, 0x00ecff) term.setPaletteColor(colors.yellow, 0xffbc00) term.setPaletteColor(colors.red, 0xff0000) 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} + 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} 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} @@ -1107,9 +1108,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/renderer.lua b/supervisor/renderer.lua index 8f9389f..b1c9f06 100644 --- a/supervisor/renderer.lua +++ b/supervisor/renderer.lua @@ -19,9 +19,10 @@ 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 @@ -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)) From 9d08b51f84d2616c8cd3879b8c3041f3bfa64211 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Mon, 11 Mar 2024 21:43:11 -0400 Subject: [PATCH 2/9] #340 restored softer blue for deuteranopia/protanopia basalt theme --- graphics/themes.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphics/themes.lua b/graphics/themes.lua index 85928ac..a8376b2 100644 --- a/graphics/themes.lua +++ b/graphics/themes.lua @@ -186,7 +186,7 @@ themes.basalt = { {}, -- deuteranopia { - { c = colors.green, hex = 0x3393ff }, + { c = colors.green, hex = 0x65aeff }, { c = colors.green_hc, hex = 0x99c9ff }, { c = colors.green_off, hex = 0x333333 }, { c = colors.yellow, hex = 0xf7c311 }, @@ -196,7 +196,7 @@ themes.basalt = { }, -- protanopia { - { c = colors.green, hex = 0x3393ff }, + { c = colors.green, hex = 0x65aeff }, { c = colors.green_hc, hex = 0x99c9ff }, { c = colors.green_off, hex = 0x333333 }, { c = colors.yellow, hex = 0xf5e633 }, From 1f451ff92adfd82607761e5e935968c1446fef6f Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Mon, 11 Mar 2024 23:31:31 -0400 Subject: [PATCH 3/9] #340 coordinator colorblind support --- coordinator/configure.lua | 12 +-- coordinator/iocontrol.lua | 2 +- coordinator/renderer.lua | 27 +++++-- coordinator/startup.lua | 7 +- coordinator/ui/components/process_ctl.lua | 20 ++--- coordinator/ui/components/unit_detail.lua | 49 ++++++------ coordinator/ui/components/unit_flow.lua | 12 +-- coordinator/ui/layout/front_panel.lua | 43 +++++++++- coordinator/ui/style.lua | 95 +++++++++++++++++------ graphics/themes.lua | 3 + 10 files changed, 187 insertions(+), 83 deletions(-) diff --git a/coordinator/configure.lua b/coordinator/configure.lua index b2576c5..1480dd7 100644 --- a/coordinator/configure.lua +++ b/coordinator/configure.lua @@ -843,15 +843,15 @@ local function config_view(display) local function recolor(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 + elseif value == themes.COLOR_MODE.DEUTERANOPIA then term.setPaletteColor(colors.green, 0x1081ff) term.setPaletteColor(colors.yellow, 0xf7c311) term.setPaletteColor(colors.red, 0xfb5615) - elseif value == 4 then + elseif value == themes.COLOR_MODE.PROTANOPIA then + term.setPaletteColor(colors.green, 0x1081ff) + term.setPaletteColor(colors.yellow, 0xf5e633) + term.setPaletteColor(colors.red, 0xff521a) + elseif value == themes.COLOR_MODE.TRITANOPIA then term.setPaletteColor(colors.green, 0x00ecff) term.setPaletteColor(colors.yellow, 0xffbc00) term.setPaletteColor(colors.red, 0xff0000) 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..ad275dc 100644 --- a/coordinator/renderer.lua +++ b/coordinator/renderer.lua @@ -16,6 +16,7 @@ local unit_view = require("coordinator.ui.layout.unit_view") local core = require("graphics.core") local flasher = require("graphics.flasher") +local themes = require("graphics.themes") local DisplayBox = require("graphics.elements.displaybox") @@ -24,6 +25,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 +52,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 +70,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 ~= themes.COLOR_MODE.STANDARD) + + engine.color_mode = config.ColorMode + engine.disable_flow_view = config.DisableFlowView end -- link to the monitor peripherals @@ -100,6 +111,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 @@ -118,7 +135,7 @@ function renderer.try_start_fp() -- show front panel view on terminal status, msg = pcall(function () engine.ui.front_panel = DisplayBox{window=term.native(),fg_bg=style.fp.root} - panel_view(engine.ui.front_panel, #engine.monitors.unit_displays) + panel_view(engine.ui.front_panel, #engine.monitors.unit_displays, engine.color_mode) end) if status then 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..459a9f0 100644 --- a/coordinator/ui/layout/front_panel.lua +++ b/coordinator/ui/layout/front_panel.lua @@ -13,6 +13,7 @@ local style = require("coordinator.ui.style") local pkt_entry = require("coordinator.ui.components.pkt_entry") local core = require("graphics.core") +local themes = require("graphics.themes") local Div = require("graphics.elements.div") local ListBox = require("graphics.elements.listbox") @@ -24,6 +25,8 @@ local TabBar = require("graphics.elements.controls.tabbar") local LED = require("graphics.elements.indicators.led") local RGBLED = require("graphics.elements.indicators.ledrgb") +local LINK_STATE = types.PANEL_LINK_STATE + local ALIGN = core.ALIGN local cpair = core.cpair @@ -33,7 +36,8 @@ local led_grn = style.led_grn -- create new front panel view ---@param panel graphics_element main displaybox ---@param num_units integer number of units (number of unit monitors) -local function init(panel, num_units) +---@param color_mode COLOR_MODE color mode +local function init(panel, num_units, color_mode) local ps = iocontrol.get_db().fp.ps TextBox{parent=panel,y=1,text="SCADA COORDINATOR",alignment=ALIGN.CENTER,height=1,fg_bg=style.fp_theme.header} @@ -56,12 +60,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 color_mode == themes.COLOR_MODE.STANDARD 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 = RGBLED{parent=system,label="NT LINKED",colors={colors.red_off,colors.red,colors.green}} + local nt_ver = RGBLED{parent=system,label="NT VERSION",colors={colors.red_off,colors.red,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..6c91b2c 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, @@ -59,6 +62,30 @@ local smooth_stone = { { 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 }, + } } } @@ -70,6 +97,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, @@ -102,44 +130,72 @@ local deepslate = { { 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 }, + } } } 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 colorblind boolean true if in a colorblind mode +function style.set_themes(main, fp, colorblind) + 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.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 +215,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/themes.lua b/graphics/themes.lua index a8376b2..5de1ae3 100644 --- a/graphics/themes.lua +++ b/graphics/themes.lua @@ -121,6 +121,7 @@ themes.sandstone = { -- 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 }, @@ -130,6 +131,7 @@ themes.sandstone = { -- 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 }, @@ -139,6 +141,7 @@ themes.sandstone = { -- 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 }, From 89d56d3101d07d2f55e2e181ac991a21207459c4 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Mon, 11 Mar 2024 23:54:03 -0400 Subject: [PATCH 4/9] moved main UI palettes to themes.lua and set configurators to use it --- coordinator/configure.lua | 46 ++++++------------- coordinator/ui/style.lua | 84 ++-------------------------------- graphics/themes.lua | 96 +++++++++++++++++++++++++++++++++++++++ pocket/configure.lua | 17 +------ reactor-plc/configure.lua | 46 ++++++------------- rtu/configure.lua | 46 ++++++------------- supervisor/configure.lua | 46 ++++++------------- 7 files changed, 158 insertions(+), 223 deletions(-) diff --git a/coordinator/configure.lua b/coordinator/configure.lua index 1480dd7..172f5a8 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 == themes.COLOR_MODE.DEUTERANOPIA then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf7c311) - term.setPaletteColor(colors.red, 0xfb5615) - elseif value == themes.COLOR_MODE.PROTANOPIA then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf5e633) - term.setPaletteColor(colors.red, 0xff521a) - elseif value == themes.COLOR_MODE.TRITANOPIA 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),value=true} + _ = IndLight{parent=clr_c_2,x=20,y=10,label="Warning",colors=cpair(colors.black,colors.yellow),value=true} + _ = IndLight{parent=clr_c_2,x=20,y=11,label="Bad",colors=cpair(colors.black,colors.red),value=true} - 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/ui/style.lua b/coordinator/ui/style.lua index 6c91b2c..920adfe 100644 --- a/coordinator/ui/style.lua +++ b/coordinator/ui/style.lua @@ -45,48 +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 = { - -- 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 }, - } - } + color_modes = themes.smooth_stone.color_modes } ---@type theme @@ -113,48 +75,10 @@ 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 = { - -- 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 }, - } - } + color_modes = themes.deepslate.color_modes } style.theme = smooth_stone diff --git a/graphics/themes.lua b/graphics/themes.lua index 5de1ae3..c0d02ed 100644 --- a/graphics/themes.lua +++ b/graphics/themes.lua @@ -241,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 }, + } + } +} + +---@class 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 e67c697..ba3f380 100644 --- a/reactor-plc/configure.lua +++ b/reactor-plc/configure.lua @@ -50,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) @@ -479,30 +465,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 == themes.COLOR_MODE.DEUTERANOPIA then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf7c311) - term.setPaletteColor(colors.red, 0xfb5615) - elseif value == themes.COLOR_MODE.PROTANOPIA then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf5e633) - term.setPaletteColor(colors.red, 0xff521a) - elseif value == themes.COLOR_MODE.TRITANOPIA 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),value=true} + _ = IndLight{parent=clr_c_2,x=20,y=10,label="Warning",colors=cpair(colors.black,colors.yellow),value=true} + _ = IndLight{parent=clr_c_2,x=20,y=11,label="Bad",colors=cpair(colors.black,colors.red),value=true} - 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/rtu/configure.lua b/rtu/configure.lua index b7746bc..50bc572 100644 --- a/rtu/configure.lua +++ b/rtu/configure.lua @@ -102,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) @@ -534,30 +520,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 == themes.COLOR_MODE.DEUTERANOPIA then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf7c311) - term.setPaletteColor(colors.red, 0xfb5615) - elseif value == themes.COLOR_MODE.PROTANOPIA then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf5e633) - term.setPaletteColor(colors.red, 0xff521a) - elseif value == themes.COLOR_MODE.TRITANOPIA 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),value=true} + _ = IndLight{parent=clr_c_2,x=20,y=10,label="Warning",colors=cpair(colors.black,colors.yellow),value=true} + _ = IndLight{parent=clr_c_2,x=20,y=11,label="Bad",colors=cpair(colors.black,colors.red),value=true} - 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/supervisor/configure.lua b/supervisor/configure.lua index 53c3eb0..f5f41c4 100644 --- a/supervisor/configure.lua +++ b/supervisor/configure.lua @@ -47,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) @@ -778,30 +764,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 == themes.COLOR_MODE.DEUTERANOPIA then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf7c311) - term.setPaletteColor(colors.red, 0xfb5615) - elseif value == themes.COLOR_MODE.PROTANOPIA then - term.setPaletteColor(colors.green, 0x1081ff) - term.setPaletteColor(colors.yellow, 0xf5e633) - term.setPaletteColor(colors.red, 0xff521a) - elseif value == themes.COLOR_MODE.TRITANOPIA 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),value=true} + _ = IndLight{parent=clr_c_2,x=20,y=10,label="Warning",colors=cpair(colors.black,colors.yellow),value=true} + _ = IndLight{parent=clr_c_2,x=20,y=11,label="Bad",colors=cpair(colors.black,colors.red),value=true} - 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} From 8dae632b251aada18e39d0eb345fa15a125c0bbc Mon Sep 17 00:00:00 2001 From: Mikayla Date: Tue, 12 Mar 2024 16:24:32 +0000 Subject: [PATCH 5/9] simplified checks for colorblind mode --- coordinator/renderer.lua | 5 ++--- coordinator/ui/layout/front_panel.lua | 6 ++---- coordinator/ui/style.lua | 13 ++++++++----- reactor-plc/panel/front_panel.lua | 5 ++--- reactor-plc/panel/style.lua | 12 ++++++++---- reactor-plc/renderer.lua | 4 ++-- rtu/panel/front_panel.lua | 5 ++--- rtu/panel/style.lua | 12 ++++++++---- rtu/renderer.lua | 4 ++-- supervisor/panel/style.lua | 11 +++++++---- 10 files changed, 43 insertions(+), 34 deletions(-) diff --git a/coordinator/renderer.lua b/coordinator/renderer.lua index ad275dc..d9e4b58 100644 --- a/coordinator/renderer.lua +++ b/coordinator/renderer.lua @@ -16,7 +16,6 @@ local unit_view = require("coordinator.ui.layout.unit_view") local core = require("graphics.core") local flasher = require("graphics.flasher") -local themes = require("graphics.themes") local DisplayBox = require("graphics.elements.displaybox") @@ -73,7 +72,7 @@ end -- apply renderer configurations ---@param config crd_config function renderer.configure(config) - style.set_themes(config.MainTheme, config.FrontPanelTheme, config.ColorMode ~= themes.COLOR_MODE.STANDARD) + style.set_themes(config.MainTheme, config.FrontPanelTheme, config.ColorMode) engine.color_mode = config.ColorMode engine.disable_flow_view = config.DisableFlowView @@ -135,7 +134,7 @@ function renderer.try_start_fp() -- show front panel view on terminal status, msg = pcall(function () engine.ui.front_panel = DisplayBox{window=term.native(),fg_bg=style.fp.root} - panel_view(engine.ui.front_panel, #engine.monitors.unit_displays, engine.color_mode) + panel_view(engine.ui.front_panel, #engine.monitors.unit_displays) end) if status then diff --git a/coordinator/ui/layout/front_panel.lua b/coordinator/ui/layout/front_panel.lua index 459a9f0..3e400d9 100644 --- a/coordinator/ui/layout/front_panel.lua +++ b/coordinator/ui/layout/front_panel.lua @@ -13,7 +13,6 @@ local style = require("coordinator.ui.style") local pkt_entry = require("coordinator.ui.components.pkt_entry") local core = require("graphics.core") -local themes = require("graphics.themes") local Div = require("graphics.elements.div") local ListBox = require("graphics.elements.listbox") @@ -36,8 +35,7 @@ local led_grn = style.led_grn -- create new front panel view ---@param panel graphics_element main displaybox ---@param num_units integer number of units (number of unit monitors) ----@param color_mode COLOR_MODE color mode -local function init(panel, num_units, color_mode) +local function init(panel, num_units) local ps = iocontrol.get_db().fp.ps TextBox{parent=panel,y=1,text="SCADA COORDINATOR",alignment=ALIGN.CENTER,height=1,fg_bg=style.fp_theme.header} @@ -61,7 +59,7 @@ local function init(panel, num_units, color_mode) local modem = LED{parent=system,label="MODEM",colors=led_grn} - if color_mode == themes.COLOR_MODE.STANDARD then + 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) diff --git a/coordinator/ui/style.lua b/coordinator/ui/style.lua index 920adfe..13379b7 100644 --- a/coordinator/ui/style.lua +++ b/coordinator/ui/style.lua @@ -84,12 +84,13 @@ local deepslate = { style.theme = smooth_stone -- 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) ----@param colorblind boolean true if in a colorblind mode -function style.set_themes(main, fp, colorblind) - style.ind_bkg = colors.gray +---@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 @@ -100,6 +101,8 @@ function style.set_themes(main, fp, colorblind) 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) diff --git a/reactor-plc/panel/front_panel.lua b/reactor-plc/panel/front_panel.lua index 5797c2b..c4ec184 100644 --- a/reactor-plc/panel/front_panel.lua +++ b/reactor-plc/panel/front_panel.lua @@ -36,8 +36,7 @@ local ind_red = style.ind_red -- create new front panel view ---@param panel graphics_element main displaybox ----@param color_mode COLOR_MODE color mode -local function init(panel, color_mode) +local function init(panel) local s_hi_box = style.theme.highlight_box local disabled_fg = style.fp.disabled_fg @@ -61,7 +60,7 @@ local function init(panel, color_mode) 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} - if color_mode == themes.COLOR_MODE.STANDARD then + 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) 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 8748cae..aa62e63 100644 --- a/reactor-plc/renderer.lua +++ b/reactor-plc/renderer.lua @@ -26,7 +26,7 @@ function renderer.try_start_ui(theme, color_mode) if ui.display == nil then -- set theme - style.set_theme(theme) + style.set_theme(theme, color_mode) -- reset terminal term.setTextColor(colors.white) @@ -48,7 +48,7 @@ function renderer.try_start_ui(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, color_mode) + panel_view(ui.display) end) if status then diff --git a/rtu/panel/front_panel.lua b/rtu/panel/front_panel.lua index 36e72f4..a3e6169 100644 --- a/rtu/panel/front_panel.lua +++ b/rtu/panel/front_panel.lua @@ -32,8 +32,7 @@ local UNIT_TYPE_LABELS = { "UNKNOWN", "REDSTONE", "BOILER", "TURBINE", "DYNAMIC -- create new front panel view ---@param panel graphics_element main displaybox ---@param units table unit list ----@param color_mode COLOR_MODE color mode -local function init(panel, units, color_mode) +local function init(panel, units) local disabled_fg = style.fp.disabled_fg TextBox{parent=panel,y=1,text="RTU GATEWAY",alignment=ALIGN.CENTER,height=1,fg_bg=style.theme.header} @@ -53,7 +52,7 @@ local function init(panel, units, color_mode) local modem = LED{parent=system,label="MODEM",colors=ind_grn} - if color_mode == themes.COLOR_MODE.STANDARD then + 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) 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 8d56a40..bdbc25b 100644 --- a/rtu/renderer.lua +++ b/rtu/renderer.lua @@ -27,7 +27,7 @@ function renderer.try_start_ui(units, theme, color_mode) if ui.display == nil then -- set theme - style.set_theme(theme) + style.set_theme(theme, color_mode) -- reset terminal term.setTextColor(colors.white) @@ -49,7 +49,7 @@ function renderer.try_start_ui(units, 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, units, color_mode) + panel_view(ui.display, units) end) if status then diff --git a/supervisor/panel/style.lua b/supervisor/panel/style.lua index efcc9b7..4fe9cb4 100644 --- a/supervisor/panel/style.lua +++ b/supervisor/panel/style.lua @@ -12,19 +12,22 @@ 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 +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 From 886bd0d5d588bc5930223c649558d5f514c65e10 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Tue, 12 Mar 2024 12:49:33 -0400 Subject: [PATCH 6/9] luacheck fixes --- reactor-plc/panel/front_panel.lua | 1 - rtu/panel/front_panel.lua | 1 - 2 files changed, 2 deletions(-) diff --git a/reactor-plc/panel/front_panel.lua b/reactor-plc/panel/front_panel.lua index c4ec184..017fb55 100644 --- a/reactor-plc/panel/front_panel.lua +++ b/reactor-plc/panel/front_panel.lua @@ -12,7 +12,6 @@ local style = require("reactor-plc.panel.style") local core = require("graphics.core") local flasher = require("graphics.flasher") -local themes = require("graphics.themes") local Div = require("graphics.elements.div") local Rectangle = require("graphics.elements.rectangle") diff --git a/rtu/panel/front_panel.lua b/rtu/panel/front_panel.lua index a3e6169..c43dcb9 100644 --- a/rtu/panel/front_panel.lua +++ b/rtu/panel/front_panel.lua @@ -10,7 +10,6 @@ local databus = require("rtu.databus") local style = require("rtu.panel.style") local core = require("graphics.core") -local themes = require("graphics.themes") local Div = require("graphics.elements.div") local TextBox = require("graphics.elements.textbox") From 93936324284329bb52393c825df728cd1567b092 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Tue, 12 Mar 2024 12:54:31 -0400 Subject: [PATCH 7/9] removed unused value specifiers --- coordinator/configure.lua | 6 +++--- reactor-plc/configure.lua | 6 +++--- rtu/configure.lua | 6 +++--- supervisor/configure.lua | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/coordinator/configure.lua b/coordinator/configure.lua index 172f5a8..5b223e8 100644 --- a/coordinator/configure.lua +++ b/coordinator/configure.lua @@ -842,9 +842,9 @@ local function config_view(display) 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} 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),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=10,label="Warning",colors=cpair(colors.black,colors.yellow),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=11,label="Bad",colors=cpair(colors.black,colors.red),value=true} + 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=1,y=14,height=6,text="Note: exact color varies by theme.",fg_bg=g_lg_fg_bg} diff --git a/reactor-plc/configure.lua b/reactor-plc/configure.lua index ba3f380..a2c223c 100644 --- a/reactor-plc/configure.lua +++ b/reactor-plc/configure.lua @@ -480,9 +480,9 @@ local function config_view(display) 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} 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),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=10,label="Warning",colors=cpair(colors.black,colors.yellow),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=11,label="Bad",colors=cpair(colors.black,colors.red),value=true} + 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=1,y=14,height=6,text="Note: exact color varies by theme.",fg_bg=g_lg_fg_bg} diff --git a/rtu/configure.lua b/rtu/configure.lua index eeb3c87..2fb8703 100644 --- a/rtu/configure.lua +++ b/rtu/configure.lua @@ -535,9 +535,9 @@ local function config_view(display) 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} 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),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=10,label="Warning",colors=cpair(colors.black,colors.yellow),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=11,label="Bad",colors=cpair(colors.black,colors.red),value=true} + 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=1,y=14,height=6,text="Note: exact color varies by theme.",fg_bg=g_lg_fg_bg} diff --git a/supervisor/configure.lua b/supervisor/configure.lua index f5f41c4..6163bbb 100644 --- a/supervisor/configure.lua +++ b/supervisor/configure.lua @@ -779,9 +779,9 @@ local function config_view(display) 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} 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),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=10,label="Warning",colors=cpair(colors.black,colors.yellow),value=true} - _ = IndLight{parent=clr_c_2,x=20,y=11,label="Bad",colors=cpair(colors.black,colors.red),value=true} + 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=1,y=14,height=6,text="Note: exact color varies by theme.",fg_bg=g_lg_fg_bg} From a00a824a7f5a00cbcca2765e64d2eddf5d7fca50 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Tue, 12 Mar 2024 13:15:28 -0400 Subject: [PATCH 8/9] cleanup and fixes --- graphics/core.lua | 2 +- graphics/themes.lua | 2 +- supervisor/panel/style.lua | 1 + supervisor/renderer.lua | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) 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 c0d02ed..b59b504 100644 --- a/graphics/themes.lua +++ b/graphics/themes.lua @@ -289,7 +289,7 @@ themes.smooth_stone = { } } ----@class ui_palette +---@type ui_palette themes.deepslate = { colors = { { c = colors.red, hex = 0xeb6a6c }, diff --git a/supervisor/panel/style.lua b/supervisor/panel/style.lua index 4fe9cb4..a0a8bb0 100644 --- a/supervisor/panel/style.lua +++ b/supervisor/panel/style.lua @@ -18,6 +18,7 @@ style.ind_grn = cpair(colors.green, colors.green_off) -- set theme per configuration ---@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 diff --git a/supervisor/renderer.lua b/supervisor/renderer.lua index b1c9f06..fde7fc3 100644 --- a/supervisor/renderer.lua +++ b/supervisor/renderer.lua @@ -27,7 +27,7 @@ function renderer.try_start_ui(theme, color_mode) if ui.display == nil then -- set theme - style.set_theme(theme) + style.set_theme(theme, color_mode) -- reset terminal term.setTextColor(colors.white) From d6175e5cec4564d0ffb6c61aecac8ac14d6e668c Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Tue, 12 Mar 2024 13:23:39 -0400 Subject: [PATCH 9/9] switched to using LEDPair elements for colorblind mode network lights --- coordinator/ui/layout/front_panel.lua | 5 +++-- reactor-plc/panel/front_panel.lua | 4 ++-- rtu/panel/front_panel.lua | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/coordinator/ui/layout/front_panel.lua b/coordinator/ui/layout/front_panel.lua index 3e400d9..455e42e 100644 --- a/coordinator/ui/layout/front_panel.lua +++ b/coordinator/ui/layout/front_panel.lua @@ -22,6 +22,7 @@ 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 @@ -64,8 +65,8 @@ local function init(panel, num_units) network.update(types.PANEL_LINK_STATE.DISCONNECTED) network.register(ps, "link_state", network.update) else - local nt_lnk = RGBLED{parent=system,label="NT LINKED",colors={colors.red_off,colors.red,colors.green}} - local nt_ver = RGBLED{parent=system,label="NT VERSION",colors={colors.red_off,colors.red,colors.green}} + 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 diff --git a/reactor-plc/panel/front_panel.lua b/reactor-plc/panel/front_panel.lua index 017fb55..b54cd04 100644 --- a/reactor-plc/panel/front_panel.lua +++ b/reactor-plc/panel/front_panel.lua @@ -64,8 +64,8 @@ local function init(panel) network.update(types.PANEL_LINK_STATE.DISCONNECTED) network.register(databus.ps, "link_state", network.update) else - local nt_lnk = RGBLED{parent=system,label="NT LINKED",colors={colors.red_off,colors.red,colors.green}} - local nt_ver = RGBLED{parent=system,label="NT VERSION",colors={colors.red_off,colors.red,colors.green}} + 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) diff --git a/rtu/panel/front_panel.lua b/rtu/panel/front_panel.lua index c43dcb9..d479302 100644 --- a/rtu/panel/front_panel.lua +++ b/rtu/panel/front_panel.lua @@ -16,6 +16,7 @@ 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 @@ -56,8 +57,8 @@ local function init(panel, units) network.update(types.PANEL_LINK_STATE.DISCONNECTED) network.register(databus.ps, "link_state", network.update) else - local nt_lnk = RGBLED{parent=system,label="NT LINKED",colors={colors.red_off,colors.red,colors.green}} - local nt_ver = RGBLED{parent=system,label="NT VERSION",colors={colors.red_off,colors.red,colors.green}} + 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