From c5392f3e192fcf534bcb6f2846afd054cabfb8b1 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Fri, 25 Oct 2013 00:43:59 -0700 Subject: [PATCH] The examples shown at js.la --- examples/hello.js | 2 +- examples/sphero.coffee | 21 +-------------------- examples/sphero_color.coffee | 8 +------- examples/sphero_multiple.coffee | 14 +++++--------- 4 files changed, 8 insertions(+), 37 deletions(-) diff --git a/examples/hello.js b/examples/hello.js index 1a25afc..69c4c55 100644 --- a/examples/hello.js +++ b/examples/hello.js @@ -1,4 +1,4 @@ -var Cylon = require('..').instance(); +var Cylon = require('..'); Cylon.robot({ connection: { name: 'looped', adaptor: 'loopback'}, diff --git a/examples/sphero.coffee b/examples/sphero.coffee index 237f106..c97303a 100644 --- a/examples/sphero.coffee +++ b/examples/sphero.coffee @@ -8,26 +8,7 @@ Cylon.robot name: 'sphero', driver: 'sphero' work: (me) -> - - me.sphero.on 'close', (data) -> - Logger.info 'THIS IS ME CLOSSING:' - Logger.info data - - me.sphero.on 'message', (data) -> - Logger.info 'message:' - Logger.info data - - me.sphero.on 'notification', (data) -> - Logger.info 'notification:' - Logger.info data - - me.sphero.detectCollisions() - - color = 0x000050 every 1.second(), -> - me.sphero.roll(60, Math.floor(Math.random() * 360), 1) - me.sphero.setRGB(color, true) - color += 0x005000 - color = 0x000050 if color > 0xFFFFFF + me.sphero.roll 60, Math.floor(Math.random() * 360) .start() diff --git a/examples/sphero_color.coffee b/examples/sphero_color.coffee index c8018b1..6e50b43 100644 --- a/examples/sphero_color.coffee +++ b/examples/sphero_color.coffee @@ -8,13 +8,7 @@ Cylon.robot name: 'sphero', driver: 'sphero' work: (me) -> - me.nextColor = -> - @color ?= 0x000050 - @color += 0x005000 - @color = 0x000050 if @color > 0xFFFFFF - @color - every 1.second(), -> - me.sphero.setRGB me.nextColor() + me.sphero.setRGB Math.floor(Math.random() * 100000) .start() diff --git a/examples/sphero_multiple.coffee b/examples/sphero_multiple.coffee index c1512e7..b6ee42e 100644 --- a/examples/sphero_multiple.coffee +++ b/examples/sphero_multiple.coffee @@ -12,20 +12,16 @@ SpheroRobot = device: name: 'sphero', driver: 'sphero' - work: (self) -> - color = 0x000050 - every 1.second(), -> - #me.sphero.roll(60, Math.floor(Math.random() * 360), 1) - Logger.info self.name - self.sphero.setRGB(color, true) - color += 0x005000 - color = 0x000050 if color > 0xFFFFFF + work: (me) -> + every 1.seconds(), -> + Logger.info me.name + me.sphero.setRGB Math.floor(Math.random() * 100000) + me.sphero.roll 60, Math.floor(Math.random() * 360) for bot in bots robot = Object.create(SpheroRobot) robot.connection.port = bot.port robot.name = bot.name - Cylon.robot robot Cylon.start()