Some of the nodes in Plaquette resonate better with an event-based approach than the current frame-by-frame approach. In particular DigitalNodes such as Metro, Alarm, PeakDetector which emit a "1" only at certain frames; or others where we could look at rose(), fell() or changed() conditions.
It would be a great feature to provide support for such events. There are a number of ways on how to do this.
Option 1: Global event function(s)
Allowing use of functions similar to Arduino's serialEvent() or Processing's mouseClicked() eg.
void roseEvent(Node& node) {
if (node == button) ...
}
or
void event(Node& node, EventType type) {
if (node == button && type == ROSE) ...
...
}
To prevent functions from firing all the time, Plaquette could maintain a list of nodes which it listens to eg. Plaquette.listen(button); or something like this.
Option 2: Plaquette-level callbacks
Similar but one directly assigns their own callbacks eg.
Some of the nodes in Plaquette resonate better with an event-based approach than the current frame-by-frame approach. In particular DigitalNodes such as Metro, Alarm, PeakDetector which emit a "1" only at certain frames; or others where we could look at rose(), fell() or changed() conditions.
It would be a great feature to provide support for such events. There are a number of ways on how to do this.
Option 1: Global event function(s)
Allowing use of functions similar to Arduino's
serialEvent()
or Processing'smouseClicked()
eg.or
To prevent functions from firing all the time, Plaquette could maintain a list of nodes which it listens to eg.
Plaquette.listen(button);
or something like this.Option 2: Plaquette-level callbacks
Similar but one directly assigns their own callbacks eg.
Option 3: Node-level callbacks
Similar but callbacks are retained by the nodes themselves: