Last active
August 19, 2016 14:06
-
-
Save antonhornquist/3f8fbaeefa299a093f246cc3a4d585cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
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