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' },
|
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' },
|
||||||
device: { name: 'led', driver: 'led', pin: 13 },
|
device: { name: 'led', driver: 'led', pin: 13 },
|
||||||
|
|
||||||
work: function() {
|
work: function(self) {
|
||||||
robot = this
|
|
||||||
|
|
||||||
// we do our thing here
|
// 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) ->
|
initConnections = (connections) ->
|
||||||
console.log "Initializing connections..."
|
console.log "Initializing connections..."
|
||||||
# make sure we're dealing with an Array
|
|
||||||
connections = [].concat connections
|
connections = [].concat connections
|
||||||
for connection in connections
|
for connection in connections
|
||||||
console.log "Initializing connection '#{ connection.name }'..."
|
console.log "Initializing connection '#{ connection.name }'..."
|
||||||
|
@ -36,6 +35,7 @@ module.exports = class Robot
|
||||||
|
|
||||||
initDevices = (devices) ->
|
initDevices = (devices) ->
|
||||||
console.log "Initializing devices..."
|
console.log "Initializing devices..."
|
||||||
|
devices = [].concat devices
|
||||||
for device in devices
|
for device in devices
|
||||||
console.log "Initializing device '#{ device.name }'..."
|
console.log "Initializing device '#{ device.name }'..."
|
||||||
self.deviceTypes[device.name] = new Device(device)
|
self.deviceTypes[device.name] = new Device(device)
|
||||||
|
@ -43,7 +43,8 @@ module.exports = class Robot
|
||||||
start: ->
|
start: ->
|
||||||
@startConnections()
|
@startConnections()
|
||||||
@startDevices()
|
@startDevices()
|
||||||
(@work.bind(self))()
|
#eval("var myled = 'hi';")
|
||||||
|
@work.bind(self)(self)
|
||||||
|
|
||||||
startConnections: ->
|
startConnections: ->
|
||||||
console.log "Starting connections..."
|
console.log "Starting connections..."
|
||||||
|
|
Loading…
Reference in New Issue