Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 15 additions and 7 deletions.
  1. +3 −1 browser/control.js
  2. +1 −1  lib/detect.js
  3. +11 −5 server.js
View
4 browser/control.js
@@ -23,11 +23,13 @@ module.exports = function (client) {
shift_down: function (n) { ctrl.a(-1 * n) },
shift_t: function (n) {
- client.takeoff(1 * n)
client.disableEmergency()
+ client.takeoff(1 * n)
},
shift_l: function (n) { client.land(1 * n) },
+ f: function (n) { if (n) client.animate('flipLeft', 15) },
+
}
window.addEventListener('keydown', function (ev) {
View
2  lib/detect.js
@@ -22,5 +22,5 @@ module.exports = function (w, h, buf) {
matches ++;
}
}
- return matches > 350;
+ return matches > 400;
};
View
16 server.js
@@ -50,27 +50,33 @@ png.on('error', function (err) {
console.error('caught error ' + err);
});
-var last = 0;
+var last = { frame : 0, detect : 0 };
var detected = false;
png.on('data', function (buf) {
- if (Date.now() - last < 1000) return;
- last = Date.now();
+ if (Date.now() - last.frame >= 100) {
+ emitter.emit('image', buf.toString('base64'));
+ last.frame = Date.now();
+ }
- emitter.emit('image', buf.toString('base64'));
+ if (Date.now() - last.detect < 1000) return;
+ last.detect = Date.now();
if (!redMode) return;
if (detected) return;
- if (detect(640, 360, buf)) {
+ if (detect(640 / 2, 360 / 2, buf)) {
detected = true;
emitter.emit('red');
console.log(Date.now());
client.front(1);
+ client.animateLeds('fire', 5, 1000);
setTimeout(function () {
client.front(0);
+ client.animateLeds('standard', 1, 1000);
+
emitter.emit('unred');
detected = false;
}, 1000);

No commit comments for this range

Something went wrong with that request. Please try again.