<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — illuminate button]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1138&amp;type=atom" />
	<updated>2020-08-11T06:16:00Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=1138</id>
		<entry>
			<title type="html"><![CDATA[Re: illuminate button]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3287#p3287" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Joan wrote:</cite><blockquote><div class="quotebox"><cite>Daba wrote:</cite><blockquote><p>I believe it consume less memory, and possibly easier to understand...</p></blockquote></div><p>Congratulations!!! Your code is brilliant. I will rehearse it.</p><p>IN CCS I use the toggle function, but in Arduino it doesn&#039;t exist and that&#039;s why I made this little code.</p><p>Sorry,<br />where i find ... #include&nbsp; ---&gt; &quot;RemoteXY.hpp&quot;</p><br /><br /><p>Thank you!!!!</p></blockquote></div><p>RemoteXY.hpp is the name of a separate &quot;tab&quot; which contains the source code copied from the web editor.</p><p>Using a separate tab makes it easier to update, because once you have copied the source code, you can then go into that tab, do a ctrl-a (select all), then ctrl-v (paste). </p><p>The button to create a new tab is on the right of the IDE, just below the serial monitor button.</p>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2020-08-11T06:16:00Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3287#p3287</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: illuminate button]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3286#p3286" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Daba wrote:</cite><blockquote><p>I believe it consume less memory, and possibly easier to understand...</p></blockquote></div><p>Congratulations!!! Your code is brilliant. I will rehearse it.</p><p>IN CCS I use the toggle function, but in Arduino it doesn&#039;t exist and that&#039;s why I made this little code.</p><p>Sorry,<br />where i find ... #include&nbsp; ---&gt; &quot;RemoteXY.hpp&quot;</p><br /><br /><p>Thank you!!!!</p>]]></content>
			<author>
				<name><![CDATA[Joan]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1497</uri>
			</author>
			<updated>2020-08-10T16:46:50Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3286#p3286</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: illuminate button]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3285#p3285" />
			<content type="html"><![CDATA[<p>I execute the &quot;toggle&quot; function needed by a Push_ON/Push_OFF (latching) button slightly differently, I believe it consume less memory, and possibly easier to understand....</p><div class="codebox"><pre><code>#include &quot;RemoteXY.hpp&quot;

// program variables
bool  button1;        // momentary button
bool  button2;        // latching button
bool  button2_memory;


void setup() 
{
  RemoteXY_Init (); 
}

void loop() 
{ 
  RemoteXY_Handler ();
  
  // Momentary button is easy....
  // the boolean tag button1 will be true if
  // the input data is non-zero
  button1 = RemoteXY.button1;

  // Latching button is a little harder ....
  // test to see if button is pressed
  if(RemoteXY.button2) {
    // now test if not already seen on
    if(!button2_memory) {
      // a new press, so toggle the button
      button2 = !button2;
      // set memory flag as button seen
      button2_memory = true;
    }
  }
  // reset the memory flag when button released
  if(!RemoteXY.button2) button2_memory = false;

  // now drive the LED indicators from the button states
  // each button will be either 0 or 1
  RemoteXY.led1_r = (button1 * 255);
  RemoteXY.led2_r = (button2 * 255);
  
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2020-08-10T12:12:42Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3285#p3285</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: illuminate button]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3278#p3278" />
			<content type="html"><![CDATA[<p>This is my example:</p><p><a target="_blank" href="http://remotexy.com/en/editor/922181bfa38d9f062c54be4b3b215c09/">http://remotexy.com/en/editor/922181bfa … b3b215c09/</a></p><p>And the code:</p><p>//////////////////////////////////////////////<br />//&nbsp; &nbsp; &nbsp; &nbsp; RemoteXY include library&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />//////////////////////////////////////////////</p><p>// RemoteXY select connection mode and include library <br />#define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT<br />#include &lt;ESP8266WiFi.h&gt;</p><p>#include &lt;RemoteXY.h&gt;</p><p>// RemoteXY connection settings <br />#define REMOTEXY_WIFI_SSID &quot;your ssid&quot;<br />#define REMOTEXY_WIFI_PASSWORD &quot;your password&quot;<br />#define REMOTEXY_SERVER_PORT 6377</p><p>uint8_t flag1;<br />uint8_t val01;</p><br /><p>// RemoteXY configurate&nbsp; <br />#pragma pack(push, 1)<br />uint8_t RemoteXY_CONF[] =<br />&nbsp; { 255,1,0,1,0,33,0,10,13,1,<br />&nbsp; 1,1,22,22,17,17,29,133,0,65,<br />&nbsp; 26,23,23,15,15,129,0,21,6,21,<br />&nbsp; 6,6,82,101,108,101,32,48,49,0 };<br />&nbsp; <br />// this structure defines all the variables and events of your control interface <br />struct {</p><p>&nbsp; &nbsp; // input variables<br />&nbsp; uint8_t button_1; // =1 if button pressed, else =0 </p><p>&nbsp; &nbsp; // output variables<br />&nbsp; uint8_t led_1_g; // =0..255 LED Green brightness </p><p>&nbsp; &nbsp; // other variable<br />&nbsp; uint8_t connect_flag;&nbsp; // =1 if wire connected, else =0 </p><p>} RemoteXY;<br />#pragma pack(pop)</p><p>/////////////////////////////////////////////<br />//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END RemoteXY include&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />/////////////////////////////////////////////</p><p>// #define PIN_BUTTON_1 D2&nbsp; &nbsp; // For NodeMCU V3<br />#define PIN_BUTTON_1 2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // For ESP8266-01</p><br /><p>void setup() <br />{<br />&nbsp; RemoteXY_Init (); <br />&nbsp; <br />&nbsp; pinMode (PIN_BUTTON_1, OUTPUT);<br />&nbsp; <br />&nbsp; // TODO you setup code<br />&nbsp; <br />}</p><p>void loop() <br />{ <br />&nbsp; RemoteXY_Handler ();<br />&nbsp; <br />&nbsp; if (RemoteXY.button_1==0) flag1=0; // Detects the change of state of the button.<br />&nbsp; if ((RemoteXY.button_1==1) &amp;&amp; flag1==0){<br />&nbsp; &nbsp; if (val01==1){<br />&nbsp; &nbsp; &nbsp; val01=0;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; else{<br />&nbsp; &nbsp; &nbsp; val01=1;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; flag1=1;<br />&nbsp; &nbsp; digitalWrite(PIN_BUTTON_1, val01);<br />&nbsp; &nbsp; }<br />&nbsp; <br />&nbsp; &nbsp;<br />&nbsp; RemoteXY.led_1_g = (digitalRead(2)==HIGH)?255:0;&nbsp; <br />&nbsp; <br />&nbsp; // TODO you loop code<br />&nbsp; // use the RemoteXY structure for data transfer<br />&nbsp; // do not call delay() </p><br /><p>}</p>]]></content>
			<author>
				<name><![CDATA[Joan]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1497</uri>
			</author>
			<updated>2020-08-09T21:59:48Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3278#p3278</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: illuminate button]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3276#p3276" />
			<content type="html"><![CDATA[<p>OK Daba...<br />Yesterday I made a similar one and I put a code where it turns on when you press, maintains the state and turns off when you press again. SonOff type.</p><p>I was saying it because that way we only use one element and not two.<br />Thanks for the example.</p>]]></content>
			<author>
				<name><![CDATA[Joan]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1497</uri>
			</author>
			<updated>2020-08-09T17:44:34Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3276#p3276</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: illuminate button]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3271#p3271" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Joan wrote:</cite><blockquote><p>illuminate button.</p><p>Like we illuminate an LED, it would be nice to be able to illuminate a button.<br />If we have an application that when pressing the button turns on a relay and when pressing it again we turn it off, it is good to indicate it from the same button.</p><br /><p>Sorry, if it&#039;s not in this space, please move it.</p><br /><p>Thank you.</p></blockquote></div><p>Welcome to the forum Joan...</p><p>Place the button behind an LED (it will still work!), use the &quot;To Front&quot;, &quot;Forward One&quot;, &quot;Back One&quot;, and &quot;To Back&quot; menu controls to get the LED in front of the button.</p><p>Obviously you will have to write code in the sketch to &quot;illuminate&quot; the LED (Dark Red, Bright Red, for example....).</p><p>Remember that the button is the same as a physical button, and the phone app. will keep on writing a &quot;1&quot; to the button value as long as your finger is on it, only writing a &quot;0&quot; when your finger is removed. You will have to take care of this in code.</p><p>Here, I&#039;ve just made this to show you...</p><p><a target="_blank" href="http://remotexy.com/en/editor/d92747f372c5f85458d5c5e5f28c0875/">http://remotexy.com/en/editor/d92747f37 … 5f28c0875/</a></p>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2020-08-09T10:10:23Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3271#p3271</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[illuminate button]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3268#p3268" />
			<content type="html"><![CDATA[<p>illuminate button.</p><p>Like we illuminate an LED, it would be nice to be able to illuminate a button.<br />If we have an application that when pressing the button turns on a relay and when pressing it again we turn it off, it is good to indicate it from the same button.</p><br /><p>Sorry, if it&#039;s not in this space, please move it.</p><br /><p>Thank you.</p>]]></content>
			<author>
				<name><![CDATA[Joan]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1497</uri>
			</author>
			<updated>2020-08-09T05:49:25Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3268#p3268</id>
		</entry>
</feed>
