Created
April 9, 2015 18:53
-
-
Save 7yl4r/3944a2d750697ddadabb to your computer and use it in GitHub Desktop.
noflo square wave generator component?
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
noflo = require 'noflo' | |
exports.getComponent = -> | |
c = new noflo.Component | |
c.inPorts.add 'low', (event, payload) => | |
@low = payload | |
c.inPorts.add 'high', (event, payload) => | |
@high = payload | |
c.inPorts.add 'dt', (event, payload) => | |
@dt = payload | |
c.inPorts.add 'simConfig', (event, payload) => | |
return unless event is 'data' | |
# config passthrough | |
c.outPorts.simConfig.send payload | |
values = new Array(payload.length) | |
for t of values | |
#start low | |
if t % (2 * @dt) < @dt | |
values[t] = @low | |
else | |
values[t] = @high | |
c.outPorts.out.send values | |
# array of values | |
c.outPorts.add 'out' | |
# config passthrough | |
c.outPorts.add 'simConfig' | |
return c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment