Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mykle1 committed Nov 8, 2018
1 parent 4706804 commit c164e1d
Showing 1 changed file with 44 additions and 43 deletions.
87 changes: 44 additions & 43 deletions MMM-EasyPix.js
Expand Up @@ -10,52 +10,55 @@ Module.register("MMM-EasyPix", {
picName: "face.gif", // .jpg, .gif, .png, etc.. (animated gif's too!)
maxWidth: "100%", // your picture files go in "pix" folder of module
sounds: ["1.mp3", "me2.mp3"], // mp3 sound file names in quotes seperated by commas
updateInterval: 60 * 1000, // updates display
animationSpeed: 1000,
},
updateInterval: 30 * 60 * 1000, // updates display
animationSpeed: 3000,
},

start: function() {
self = this;
this.url = '';
this.scheduleUpdate();
if (this.config.picName != '') {
this.url = "modules/MMM-EasyPix/pix/" + this.config.picName;

}
var self = this;
this.url = '';

// ADDED: Schedule update timer courtesy of ninjabreadman
var self = this;
setInterval(function() {
self.updateDom(self.config.animationSpeed || 0); // use config.animationSpeed or revert to zero @ninjabreadman
}, this.config.updateInterval);
},



getStyles: function() {
return ["MMM-EasyPix.css"]
},

scheduleUpdate: function() {
setInterval(() => {
this.updateDom(); // this.getDom(); @cbd
// console.log(this.updateDom); // for checking
},
this.config.updateInterval);
},






// Override dom generator.
getDom: function() {
var wrapper = document.createElement("div");
var image = document.createElement("img");
if (this.config.picName != '') {
image.src = this.url;
image.src = '/modules/MMM-EasyPix/pix/' + this.config.picName + "?seed=" + new Date();
image.className = "photo";
image.style.maxWidth = this.config.maxWidth;
}



wrapper.appendChild(image);

return wrapper;
},


random_imglink: function (){
var myimages = new Array()
var myimages = '/modules/MMM-EasyPix/pix/';

var ry = Math.floor(Math.random()*'/modules/MMM-EasyPix/pix/'.length)
if (ry==0) {
ry=1;
}
document.write('<img src="'+myimages[ry]+'" border=0>');

return random_imglink;
},



///// Add this function to the modules you want to control with voice //////
///// Must be the same as in "sentences" array in MMM-voice.js /////
Expand All @@ -67,25 +70,23 @@ Module.register("MMM-EasyPix", {
} else if (notification === 'SHOW_LUCY') {
this.show(1000);
}
// if (notification === 'SHOW_LUCY') {
// var sound = new Audio();
// sound.src = 'modules/MMM-EasyPix/sounds/me2.mp3';
// sound.play();
// }
///////// So you don't hear the same greeting every time /////////////////////////
////////// Randomized sound files courtesy of @ Cowboysdude ////////////////////////

if (notification === 'HELLO_THERE_LUCY') {
var sound = new Audio();
sound.src = 'modules/MMM-EasyPix/hello.mp3';
sound.play();
}
///////// So you don't hear the same greeting every time /////////////////////////
////////// Randomized sound files courtesy of @ Cowboysdude ////////////////////////
if (notification === 'SHOW_LUCY') {
var audio_files = this.config.sounds;
var random_file = audio_files[Math.floor(Math.random() * audio_files.length)];
var audio = new Audio(random_file);
audio.src = 'modules/MMM-EasyPix/sounds/'+random_file;
audio.play();
}

},


});
},


});

0 comments on commit c164e1d

Please sign in to comment.