Skip to content

Instantly share code, notes, and snippets.

@antonhornquist
Last active August 19, 2016 14:06
Show Gist options
  • Save antonhornquist/3f8fbaeefa299a093f246cc3a4d585cd to your computer and use it in GitHub Desktop.
Save antonhornquist/3f8fbaeefa299a093f246cc3a4d585cd to your computer and use it in GitHub Desktop.
(
var app = \toggle;
var state;
var update;
var client;
~disposeApp.();
state=Ref(Archive.global.at(\apps, app, \value) ? true);
update = { client.ledSet(0, 0, a.value) };
state.addDependant(update);
client = SerialOSCClientApp.grid(app);
client.onGridRefreshed = {
SerialOSCGrid.clearLeds; // TODO: could be implied
update.();
};
client.onGridKey = { |x, y, state|
if ((x@y == 0@0) and: state) {
state.set(state.get.not).changed
}
};
~disposeApp = {
client.free;
Archive.global.put(\apps, app, \value, state.dereference);
if (CmdPeriod.objects.includes(~disposeApp)) { CmdPeriod.remove(~disposeApp) };
~disposeApp = nil;
};
CmdPeriod.doOnce(~disposeApp);
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment