mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#340 colorblind modes for rtu, reactor-plc, and supervisor
This commit is contained in:
parent
d5b166dcc6
commit
b3f29566ea
@ -11,6 +11,7 @@ local themes = {}
|
|||||||
|
|
||||||
-- add color mappings for front panels
|
-- add color mappings for front panels
|
||||||
colors.ivory = colors.pink
|
colors.ivory = colors.pink
|
||||||
|
colors.green_hc = colors.cyan
|
||||||
colors.yellow_hc = colors.purple
|
colors.yellow_hc = colors.purple
|
||||||
colors.red_off = colors.brown
|
colors.red_off = colors.brown
|
||||||
colors.yellow_off = colors.magenta
|
colors.yellow_off = colors.magenta
|
||||||
@ -100,7 +101,7 @@ themes.sandstone = {
|
|||||||
{ c = colors.yellow, hex = 0xf9fb53 },
|
{ c = colors.yellow, hex = 0xf9fb53 },
|
||||||
{ c = colors.green_off, hex = 0x16665a },
|
{ c = colors.green_off, hex = 0x16665a },
|
||||||
{ c = colors.green, hex = 0x6be551 },
|
{ c = colors.green, hex = 0x6be551 },
|
||||||
{ c = colors.cyan, hex = 0x34bac8 },
|
{ c = colors.green_hc, hex = 0x6be551 },
|
||||||
{ c = colors.lightBlue, hex = 0x6cc0f2 },
|
{ c = colors.lightBlue, hex = 0x6cc0f2 },
|
||||||
{ c = colors.blue, hex = 0x0096ff },
|
{ c = colors.blue, hex = 0x0096ff },
|
||||||
{ c = colors.yellow_hc, hex = 0xe3bc2a },
|
{ c = colors.yellow_hc, hex = 0xe3bc2a },
|
||||||
@ -111,6 +112,39 @@ themes.sandstone = {
|
|||||||
{ c = colors.gray, hex = 0x575757 },
|
{ c = colors.gray, hex = 0x575757 },
|
||||||
{ c = colors.black, hex = 0x191919 },
|
{ c = colors.black, hex = 0x191919 },
|
||||||
{ c = colors.red_off, hex = 0x672223 }
|
{ 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.yellow, hex = 0xefe37c },
|
||||||
{ c = colors.green_off, hex = 0x436b41 },
|
{ c = colors.green_off, hex = 0x436b41 },
|
||||||
{ c = colors.green, hex = 0x7ae175 },
|
{ c = colors.green, hex = 0x7ae175 },
|
||||||
{ c = colors.cyan, hex = 0x5ec7d1 },
|
{ c = colors.green_hc, hex = 0x7ae175 },
|
||||||
{ c = colors.lightBlue, hex = 0x7dc6f2 },
|
{ c = colors.lightBlue, hex = 0x7dc6f2 },
|
||||||
{ c = colors.blue, hex = 0x56aae6 },
|
{ c = colors.blue, hex = 0x56aae6 },
|
||||||
{ c = colors.yellow_hc, hex = 0xe9cd68 },
|
{ c = colors.yellow_hc, hex = 0xe9cd68 },
|
||||||
@ -145,6 +179,41 @@ themes.basalt = {
|
|||||||
{ c = colors.gray, hex = 0x5c5f68 },
|
{ c = colors.gray, hex = 0x5c5f68 },
|
||||||
{ c = colors.black, hex = 0x262626 },
|
{ c = colors.black, hex = 0x262626 },
|
||||||
{ c = colors.red_off, hex = 0x653839 }
|
{ 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 }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ local tcd = require("scada-common.tcd")
|
|||||||
local util = require("scada-common.util")
|
local util = require("scada-common.util")
|
||||||
|
|
||||||
local core = require("graphics.core")
|
local core = require("graphics.core")
|
||||||
|
local themes = require("graphics.themes")
|
||||||
|
|
||||||
local DisplayBox = require("graphics.elements.displaybox")
|
local DisplayBox = require("graphics.elements.displaybox")
|
||||||
local Div = require("graphics.elements.div")
|
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=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"}
|
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."}
|
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 function recolor(value)
|
||||||
if value == 1 then
|
if value == 1 then
|
||||||
for i = 1, #style.colors do term.setPaletteColor(style.colors[i].c, style.colors[i].hex) end
|
for i = 1, #style.colors do term.setPaletteColor(style.colors[i].c, style.colors[i].hex) end
|
||||||
elseif value == 2 then
|
elseif value == themes.COLOR_MODE.DEUTERANOPIA then
|
||||||
term.setPaletteColor(colors.green, 0x1081ff)
|
|
||||||
term.setPaletteColor(colors.yellow, 0xf5e633)
|
|
||||||
term.setPaletteColor(colors.red, 0xff521a)
|
|
||||||
elseif value == 3 then
|
|
||||||
term.setPaletteColor(colors.green, 0x1081ff)
|
term.setPaletteColor(colors.green, 0x1081ff)
|
||||||
term.setPaletteColor(colors.yellow, 0xf7c311)
|
term.setPaletteColor(colors.yellow, 0xf7c311)
|
||||||
term.setPaletteColor(colors.red, 0xfb5615)
|
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.green, 0x00ecff)
|
||||||
term.setPaletteColor(colors.yellow, 0xffbc00)
|
term.setPaletteColor(colors.yellow, 0xffbc00)
|
||||||
term.setPaletteColor(colors.red, 0xff0000)
|
term.setPaletteColor(colors.red, 0xff0000)
|
||||||
end
|
end
|
||||||
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}
|
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=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] == "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] == "EmerCoolColor" and raw ~= nil then val = rsio.color_name(raw)
|
||||||
elseif f[1] == "FrontPanelTheme" then
|
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
|
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
|
end
|
||||||
|
|
||||||
if val == "nil" then val = "<not set>" end
|
if val == "nil" then val = "<not set>" end
|
||||||
|
@ -12,6 +12,7 @@ local style = require("reactor-plc.panel.style")
|
|||||||
|
|
||||||
local core = require("graphics.core")
|
local core = require("graphics.core")
|
||||||
local flasher = require("graphics.flasher")
|
local flasher = require("graphics.flasher")
|
||||||
|
local themes = require("graphics.themes")
|
||||||
|
|
||||||
local Div = require("graphics.elements.div")
|
local Div = require("graphics.elements.div")
|
||||||
local Rectangle = require("graphics.elements.rectangle")
|
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 LEDPair = require("graphics.elements.indicators.ledpair")
|
||||||
local RGBLED = require("graphics.elements.indicators.ledrgb")
|
local RGBLED = require("graphics.elements.indicators.ledrgb")
|
||||||
|
|
||||||
|
local LINK_STATE = types.PANEL_LINK_STATE
|
||||||
|
|
||||||
local ALIGN = core.ALIGN
|
local ALIGN = core.ALIGN
|
||||||
|
|
||||||
local cpair = core.cpair
|
local cpair = core.cpair
|
||||||
@ -33,7 +36,8 @@ local ind_red = style.ind_red
|
|||||||
|
|
||||||
-- create new front panel view
|
-- create new front panel view
|
||||||
---@param panel graphics_element main displaybox
|
---@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 s_hi_box = style.theme.highlight_box
|
||||||
|
|
||||||
local disabled_fg = style.fp.disabled_fg
|
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 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 modem = LED{parent=system,label="MODEM",colors=ind_grn}
|
||||||
|
|
||||||
|
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}}
|
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.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()
|
system.line_break()
|
||||||
|
|
||||||
reactor.register(databus.ps, "reactor_dev_state", reactor.update)
|
reactor.register(databus.ps, "reactor_dev_state", reactor.update)
|
||||||
modem.register(databus.ps, "has_modem", modem.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_main = LED{parent=system,label="RT MAIN",colors=ind_grn}
|
||||||
local rt_rps = LED{parent=system,label="RT RPS",colors=ind_grn}
|
local rt_rps = LED{parent=system,label="RT RPS",colors=ind_grn}
|
||||||
|
@ -18,9 +18,10 @@ local ui = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- try to start the 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
|
---@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
|
local status, msg = true, nil
|
||||||
|
|
||||||
if ui.display == nil then
|
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)
|
term.setPaletteColor(style.theme.colors[i].c, style.theme.colors[i].hex)
|
||||||
end
|
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
|
-- init front panel view
|
||||||
status, msg = pcall(function ()
|
status, msg = pcall(function ()
|
||||||
ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root}
|
ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root}
|
||||||
panel_view(ui.display)
|
panel_view(ui.display, color_mode)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if status then
|
if status then
|
||||||
|
@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc")
|
|||||||
local renderer = require("reactor-plc.renderer")
|
local renderer = require("reactor-plc.renderer")
|
||||||
local threads = require("reactor-plc.threads")
|
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 = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
@ -183,7 +183,7 @@ local function main()
|
|||||||
-- front panel time!
|
-- front panel time!
|
||||||
if not renderer.ui_ready() then
|
if not renderer.ui_ready() then
|
||||||
local message
|
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
|
if not plc_state.fp_ok then
|
||||||
println_ts(util.c("UI error: ", message))
|
println_ts(util.c("UI error: ", message))
|
||||||
|
@ -9,6 +9,7 @@ local tcd = require("scada-common.tcd")
|
|||||||
local util = require("scada-common.util")
|
local util = require("scada-common.util")
|
||||||
|
|
||||||
local core = require("graphics.core")
|
local core = require("graphics.core")
|
||||||
|
local themes = require("graphics.themes")
|
||||||
|
|
||||||
local DisplayBox = require("graphics.elements.displaybox")
|
local DisplayBox = require("graphics.elements.displaybox")
|
||||||
local Div = require("graphics.elements.div")
|
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=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"}
|
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."}
|
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 function recolor(value)
|
||||||
if value == 1 then
|
if value == 1 then
|
||||||
for i = 1, #style.colors do term.setPaletteColor(style.colors[i].c, style.colors[i].hex) end
|
for i = 1, #style.colors do term.setPaletteColor(style.colors[i].c, style.colors[i].hex) end
|
||||||
elseif value == 2 then
|
elseif value == themes.COLOR_MODE.DEUTERANOPIA then
|
||||||
term.setPaletteColor(colors.green, 0x1081ff)
|
|
||||||
term.setPaletteColor(colors.yellow, 0xf5e633)
|
|
||||||
term.setPaletteColor(colors.red, 0xff521a)
|
|
||||||
elseif value == 3 then
|
|
||||||
term.setPaletteColor(colors.green, 0x1081ff)
|
term.setPaletteColor(colors.green, 0x1081ff)
|
||||||
term.setPaletteColor(colors.yellow, 0xf7c311)
|
term.setPaletteColor(colors.yellow, 0xf7c311)
|
||||||
term.setPaletteColor(colors.red, 0xfb5615)
|
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.green, 0x00ecff)
|
||||||
term.setPaletteColor(colors.yellow, 0xffbc00)
|
term.setPaletteColor(colors.yellow, 0xffbc00)
|
||||||
term.setPaletteColor(colors.red, 0xff0000)
|
term.setPaletteColor(colors.red, 0xff0000)
|
||||||
end
|
end
|
||||||
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}
|
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=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))
|
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] == "LogMode" then val = util.trinary(raw == log.MODE.APPEND, "append", "replace")
|
||||||
elseif f[1] == "FrontPanelTheme" then
|
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
|
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
|
end
|
||||||
|
|
||||||
if val == "nil" then val = "<not set>" end
|
if val == "nil" then val = "<not set>" end
|
||||||
|
@ -10,6 +10,7 @@ local databus = require("rtu.databus")
|
|||||||
local style = require("rtu.panel.style")
|
local style = require("rtu.panel.style")
|
||||||
|
|
||||||
local core = require("graphics.core")
|
local core = require("graphics.core")
|
||||||
|
local themes = require("graphics.themes")
|
||||||
|
|
||||||
local Div = require("graphics.elements.div")
|
local Div = require("graphics.elements.div")
|
||||||
local TextBox = require("graphics.elements.textbox")
|
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 LED = require("graphics.elements.indicators.led")
|
||||||
local RGBLED = require("graphics.elements.indicators.ledrgb")
|
local RGBLED = require("graphics.elements.indicators.ledrgb")
|
||||||
|
|
||||||
|
local LINK_STATE = types.PANEL_LINK_STATE
|
||||||
|
|
||||||
local ALIGN = core.ALIGN
|
local ALIGN = core.ALIGN
|
||||||
|
|
||||||
local cpair = core.cpair
|
local cpair = core.cpair
|
||||||
@ -29,7 +32,8 @@ local UNIT_TYPE_LABELS = { "UNKNOWN", "REDSTONE", "BOILER", "TURBINE", "DYNAMIC
|
|||||||
-- create new front panel view
|
-- create new front panel view
|
||||||
---@param panel graphics_element main displaybox
|
---@param panel graphics_element main displaybox
|
||||||
---@param units table unit list
|
---@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
|
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}
|
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)
|
heartbeat.register(databus.ps, "heartbeat", heartbeat.update)
|
||||||
|
|
||||||
local modem = LED{parent=system,label="MODEM",colors=ind_grn}
|
local modem = LED{parent=system,label="MODEM",colors=ind_grn}
|
||||||
|
|
||||||
|
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}}
|
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.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()
|
system.line_break()
|
||||||
|
|
||||||
modem.register(databus.ps, "has_modem", modem.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_main = LED{parent=system,label="RT MAIN",colors=ind_grn}
|
||||||
local rt_comm = LED{parent=system,label="RT COMMS",colors=ind_grn}
|
local rt_comm = LED{parent=system,label="RT COMMS",colors=ind_grn}
|
||||||
|
@ -19,9 +19,10 @@ local ui = {
|
|||||||
|
|
||||||
-- try to start the UI
|
-- try to start the UI
|
||||||
---@param units table RTU units
|
---@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
|
---@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
|
local status, msg = true, nil
|
||||||
|
|
||||||
if ui.display == nil then
|
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)
|
term.setPaletteColor(style.theme.colors[i].c, style.theme.colors[i].hex)
|
||||||
end
|
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
|
-- init front panel view
|
||||||
status, msg = pcall(function ()
|
status, msg = pcall(function ()
|
||||||
ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root}
|
ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root}
|
||||||
panel_view(ui.display, units)
|
panel_view(ui.display, units, color_mode)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if status then
|
if status then
|
||||||
|
@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
|
|||||||
local sps_rtu = require("rtu.dev.sps_rtu")
|
local sps_rtu = require("rtu.dev.sps_rtu")
|
||||||
local turbinev_rtu = require("rtu.dev.turbinev_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_TYPE = types.RTU_UNIT_TYPE
|
||||||
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
||||||
@ -506,7 +506,7 @@ local function main()
|
|||||||
if sys_config() then
|
if sys_config() then
|
||||||
-- start UI
|
-- start UI
|
||||||
local message
|
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
|
if not rtu_state.fp_ok then
|
||||||
println_ts(util.c("UI error: ", message))
|
println_ts(util.c("UI error: ", message))
|
||||||
|
@ -7,6 +7,7 @@ local tcd = require("scada-common.tcd")
|
|||||||
local util = require("scada-common.util")
|
local util = require("scada-common.util")
|
||||||
|
|
||||||
local core = require("graphics.core")
|
local core = require("graphics.core")
|
||||||
|
local themes = require("graphics.themes")
|
||||||
|
|
||||||
local DisplayBox = require("graphics.elements.displaybox")
|
local DisplayBox = require("graphics.elements.displaybox")
|
||||||
local Div = require("graphics.elements.div")
|
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=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"}
|
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."}
|
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 function recolor(value)
|
||||||
if value == 1 then
|
if value == 1 then
|
||||||
for i = 1, #style.colors do term.setPaletteColor(style.colors[i].c, style.colors[i].hex) end
|
for i = 1, #style.colors do term.setPaletteColor(style.colors[i].c, style.colors[i].hex) end
|
||||||
elseif value == 2 then
|
elseif value == themes.COLOR_MODE.DEUTERANOPIA then
|
||||||
term.setPaletteColor(colors.green, 0x1081ff)
|
|
||||||
term.setPaletteColor(colors.yellow, 0xf5e633)
|
|
||||||
term.setPaletteColor(colors.red, 0xff521a)
|
|
||||||
elseif value == 3 then
|
|
||||||
term.setPaletteColor(colors.green, 0x1081ff)
|
term.setPaletteColor(colors.green, 0x1081ff)
|
||||||
term.setPaletteColor(colors.yellow, 0xf7c311)
|
term.setPaletteColor(colors.yellow, 0xf7c311)
|
||||||
term.setPaletteColor(colors.red, 0xfb5615)
|
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.green, 0x00ecff)
|
||||||
term.setPaletteColor(colors.yellow, 0xffbc00)
|
term.setPaletteColor(colors.yellow, 0xffbc00)
|
||||||
term.setPaletteColor(colors.red, 0xff0000)
|
term.setPaletteColor(colors.red, 0xff0000)
|
||||||
end
|
end
|
||||||
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}
|
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=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))
|
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] == "LogMode" then val = util.trinary(raw == log.MODE.APPEND, "append", "replace")
|
||||||
elseif f[1] == "FrontPanelTheme" then
|
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
|
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
|
elseif f[1] == "CoolingConfig" and type(cfg.CoolingConfig) == "table" then
|
||||||
val = ""
|
val = ""
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ function databus.tx_plc_rtt(reactor_id, rtt)
|
|||||||
elseif rtt > WARN_RTT then
|
elseif rtt > WARN_RTT then
|
||||||
databus.ps.publish("plc_" .. reactor_id .. "_rtt_color", colors.yellow_hc)
|
databus.ps.publish("plc_" .. reactor_id .. "_rtt_color", colors.yellow_hc)
|
||||||
else
|
else
|
||||||
databus.ps.publish("plc_" .. reactor_id .. "_rtt_color", colors.green)
|
databus.ps.publish("plc_" .. reactor_id .. "_rtt_color", colors.green_hc)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ function databus.tx_rtu_rtt(session_id, rtt)
|
|||||||
elseif rtt > WARN_RTT then
|
elseif rtt > WARN_RTT then
|
||||||
databus.ps.publish("rtu_" .. session_id .. "_rtt_color", colors.yellow_hc)
|
databus.ps.publish("rtu_" .. session_id .. "_rtt_color", colors.yellow_hc)
|
||||||
else
|
else
|
||||||
databus.ps.publish("rtu_" .. session_id .. "_rtt_color", colors.green)
|
databus.ps.publish("rtu_" .. session_id .. "_rtt_color", colors.green_hc)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ function databus.tx_crd_rtt(rtt)
|
|||||||
elseif rtt > WARN_RTT then
|
elseif rtt > WARN_RTT then
|
||||||
databus.ps.publish("crd_rtt_color", colors.yellow_hc)
|
databus.ps.publish("crd_rtt_color", colors.yellow_hc)
|
||||||
else
|
else
|
||||||
databus.ps.publish("crd_rtt_color", colors.green)
|
databus.ps.publish("crd_rtt_color", colors.green_hc)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ function databus.tx_pdg_rtt(session_id, rtt)
|
|||||||
elseif rtt > WARN_RTT then
|
elseif rtt > WARN_RTT then
|
||||||
databus.ps.publish("pdg_" .. session_id .. "_rtt_color", colors.yellow_hc)
|
databus.ps.publish("pdg_" .. session_id .. "_rtt_color", colors.yellow_hc)
|
||||||
else
|
else
|
||||||
databus.ps.publish("pdg_" .. session_id .. "_rtt_color", colors.green)
|
databus.ps.publish("pdg_" .. session_id .. "_rtt_color", colors.green_hc)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -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=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}
|
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)
|
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}
|
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_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_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)
|
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}
|
TextBox{parent=crd_box,x=4,y=3,text="COMPUTER",width=8,height=1,fg_bg=label_d_fg}
|
||||||
|
@ -19,9 +19,10 @@ local ui = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- try to start the 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
|
---@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
|
local status, msg = true, nil
|
||||||
|
|
||||||
if ui.display == nil then
|
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)
|
term.setPaletteColor(style.theme.colors[i].c, style.theme.colors[i].hex)
|
||||||
end
|
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
|
-- init front panel view
|
||||||
status, msg = pcall(function ()
|
status, msg = pcall(function ()
|
||||||
ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root}
|
ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root}
|
||||||
|
@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor")
|
|||||||
|
|
||||||
local svsessions = require("supervisor.session.svsessions")
|
local svsessions = require("supervisor.session.svsessions")
|
||||||
|
|
||||||
local SUPERVISOR_VERSION = "v1.2.12"
|
local SUPERVISOR_VERSION = "v1.3.0"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
@ -118,7 +118,7 @@ local function main()
|
|||||||
databus.tx_hw_modem(true)
|
databus.tx_hw_modem(true)
|
||||||
|
|
||||||
-- start UI
|
-- 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
|
if not fp_ok then
|
||||||
println_ts(util.c("UI error: ", message))
|
println_ts(util.c("UI error: ", message))
|
||||||
|
Loading…
Reference in New Issue
Block a user