<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Ability to change color by physical button?]]></title><description><![CDATA[<p dir="auto"><em>Sorry if i put this post in the wrong category.</em></p>
<p dir="auto">I have just started to fine-polish the last pieces in the config on my MagicMirror when my better half comes screaming " I want an whiteboard!"<br />
Then the idea came to me that instead of making a mirror, i just use a ordinary glas and use it as an whiteboard. But i dont want it to have a white background all the time…</p>
<p dir="auto">So my question is, is it doable by an physical button/switch to “invert” the colors on the hole layot ?</p>
<p dir="auto">So that the handwritted “Whiteboard-text” is almost hidden when in “MagicMirror-Mode” (Original layot) and with the press of a button or switch the hole layout is inverting, making the background white and text black.</p>
<p dir="auto">I have NO prior knowledge of programming, but i am not afraid to try. But i might need a push in the right direction first :P</p>
<p dir="auto">My first idea involved a script like this:</p>
<p dir="auto">´Push button´<br />
Making it activate a script that replaces ´/css/main.css´ with ´/css/main2.css´ and thereafter sends a ´refresh´command.<br />
Sort of…<br />
<em>( This is my programing abilities ;) )</em></p>
<p dir="auto">Am i reaching for the stars here or is it something that is doable? Maybe there is another solution?</p>
]]></description><link>https://forum.magicmirror.builders/topic/233/ability-to-change-color-by-physical-button</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 02:55:59 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/233.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 Jun 2016 13:00:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ability to change color by physical button? on Fri, 17 Jun 2016 22:11:05 GMT]]></title><description><![CDATA[<p dir="auto"><s>Hi… This can easily be accomplished with some javascript and css. No need to mess with hardware or anything.</s></p>
<p dir="auto">Edit: I guess I should actually read the post. You need a physical button. Disregard lol</p>
]]></description><link>https://forum.magicmirror.builders/post/1737</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/1737</guid><dc:creator><![CDATA[EoF]]></dc:creator><pubDate>Fri, 17 Jun 2016 22:11:05 GMT</pubDate></item><item><title><![CDATA[Reply to Ability to change color by physical button? on Fri, 17 Jun 2016 20:27:07 GMT]]></title><description><![CDATA[<p dir="auto">maybe this will give you a start</p>
<p dir="auto">I added the following lines to MagicMirror/css/custom.css</p>
<pre><code>.male {
	background: black;
	color: blue;
}

.female {
	background: white;
	color: pink;
}
</code></pre>
<p dir="auto">and for testing I edited the clock module (MagicMirror/modules/default/clock/clock.js) because it get’s updated every second.</p>
<p dir="auto">put those lines right after line 69</p>
<pre><code>if(secondsWrapper.innerHTML % 10 == 0){ /*changes class every 10 seconds, because i don't have a button i made this "hack" for testing purposes*/
			var body = document.querySelector('body');
			if(body.classList.contains("male")){
				body.classList.remove("male");
				body.classList.add("female");
			} else {
				body.classList.remove("female");
				body.classList.add("male");
			}
		}
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/1736</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/1736</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Fri, 17 Jun 2016 20:27:07 GMT</pubDate></item><item><title><![CDATA[Reply to Ability to change color by physical button? on Fri, 17 Jun 2016 18:09:26 GMT]]></title><description><![CDATA[<p dir="auto">Thank you Strawberry with everything.<br />
I think i have to give this idea up tho. I have now been sitting for two days trying. But i just cant wrap my head around it. :/<br />
Nothing makes sense for me with JavaScript. Not a single row of code have i been able to write.<br />
Changing ‘fontColor’ is about my level of knowledge :P</p>
]]></description><link>https://forum.magicmirror.builders/post/1734</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/1734</guid><dc:creator><![CDATA[Snoevit]]></dc:creator><pubDate>Fri, 17 Jun 2016 18:09:26 GMT</pubDate></item><item><title><![CDATA[Reply to Ability to change color by physical button? on Wed, 15 Jun 2016 16:21:27 GMT]]></title><description><![CDATA[<p dir="auto">i was to late to edit :pensive:</p>
<pre><code>'use strict';

/* Magic Mirror
 * Module: MMM-PIR-Sensor
 *
 * By Paul-Vincent Roll http://paulvincentroll.com
 * MIT Licensed.
 */

/*import dependencies*/
const NodeHelper = require('node_helper');
const gpio = require('wiring-pi');
const exec = require('child_process').exec;

