Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rows and cols to grid.vport #552

Closed
okyeron opened this issue Sep 16, 2018 · 2 comments
Closed

Add rows and cols to grid.vport #552

okyeron opened this issue Sep 16, 2018 · 2 comments

Comments

@okyeron
Copy link
Contributor

@okyeron okyeron commented Sep 16, 2018

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
@tehn
Copy link
Member

@tehn tehn commented Sep 18, 2018

want to submit a PR? this idea seems good

@okyeron
Copy link
Contributor Author

@okyeron okyeron commented Sep 18, 2018

@okyeron okyeron closed this Sep 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants