-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMMM-WS281X-Server.js
More file actions
65 lines (58 loc) · 1.91 KB
/
Copy pathMMM-WS281X-Server.js
File metadata and controls
65 lines (58 loc) · 1.91 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
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
Module.register('MMM-WS281X-Server',{
defaults: {
hostname: '127.0.0.1',
port: 9999,
ledOnStart: false,
ledOnStartEffect: 'start',
showAlert: false,
showAlertEffect: 'alert',
useMMMFaceRecoDNN: false,
userLoginEffect: 'login',
userLogoutEffect: 'logout',
channel: 1,
led_count: 24,
led_type: 0,
invert: 0,
global_brightness: 255,
gpionum: 18,
spi: false,
spi_dev: '/dev/spidev0.0',
spi_speed: 20,
alt_spi_pin: 10,
listenNotifications: []
},
start: function() {
Log.info('[' + this.name + '] Starting');
this.sendSocketNotification('init', this.config);
},
notificationReceived: function(notification, payload) {
switch(notification) {
case 'SHOW_ALERT':
// LED effect on alerts shown in the UI:
if (this.config.showAlert) {
this.sendSocketNotification('alert', this.config);
}
break;
case 'USERS_LOGIN':
// LED effect support for MMMFaceRecoDNN Module:
if (this.config.useMMMFaceRecoDNN) {
this.sendSocketNotification('login', this.config);
}
break;
case 'USERS_LOGOUT':
case 'USERS_LOGOUT_MODULES':
// LED effect support for MMMFaceRecoDNN Module:
if (this.config.useMMMFaceRecoDNN) {
this.sendSocketNotification('logout', this.config);
}
break;
} // end switch
for (const notif of this.config.listenNotifications) {
notifName = notif.notification;
if (notification === notifName) {
text = notif.text;
this.sendSocketNotification('command', text);
}
}
}
});