module.exports = NodeHelper.create({
  /*this method got fired when the core is starting your module helper*/
  start: function () {
    this.started = false
  },
  /*this function will activate your monitor by enabling hdmi output or sending a signal to the relais via gpio pin*/
  activateMonitor: function () {
    /* you don't need the following 3 lines, which would set a signal to the relais specified in the config section of your module of the file above*/
    if (this.config.relayPIN != false) {
      gpio.digitalWrite(this.config.relayPIN, this.config.relayOnState)
    }
    /*after removing the previous 3 lines you also need to change "else if" to "if". the following lines run a command in a child process in the background to enable the hdmi output*/
    else if (this.config.relayPIN == false){
      exec("/opt/vc/bin/tvservice -p", null);
    }
  },
/*this function will deactivate your monitor by disabling hdmi output or sending a signal to the relais via gpio pin*/
  deactivateMonitor: function () {
/* you don't need the following 3 lines, which would set a signal to the relais specified in the config section of your module of the file above*/
    if (this.config.relayPIN != false) {
      gpio.digitalWrite(this.config.relayPIN, this.config.relayOffState)
    }
 /*after removing the previous 3 lines you also need to change "else if" to "if". the following lines run a command in a child process in the background to disable the hdmi output*/
    else if (this.config.relayPIN == false){
      exec("/opt/vc/bin/tvservice -o", null);
    }
  },
  /*here you receive messages which you send via modulename.js*/
  socketNotificationReceived: function(notification, payload) {
    const self = this;
    /*the following part runs when you receive the notification from your module l. 33 on github "this.sendSocketNotification('CONFIG', this.config);"*/
    if (notification === 'CONFIG' &amp;&amp; this.started == false) {
      
      const self = this
      this.config = payload
      
      //Setup pins
      exec("echo '" + this.config.sensorPIN.toString() + "' &gt; /sys/class/gpio/export", null); /*motion sensor pin*/
      exec("echo 'in' &gt; /sys/class/gpio/gpio" + this.config.sensorPIN.toString() + "/direction", null); /*relais pin*/
      /*fllowing lines not important if you're not using relais*/
      if (this.config.relayPIN) {
        exec("echo '" + this.config.relayPIN.toString() + "' &gt; /sys/class/gpio/export", null);
        exec("echo 'out' &gt; /sys/class/gpio/gpio" + this.config.relayPIN.toString() + "/direction", null);
        exec("echo '1' &gt; /sys/class/gpio/gpio" + this.config.relayPIN.toString() + "/value", null);
      }
      
      //Set gpio-mode
      gpio.setup('sys');
      
      //Detected movement
      /*when you detect a movement with your sensor it will run the callback "function(delta){...}"*/
      gpio.wiringPiISR(this.config.sensorPIN, gpio.INT_EDGE_BOTH, function(delta) {
        if (gpio.digitalRead(self.config.sensorPIN) == 1) {
          /* motion detected send the notification to your module*/
          self.sendSocketNotification("USER_PRESENCE", true);
          if (self.config.powerSaving){
            /*activate the monitor again to show the user data on your screen*/
            self.activateMonitor()
          }
        }
        //No movement
        else if (gpio.digitalRead(self.config.sensorPIN) == 0) {
          /*send your module the notification tha there is no user present and deactivate the monitor*/
          self.sendSocketNotification("USER_PRESENCE", false);
          if (self.config.powerSaving){
            self.deactivateMonitor()
          }
        }
      });
     
    this.started = true
    };
  }
  
});
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/1669</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/1669</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Wed, 15 Jun 2016 16:21:27 GMT</pubDate></item><item><title><![CDATA[Reply to Ability to change color by physical button? on Wed, 15 Jun 2016 15:56:03 GMT]]></title><description><![CDATA[<p dir="auto">i hope the following lines can help you to understand it a bit more and that it is explained correctly.</p>
<p dir="auto">this references the module itself</p>
<p dir="auto">so in the module you can do this.sendSocketNotification(…) which will call the function sendsocketnotification of your module (this)</p>
<p dir="auto">also you can follow this guide to develop a module <a href="https://github.com/MichMich/MagicMirror/tree/master/modules" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/MichMich/MagicMirror/tree/master/modules</a></p>
<pre><code>/* Magic Mirror
 * Module: MMM-PIR-Sensor
 *
 * By Paul-Vincent Roll http://paulvincentroll.com
 * MIT Licensed.
 */

/* registers a module with the name MMM-PIR-Sensor in the magic mirror system*/
Module.register('MMM-PIR-Sensor',{
	
        /*config part*/
	defaults: {
		sensorPIN: 22, /*number of pin can be different for raspberry pi version e.g. https://raspilab.files.wordpress.com/2014/08/gpiosb.png*/
		relayPIN: false, /*this is for using relais in this module not needed because you can also set the hdmi output off*/
		powerSaving: true,
		relayOnState: 1, /*not important because you're not using relays*/
	},
	
        /*here you receive messages which you send via node_helper.js*/
	socketNotificationReceived: function(notification, payload) {
		if (notification === "USER_PRESENCE"){
                        /*when you receive the notification user_presence from your node_helper you send a global message with this notification to every module in magic mirror so they can handle this event as well*/
			this.sendNotification(notification, payload)
		}
	},
	
        /*this method got fired when the core is starting your module
	start: function() {
                /* the following 6 lines can be removed if you don't want to use relais. The functionality of these lines is to set relayoffstate depending on the relayonstate defined in the configt section above*/
		if (this.config.relayOnState == 1){
			this.config.relayOffState = 0
		}
		else if (this.config.relayOnState == 0){
			this.config.relayOffState = 1
		}
                /*here you send a notification to your node_helper.js*/
		this.sendSocketNotification('CONFIG', this.config);
                 /*here you print some information to the console, which you can't se without enabling the developer console in the electronh wrapper during runtime*/
		Log.info('Starting module: ' + this.name);
	}
});
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/1667</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/1667</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Wed, 15 Jun 2016 15:56:03 GMT</pubDate></item><item><title><![CDATA[Reply to Ability to change color by physical button? on Wed, 15 Jun 2016 15:29:26 GMT]]></title><description><![CDATA[<p dir="auto">I dont have any code. All this time i have been trying to understand what i am trying to do. If we look at The code from PIR-sensor, i dont know wich line are doing what. I have no clue on how and where to start. I cant see to understand The “building” of a module. All The “this. File”  and what not dont make Any sense to me.<br />
I need a How-to guide for toddlers  :P</p>
]]></description><link>https://forum.magicmirror.builders/post/1666</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/1666</guid><dc:creator><![CDATA[Snoevit]]></dc:creator><pubDate>Wed, 15 Jun 2016 15:29:26 GMT</pubDate></item><item><title><![CDATA[Reply to Ability to change color by physical button? on Wed, 15 Jun 2016 15:20:38 GMT]]></title><description><![CDATA[<p dir="auto">if you post your code in here we may can assist you a little bit</p>
]]></description><link>https://forum.magicmirror.builders/post/1665</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/1665</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Wed, 15 Jun 2016 15:20:38 GMT</pubDate></item><item><title><![CDATA[Reply to Ability to change color by physical button? on Wed, 15 Jun 2016 15:19:36 GMT]]></title><description><![CDATA[<p dir="auto">The python-button part is something i tried before, its the other language i have great difficulties with. (The one that MagicMirror is coded in.) since i dont understand The language, i cant read it and change/re-write what is needed for my idea to work. Ive been trying for 4h now.</p>
]]></description><link>https://forum.magicmirror.builders/post/1664</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/1664</guid><dc:creator><![CDATA[Snoevit]]></dc:creator><pubDate>Wed, 15 Jun 2016 15:19:36 GMT</pubDate></item><item><title><![CDATA[Reply to Ability to change color by physical button? on Wed, 15 Jun 2016 15:10:15 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://www.raspberrypi.org/learning/physical-computing-with-python/" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.raspberrypi.org/learning/physical-computing-with-python/</a> maybe this can help you to understand how the gpio pins work, but it’s a different programmin language as in this project</p>
]]></description><link>https://forum.magicmirror.builders/post/1663</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/1663</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Wed, 15 Jun 2016 15:10:15 GMT</pubDate></item><item><title><![CDATA[Reply to Ability to change color by physical button? on Wed, 15 Jun 2016 15:06:55 GMT]]></title><description><![CDATA[<p dir="auto">Yeah… I have no idea what the heck i am doing^^,<br />
This is way over my league.<br />
Is there any good beginner guides for me? :p<br />
I have been looking thru the PIR-Sensor module (and other) whilst reading the “Module Dev. Docu.” trying to understand.</p>
]]></description><link>https://forum.magicmirror.builders/post/1662</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/1662</guid><dc:creator><![CDATA[Snoevit]]></dc:creator><pubDate>Wed, 15 Jun 2016 15:06:55 GMT</pubDate></item><item><title><![CDATA[Reply to Ability to change color by physical button? on Wed, 15 Jun 2016 10:44:59 GMT]]></title><description><![CDATA[<p dir="auto">Thank you Strawberry!<br />
I will give it a go :)</p>
]]></description><link>https://forum.magicmirror.builders/post/1658</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/1658</guid><dc:creator><![CDATA[Snoevit]]></dc:creator><pubDate>Wed, 15 Jun 2016 10:44:59 GMT</pubDate></item><item><title><![CDATA[Reply to Ability to change color by physical button? on Mon, 13 Jun 2016 14:35:35 GMT]]></title><description><![CDATA[<p dir="auto">you could go for a button like this <a href="https://www.adafruit.com/products/367" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.adafruit.com/products/367</a> and hook it on the gpio pins.</p>
<p dir="auto">then you should write your own module where you can control your pins  e.g. like this module <a href="https://github.com/paviro/MMM-PIR-Sensor" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/paviro/MMM-PIR-Sensor</a></p>
<p dir="auto">instead of shutting down your tv you could change classes of the document to change the design</p>
]]></description><link>https://forum.magicmirror.builders/post/1624</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/1624</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Mon, 13 Jun 2016 14:35:35 GMT</pubDate></item></channel></rss>