Skip to content

Instantly share code, notes, and snippets.

@7yl4r
Created April 9, 2015 18:53
Show Gist options
  • Save 7yl4r/3944a2d750697ddadabb to your computer and use it in GitHub Desktop.
Save 7yl4r/3944a2d750697ddadabb to your computer and use it in GitHub Desktop.
noflo square wave generator component?
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