Knowledge of self when working
This commit is contained in:
parent
1f93cee823
commit
03febed1bb
|
@ -5,11 +5,10 @@ var robot = cylon.robot({
|
|||
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' },
|
||||
device: { name: 'led', driver: 'led', pin: 13 },
|
||||
|
||||
work: function() {
|
||||
robot = this
|
||||
|
||||
work: function(self) {
|
||||
// we do our thing here
|
||||
every((1).second(), function() { console.log(robot.led.name); });
|
||||
console.log(self.led.name);
|
||||
every((1).second(), function() { console.log(self.led.name); });
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ module.exports = class Robot
|
|||
|
||||
initConnections = (connections) ->
|
||||
console.log "Initializing connections..."
|
||||
# make sure we're dealing with an Array
|
||||
connections = [].concat connections
|
||||
for connection in connections
|
||||
console.log "Initializing connection '#{ connection.name }'..."
|
||||
|
@ -36,6 +35,7 @@ module.exports = class Robot
|
|||
|
||||
initDevices = (devices) ->
|
||||
console.log "Initializing devices..."
|
||||
devices = [].concat devices
|
||||
for device in devices
|
||||
console.log "Initializing device '#{ device.name }'..."
|
||||
self.deviceTypes[device.name] = new Device(device)
|
||||
|
@ -43,7 +43,8 @@ module.exports = class Robot
|
|||
start: ->
|
||||
@startConnections()
|
||||
@startDevices()
|
||||
(@work.bind(self))()
|
||||
#eval("var myled = 'hi';")
|
||||
@work.bind(self)(self)
|
||||
|
||||
startConnections: ->
|
||||
console.log "Starting connections..."
|
||||
|
|
Loading…
Reference in New Issue