#340 colorblind modes for rtu, reactor-plc, and supervisor
This commit is contained in:
@@ -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 = "<not set>" end
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user