Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jancalve@gmail.com committed Nov 9, 2019
1 parent 272cb17 commit 3bfb841
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 45 deletions.
29 changes: 2 additions & 27 deletions MMM-flick-gestures.js
Expand Up @@ -17,44 +17,19 @@ Module.register("MMM-flick-gestures",{
requiresVersion: '2.1.0',

defaults: {
text: "Hello World!"
},

// Override dom generator.
getDom: function() {
console.log('getDom()');
Log.log('getDom()');
var wrapper = document.createElement("div");
wrapper.innerHTML = this.config.text;
return wrapper;
},
start: function() {
console.log('start()');
Log.log('start()');
this.mySpecialProperty = "So much wow!";
Log.log(this.name + ' is started!');
this.sendSocketNotification("INIT", this.config)
this.sendSocketNotification("INIT", this.config)
},
socketNotificationReceived: function(notification, payload) {

Log.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
this.sendNotification(notification);
}
});


/*
pyshell.on('message', function (message) {
// relay event to modules
Log.log(message);
console.log(message);
});
pyshell.end(function (err) {
if (err){
throw err;
};
Log.log('flick finished');
console.log('finished');
});
*/
});
29 changes: 11 additions & 18 deletions node_helper.js
Expand Up @@ -7,7 +7,6 @@ let options = {
mode: 'text',
pythonPath: '/usr/bin/python',
pythonOptions: ['-u'], // get print results in real-time
// scriptPath: '',
args: []
};

Expand All @@ -16,55 +15,49 @@ let options = {
module.exports = NodeHelper.create({

start: function () {
console.log("[GESTURE] Starting...")
this.config = {}
this.gestureSequence = ""
this.commandTimer = null
this.shell = null
},

stop: function () {
this.log("[GESTURE] Finishing...")
console.log("[GESTURE] Stopping...")
if (this.shell) {
this.shell.end()
}
},

socketNotificationReceived: function (noti, payload) {

this.job(payload)


},

log: function (obj) {
// if (this.config.verbose) {
console.log(obj)
// }
},

job: function (config) {
var me = this;
console.log('I got a job!');
var pyshell = new PythonShell(myPythonScriptPath, options);
pyshell.on('message', function (message) {
// relay event to modules
// console.log(message);
console.log(message);
if (message === 'west - east') {
// console.log('Sending page dec.');
me.sendSocketNotification("PAGE_DECREMENT");
}
else if (message === 'north - south') {
me.sendSocketNotification("PAGE_DECREMENT");
}
else if (message === 'south - north') {
me.sendSocketNotification("PAGE_INCREMENT");
}
else if (message === 'east - west') {
//console.log('Sending page inc.');
me.sendSocketNotification("PAGE_INCREMENT");

}
}
});

pyshell.end(function (err) {
if (err) {
throw err;
}
console.log('finished');
console.log('pyShell finished with err ' + err);
});

}
Expand Down

0 comments on commit 3bfb841

Please sign in to comment.