"use strict";
var Cylon = require("cylon");
Cylon
.robot()
.connection("sphero", { adaptor: "sphero", port: "/dev/rfcomm0" })
.device("sphero", { driver: "sphero" })
.on("ready", function(bot) {
var color = 0x00FF00,
bitFilter = 0xFFFF00;
console.log("Setting up Collision Detection...");
bot.sphero.on("dataStreaming", function(data) {
console.log("data:");
console.log(data);
});
bot.sphero.on("collision", function() {
console.log("Collision:");
color = color ^ bitFilter;
console.log("Color: " + (color.toString(16)) + " ");
bot.sphero.color(color);
bot.sphero.roll(128, Math.floor(Math.random() * 360));
});
var opts = {
n: 40,
m: 1,
pcnt: 0,
dataSources: ["velocity", "odomoter"]
};
bot.sphero.setDataStreaming(opts);
bot.sphero.detectCollisions();
bot.sphero.color(color);
});
Cylon.start();