Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MMM-EasyPix.js 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Magic Mirror
  2. * Module: MMM-EasyPix
  3. *
  4. * By Mykle1
  5. * MIT Licensed.
  6. */
  7. Module.register("MMM-EasyPix", {
  8. defaults: {
  9. picName: "face.gif", // .jpg, .gif, .png, etc.. (animated gif's too!)
  10. maxWidth: "100%", // your picture files go in "pix" folder of module
  11. sounds: ["1.mp3", "me2.mp3"], // mp3 sound file names in quotes seperated by commas
  12. updateInterval: 30 * 60 * 1000, // updates display
  13. animationSpeed: 3000,
  14. },
  15. start: function() {
  16. var self = this;
  17. this.url = '';
  18. // ADDED: Schedule update timer courtesy of ninjabreadman
  19. var self = this;
  20. setInterval(function() {
  21. self.updateDom(self.config.animationSpeed || 0); // use config.animationSpeed or revert to zero @ninjabreadman
  22. }, this.config.updateInterval);
  23. },
  24. getStyles: function() {
  25. return ["MMM-EasyPix.css"]
  26. },
  27. // Override dom generator.
  28. getDom: function() {
  29. var wrapper = document.createElement("div");
  30. var image = document.createElement("img");
  31. image.src = '/modules/MMM-EasyPix/pix/' + this.config.picName + "?seed=" + new Date();
  32. image.className = "photo";
  33. image.style.maxWidth = this.config.maxWidth;
  34. wrapper.appendChild(image);
  35. return wrapper;
  36. },
  37. random_imglink: function (){
  38. var myimages = new Array()
  39. var myimages = '/modules/MMM-EasyPix/pix/';
  40. var ry = Math.floor(Math.random()*'/modules/MMM-EasyPix/pix/'.length)
  41. if (ry==0) {
  42. ry=1;
  43. }
  44. document.write('<img src="'+myimages[ry]+'" border=0>');
  45. return random_imglink;
  46. },
  47. ///// Add this function to the modules you want to control with voice //////
  48. ///// Must be the same as in "sentences" array in MMM-voice.js /////
  49. ///// Replace sound file with your own greeting /////
  50. notificationReceived: function(notification, payload) {
  51. if (notification === 'HIDE_LUCY') {
  52. this.hide(500);
  53. } else if (notification === 'SHOW_LUCY') {
  54. this.show(1000);
  55. }
  56. if (notification === 'HELLO_THERE_LUCY') {
  57. var sound = new Audio();
  58. sound.src = 'modules/MMM-EasyPix/hello.mp3';
  59. sound.play();
  60. }
  61. ///////// So you don't hear the same greeting every time /////////////////////////
  62. ////////// Randomized sound files courtesy of @ Cowboysdude ////////////////////////
  63. if (notification === 'SHOW_LUCY') {
  64. var audio_files = this.config.sounds;
  65. var random_file = audio_files[Math.floor(Math.random() * audio_files.length)];
  66. var audio = new Audio(random_file);
  67. audio.src = 'modules/MMM-EasyPix/sounds/'+random_file;
  68. audio.play();
  69. }
  70. },
  71. });