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

What happened to attached for devices? #843

Closed
okyeron opened this issue Jun 17, 2019 · 6 comments
Closed

What happened to attached for devices? #843

okyeron opened this issue Jun 17, 2019 · 6 comments

Comments

@okyeron
Copy link
Contributor

@okyeron okyeron commented Jun 17, 2019

Some time back in 1.0 grid and midi devices could be checked if attached - Study 4 specifically uses this.

Now I'm searching all the code and can't find it at all.

What happened here? Did this get tossed for some other better way to determine if a device is connected?

@artfwo
Copy link
Member

@artfwo artfwo commented Jun 17, 2019

Yes, I think I removed that property when cleaning up vport library, you can use vport.device ~= nil instead.

@neauoire
Copy link

@neauoire neauoire commented Jun 17, 2019

Could I ask for it to be added back? Not a big fan of vport.device ~= nil as replacement.

@artfwo
Copy link
Member

@artfwo artfwo commented Jun 17, 2019

That would be a flag which does nothing but being a duplicate of vport.device ~= nil, a potential source of problems if we forget to update it. You can use vport.device as a shortcut, which will evaluate to true, if the device is attached.

@neauoire
Copy link

@neauoire neauoire commented Jun 17, 2019

Maybe I'm not exactly sure how to use it then, first time I hear of vport. I just want to check if the grid is connected to the norns. It's currently connected:

g = grid.connect()
g.key = on_grid_key
g.add = on_grid_add
g.remove = on_grid_remove

print(vport) # nil
print(g.vport) # nil
print(grid.vport) # nil
print(norns.vport) # nil
@artfwo
Copy link
Member

@artfwo artfwo commented Jun 17, 2019

Right, grid.connect(x) returns a vport instance, see https://github.com/monome/norns/blob/master/lua/core/grid.lua#L107

Currently scripts only deal with vports (assigned in devices menu), and we connect to them using grid.connect. A vport instance keeps a reference to the physical device, in your example above that would be g.device.

Hope this helps!

@neauoire
Copy link

@neauoire neauoire commented Jun 17, 2019

That's actually excellent, sorry for my confusion earlier.

@okyeron okyeron closed this Jun 18, 2019
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
3 participants