Skip to content

Commit

Permalink
Merge pull request #32 from vhbfernandes/master
Browse files Browse the repository at this point in the history
added christmas tree patroling command
  • Loading branch information
mintuz authored Dec 5, 2018
2 parents b29a80f + 91caaba commit 8846e7f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ bb8.executeCustomCommand(filePath, {colour: '#000000'});
* [@citypaul](http://twitter.com/paulhammond)
* [@sud-puth](http://twitter.com/sud_)
* [@saraford](http://twitter.com/saraford)
* [@veaga](http://twitter.com/veaga)

# Want to contribute?

Expand Down
16 changes: 16 additions & 0 deletions commands/christmaspatrol.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var _ = require('lodash')
module.exports = function (bb8,options) {
var radius = options.radius; //mm
var distance = 2*Math.PI*radius;
var colors = ["red","green"];
var angle_counter = 0;
var direction = 30;
return setInterval(function() {
bb8.roll(Math.floor(distance/12),direction*angle_counter);
bb8.color(_.sample(colors));
angle_counter++;
if (angle_counter>11) {
angle_counter = 0;
}
}, 500);
};

0 comments on commit 8846e7f

Please sign in to comment.