-
Notifications
You must be signed in to change notification settings - Fork 0
/
MMM-Hover.js
73 lines (62 loc) · 1.53 KB
/
MMM-Hover.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* global Module */
/* Magic Mirror
* Module: MMM-Hover
*
* By (Dancj) Dan Thayer
* MIT Licensed.
*/
Module.register("MMM-Hover", {
defaults: {
updateInterval: 60000,
retryDelay: 5000,
i2cAddress: null,
i2cBus: 0,
pinTs: null,
pinReset: null,
defaultRate: 10,
pollRate: 0,
debug: false,
triggeredEvents: { // TODO: trigger multiple events from the same event
tap: {
north: "",
south: "",
west: "PAGE_DECREMENT",
east: "PAGE_INCREMENT",
center: ""
},
swipe: {
up: "",
down: "",
left: "PAGE_DECREMENT",
right: "PAGE_INCREMENT"
}
}
},
requiresVersion: "2.1.0", // Required version of MagicMirror
start: function() {
var self = this;
this.sendSocketNotification("CONFIG", this.config);
Log.info("Starting module: " + this.name);
// TODO: show DOM message?
},
notificationReceived: function (notification, payload, sender) {
// do nothing
},
// socketNotificationReceived from helper
socketNotificationReceived: function (notification, payload) {
if(notification === "SWIPE") {
var event = this.config.triggeredEvents.swipe[payload];
Log.info("Hover detected Swipe in direction: " + payload + ", triggering: " + event);
if (event) {
// report out to listeners
this.sendNotification(event, "");
}
} else if (notification === "TAP") {
var event = this.config.triggeredEvents.tap[payload];
Log.info("Hover detected Tap at position: " + payload + ", triggering" + event);
if (event) {
this.sendNotification(event, "");
}
}
}
});