Suggestion - modify grid.lua to store the number of rows and cols available in the vport object.
The following seems to work (on a quick test)
Grid.vport = {}
for i=1,4 do
Grid.vport[i] = {
name = "none",
callbacks = {},
index = 0,
led = function() end,
all = function() end,
refresh = function() end,
cols = 0,
rows = 0,
attached = false
}
end
and
function Grid.new(id, serial, name, dev)
local g = setmetatable({}, Grid)
g.id = id
g.serial = serial
name = name .. " " .. serial
while tab.contains(Grid.list,name) do
name = name .. "+"
end
g.name = name
g.dev = dev -- opaque pointer
g.key = nil -- key event callback
g.remove = nil -- device unplug callback
g.rows = grid_rows(dev)
g.cols = grid_cols(dev)
g.ports = {} -- list of virtual ports this device is attached to
-- autofill next postiion
local connected = {}
for i=1,4 do
table.insert(connected, Grid.vport[i].name)
table.insert(connected, Grid.vport[i].cols)
table.insert(connected, Grid.vport[i].rows)
end
if not tab.contains(connected, name) then
for i=1,4 do
if Grid.vport[i].name == "none" then
Grid.vport[i].name = name
Grid.vport[i].cols = grid_cols(dev)
Grid.vport[i].rows = grid_rows(dev)
break
end
end
end
return g
end
Suggestion - modify
grid.lua
to store the number of rows and cols available in the vport object.The following seems to work (on a quick test)
and