This repository has been archived by the owner on Dec 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from orbotix/feature/promises-dual-interface
- Loading branch information
Showing
11 changed files
with
374 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use strict"; | ||
|
||
var sphero = require("../"); | ||
var orb = sphero(process.env.PORT); | ||
|
||
orb.connect().then(function() { | ||
return orb.color("FF00FF"); | ||
}).then(function() { | ||
return orb.getBluetoothInfo(); | ||
}).then(function(data) { | ||
console.log("bluetoothInfo:"); | ||
console.log(" name:", data.name); | ||
console.log(" btAddress:", data.btAddress); | ||
console.log(" separator:", data.separator); | ||
console.log(" colors:", data.colors); | ||
}).catch(function(err) { | ||
console.error("err:", err); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
|
||
var sphero = require("../"); | ||
var orb = sphero(process.env.PORT); | ||
|
||
orb.connect().then(orb.detectCollisions).then(function() { | ||
return orb.color("green"); | ||
}).then(function() { | ||
return orb.roll(155, 0); | ||
}); | ||
|
||
orb.on("collision", function(data) { | ||
console.log("collision detected"); | ||
console.log(" data:", data); | ||
|
||
orb.color("red").delay(100).then(function() { | ||
return orb.color("green"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"use strict"; | ||
|
||
var sphero = require("../"); | ||
var orb = sphero(process.env.PORT); | ||
|
||
orb.connect().then(function() { | ||
return orb.color({ red: 255, green: 0, blue: 255 }); | ||
}).delay(1000).then(function() { | ||
console.log("color 1"); | ||
// sets color to the provided hex value | ||
return orb.color(0xff0000); | ||
}).delay(1000).then(function() { | ||
console.log("color 2"); | ||
// hex numbers can also be passed in strings | ||
return orb.color("00ff00"); | ||
}).delay(1000).then(function() { | ||
console.log("color 3"); | ||
// sets color to the provided color name | ||
return orb.color("magenta"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use strict"; | ||
|
||
var sphero = require("../"); | ||
var orb = sphero(process.env.PORT); | ||
|
||
orb.connect().then(function() { | ||
// roll orb in a random direction, changing direction every second | ||
setInterval(function() { | ||
var direction = Math.floor(Math.random() * 360); | ||
orb.roll(150, direction); | ||
}, 1000); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.