forked from evancohen/smart-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmotion.js
More file actions
37 lines (31 loc) · 1.11 KB
/
Copy pathmotion.js
File metadata and controls
37 lines (31 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict'
// Load in smart mirror config
const config = require(__dirname + "/config.js")
if(!config || !config.motion || !config.motion.enabled || !config.motion.pin || !config.language){
console.log("!E:","Configuration Error! See: https://docs.smart-mirror.io/docs/configure_the_mirror.html#motion")
}
if (config.motion.enabled) {
// Configure johnny-five
var five = require('johnny-five');
var Raspi = require("raspi-io");
var board = new five.Board({
io: new Raspi()
});
board.on("ready",function() {
var motion = new five.Motion(config.motion.pin);
// "calibrated" occurs once, at the beginning of a session,
motion.on("calibrated", function() {
console.log("!c:","calibrated");
});
// "motionstart" events are fired when the "calibrated"
// proximal area is disrupted, generally by some form of movement
motion.on("motionstart", function() {
console.log("!s:","motionstart");
});
// "motionend" events are fired following a "motionstart" event
// when no movement has occurred in X ms
motion.on("motionend", function() {
console.log("!e:","motionend");
});
});
}