#149 validate display sizes on startup

This commit is contained in:
Mikayla Fischler 2023-02-03 15:19:00 -05:00
parent 53e4576547
commit 72791d042b
4 changed files with 43 additions and 3 deletions

View File

@ -1,4 +1,5 @@
local log = require("scada-common.log")
local util = require("scada-common.util")
local style = require("coordinator.ui.style")
@ -85,6 +86,29 @@ function renderer.reset(recolor)
end
end
-- check main display width
---@return boolean width_okay
function renderer.validate_main_display_width()
local w, _ = engine.monitors.primary.getSize()
return w == 164
end
-- check display sizes
---@return boolean valid all unit display dimensions OK
function renderer.validate_unit_display_sizes()
local valid = true
for id, monitor in pairs(engine.monitors.unit_displays) do
local w, h = monitor.getSize()
if w ~= 79 or h ~= 52 then
log.warning(util.c("unit ", id, " display resolution not 79 wide by 52 tall: ", w, ", ", h))
valid = false
end
end
return valid
end
-- initialize the dmesg output window
function renderer.init_dmesg()
local disp_x, disp_y = engine.monitors.primary.getSize()

View File

@ -19,7 +19,7 @@ local iocontrol = require("coordinator.iocontrol")
local renderer = require("coordinator.renderer")
local sounder = require("coordinator.sounder")
local COORDINATOR_VERSION = "beta-v0.8.13"
local COORDINATOR_VERSION = "beta-v0.8.14"
local print = util.print
local println = util.println
@ -84,13 +84,25 @@ local function main()
return
end
log.info("monitors ready, dmesg output incoming...")
-- init renderer
renderer.set_displays(monitors)
renderer.reset(config.RECOLOR)
if not renderer.validate_main_display_width() then
println("boot> main display must be 8 blocks wide")
log.fatal("main display not wide enough")
return
elseif not renderer.validate_unit_display_sizes() then
println("boot> one or more unit display dimensions incorrect; they must be 4x4 blocks")
log.fatal("unit display dimensions incorrect")
return
end
renderer.init_dmesg()
-- lets get started!
log.info("monitors ready, dmesg output incoming...")
log_graphics("displays connected and reset")
log_sys("system start on " .. os.date("%c"))
log_boot("starting " .. COORDINATOR_VERSION)

View File

@ -35,6 +35,8 @@ local period = core.flasher.PERIOD
---@param x integer top left x
---@param y integer top left y
local function new_view(root, x, y)
assert(root.height() >= (y + 24), "main display not of sufficient vertical resolution (add an additional row of monitors)")
local facility = iocontrol.get_db().facility
local units = iocontrol.get_db().units

View File

@ -39,6 +39,8 @@ local function make(parent, x, y, unit)
height = 25
end
assert(parent.height() >= (y + height), "main display not of sufficient vertical resolution (add an additional row of monitors)")
-- bounding box div
local root = Div{parent=parent,x=x,y=y,width=80,height=height}