-
Notifications
You must be signed in to change notification settings - Fork 1
/
MMM-IT8951.js
executable file
·55 lines (50 loc) · 1.89 KB
/
MMM-IT8951.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
/**
* This MagicMirror² module communicates with a IT8951 card to display MagicMirror² on a e-ink screen using IT8951 drivers.
* @module MMM-IT8951
* @class Module
* @see `README.md`
* @author Sébastien Mazzon
* @license MIT - @see `LICENCE.txt`
*/
"use strict";
Module.register("MMM-IT8951", {
/**
* Default properties of the module
* @see `module.defaults`
* @see <https://docs.magicmirror.builders/development/core-module-file.html#defaults>
*/
defaults: {
/* Display configuration */
updateInterval: 60 * 1000, // Full refresh screen interval - default to 1 minute
bufferDelay: 1000, // Delay before accounting updated items that have not an instant refresh rate on screen - default to 1 second
defaultTo4levels: false,
/* Driver configuration */
mock: false, // Use a true IT8951 card or mock interface
driverParam: { MAX_BUFFER_SIZE: 4096, ALIGN4BYTES: true, VCOM: 1480 }, // see https://github.com/gaweee/node-it8951#functions-calls
},
/**
* Called by the MagicMirror² core when a notification arrives.
*
* @param {string} notification The identifier of the notification.
* @param {*} payload The payload of the notification.
* @param {Module} sender The module that sent the notification.
*/
notificationReceived: function (notification, payload, sender) {
if (notification === "DOM_OBJECTS_CREATED") {
// Initializes node helper
this.sendSocketNotification("CONFIG", this.config);
} else if (notification === "IT8951_ASK_FULL_REFRESH") {
// Full refresh of screen (payload is a boolean to have update screen with the 16-levels)
this.sendSocketNotification(notification, payload);
}
},
/**
* Returns the CSS files adding gray levels to root
* @see `module.getStyles`
* @see <https://docs.magicmirror.builders/development/core-module-file.html#getstyles>
* @returns {Array}
*/
getStyles: function () {
return [`${this.name}.css`];
},
});