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

Fixes to grid reconnect, cols and rows, midi attached status. #568

Merged
merged 1 commit into from Sep 30, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

fixes to grid reconnect, cols and rows, midi attached status.

  • Loading branch information
markwheeler committed Sep 30, 2018
commit 42154c79351ccaf3c2651464dbfe94aef1721222
@@ -51,15 +51,11 @@ function Grid.new(id, serial, name, dev)
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
@@ -120,6 +116,8 @@ function Grid.connect(n)
local d = {
index = Grid.vport[n].index,
port = n,
cols = function() return Grid.vport[n].cols end,
rows = function() return Grid.vport[n].rows end,
event = function(x,y,z)
print("grid input")
end,
@@ -128,7 +126,9 @@ function Grid.connect(n)
all = function(val) Grid.vport[n].all(val) end,
refresh = function() Grid.vport[n].refresh() end,
disconnect = function(self)
self.send = function() print("not connected") end
self.led = function() end
self.all = function() end
self.refresh = function() print("refresh: grid not connected") end
Grid.vport[self.port].callbacks[self.index] = nil
self.index = nil
self.port = nil
@@ -138,12 +138,16 @@ function Grid.connect(n)
if self.index then
Grid.vport[self.port].callbacks[self.index] = nil
end
self.send = function(data) Grid.vport[p].send(data) end
attached = function() return Grid.vport[p].attached end
self.attached = function() return Grid.vport[p].attached end
self.led = function(x,y,z) Grid.vport[p].led(x,y,z) end
self.all = function(val) Grid.vport[p].all(val) end
self.refresh = function() Grid.vport[p].refresh() end
Grid.vport[p].index = Grid.vport[p].index + 1
self.index = Grid.vport[p].index
self.port = p
Grid.vport[p].callbacks[self.index] = function(data) self.event(data) end
self.cols = function() return Grid.vport[p].cols end
self.rows = function() return Grid.vport[p].rows end
Grid.vport[p].callbacks[self.index] = function(x,y,z) self.event(x,y,z) end
end
}

@@ -173,8 +177,12 @@ function Grid.update_devices()
Grid.vport[i].led = function(x, y, val) end
Grid.vport[i].all = function(val) end
Grid.vport[i].refresh = function() end
Grid.vport[i].cols = 0
Grid.vport[i].rows = 0
for _,device in pairs(Grid.devices) do
if device.name == Grid.vport[i].name then
Grid.vport[i].cols = device.cols
Grid.vport[i].rows = device.rows
Grid.vport[i].led = function(x, y, val) device:led(x, y, val) end
Grid.vport[i].all = function(val) device:all(val) end
Grid.vport[i].refresh = function() device:refresh() end
@@ -109,7 +109,7 @@ function Midi.connect(n)
Midi.vport[self.port].callbacks[self.index] = nil
end
self.send = function(data) Midi.vport[p].send(data) end
attached = function() return Midi.vport[p].attached end
self.attached = function() return Midi.vport[p].attached end
Midi.vport[p].index = Midi.vport[p].index + 1
self.index = Midi.vport[p].index
self.port = p
ProTip! Use n and p to navigate between commits in a pull request.