<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[RemoteXY community — Associate UI element with a function instead of a pin]]></title>
		<link>https://forum.remotexy.com/viewtopic.php?id=1496</link>
		<atom:link href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1496&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Associate UI element with a function instead of a pin.]]></description>
		<lastBuildDate>Sun, 04 Sep 2022 15:20:13 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Associate UI element with a function instead of a pin]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=4792#p4792</link>
			<description><![CDATA[<div class="quotebox"><cite>w9ran wrote:</cite><blockquote><p>Along a similar line, I think it would be useful to have a one-shot option in the UI, so that only changes of state are transmitted wirelessly.&nbsp; &nbsp; In order to implement an adjustment feature using up and down arrows, for instance, I had to &quot;debounce&quot; the variable coming back from RemoteXY to get just one increment per button touch rather than a string of them (like an autorepeat).&nbsp; &nbsp; <span style="color: red"> It would simplify some user interfaces if a button would only generate one change of state indication until it is released again</span>.</p><p>Bob</p></blockquote></div><p>I&#039;m not sure if this would be the best way forward Bob.</p><p>It would &quot;fix&quot; a button to be either COS or Continuous, but not both. I reckon some buttons you might want to use both methods in your sketch.</p><p>I&#039;m sure there&#039;s a comprehensive library for dealing with button handling, I&#039;ll see if I can find one.&nbsp; Many devices use a single button for a single increment (or decrement) of a value, for instance, but if &quot;held&quot; for a time the value gets incremented continuously, at a certain rate, which often also accelerates the longer you hold it.</p><p>I know I&#039;ve used a &quot;Debounce&quot; function in the past that tells you which button is just pressed, and has the ability to tell you if a button is &quot;held&quot;.</p><p>IMHO there&#039;ll be too many variable &quot;features&quot; you may require of a button for these to be handled in the UI, this sort of jiggery-pokery best done in the sketch, and the UI just says &quot;button down/button up&quot; as it does now.</p><p>EDIT : here&#039;s what comes up when you google &quot;arduino button library&quot; ....</p><p><a target="_blank" href="https://www.arduino.cc/reference/en/libraries/button/">https://www.arduino.cc/reference/en/libraries/button/</a><br /><a target="_blank" href="https://www.arduino.cc/reference/en/libraries/button-arduino/">https://www.arduino.cc/reference/en/lib … n-arduino/</a><br /><a target="_blank" href="https://www.arduino.cc/reference/en/libraries/ezbutton/">https://www.arduino.cc/reference/en/libraries/ezbutton/</a></p><p>There&#039;s loads more, and I&#039;m sure at least one of them will suit your needs ...</p>]]></description>
			<author><![CDATA[null@example.com (Daba)]]></author>
			<pubDate>Sun, 04 Sep 2022 15:20:13 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=4792#p4792</guid>
		</item>
		<item>
			<title><![CDATA[Re: Associate UI element with a function instead of a pin]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=4791#p4791</link>
			<description><![CDATA[<p>Along a similar line, I think it would be useful to have a one-shot option in the UI, so that only changes of state are transmitted wirelessly.&nbsp; &nbsp; In order to implement an adjustment feature using up and down arrows, for instance, I had to &quot;debounce&quot; the variable coming back from RemoteXY to get just one increment per button touch rather than a string of them (like an autorepeat).&nbsp; &nbsp; &nbsp;It would simplify some user interfaces if a button would only generate one change of state indication until it is released again.</p><p>Bob</p>]]></description>
			<author><![CDATA[null@example.com (w9ran)]]></author>
			<pubDate>Sun, 04 Sep 2022 02:17:13 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=4791#p4791</guid>
		</item>
		<item>
			<title><![CDATA[Re: Associate UI element with a function instead of a pin]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=4763#p4763</link>
			<description><![CDATA[<div class="quotebox"><cite>DougLeary wrote:</cite><blockquote><p>Besides controlling a hardware pin a UI element could also trigger function calls. </p><p>For example, selecting a pin in the &quot;Snap to Pin&quot; dropdown for button_1 generates code:</p><p>&nbsp; &nbsp; digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1==0)?LOW:HIGH);</p><p>If &quot;Snap to Pin&quot; also had a Function Name option, you could enter &quot;myFunction&quot; and it would generate code:</p><p>&nbsp; &nbsp; if (RemoteXY.button_1==1) { myFunction(); }&nbsp; &nbsp;// call myFunction if button_1 is pressed</p></blockquote></div><p>A potential problem here is that your function will be called every iteration of void loop() while the button is held down. This may not be desirable.</p><p>You can avoid this by generating a &quot;one-shot&quot; and only calling your function once, but while coding that it&#039;s no big sweat to read the RemoteXY button variable as is, and using the one-shot code, call the function once only.</p><p>Here I&#039;m using a button on the GUI that has to be held down for 5 seconds in order to reset my &quot;hours_run&quot; timings ....</p><div class="codebox"><pre><code> // reset button code
  if(RemoteXY.hours_reset == 1)
  {
    if(reset_ons == false) 
    {
      reset_start_time = millis();          // log the start time
      reset_ons = true;                     // set the one-shot
    } // if(reset_ons = false)

    if(millis() &gt; reset_start_time + 5000)  // wait elapsed time
    {
      hours_run = 0;
      EEData.hours_run = hours_run;
      minutes_run = 0;
      EEData.minutes_run = minutes_run;
      seconds_run = 0;
      EEDataSAVE();
    } // if(millis() &gt; reset_start_time + 3000)
  } // if(RemoteXY.hours_reset == 1)

  if(RemoteXY.hours_reset == 0) reset_ons = false;            // button released</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Daba)]]></author>
			<pubDate>Sat, 13 Aug 2022 20:47:54 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=4763#p4763</guid>
		</item>
		<item>
			<title><![CDATA[Re: Associate UI element with a function instead of a pin]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=4654#p4654</link>
			<description><![CDATA[<p>This is a good idea. For beginners. We think about calling a function when the variable changes to any value. There will be something like events.</p>]]></description>
			<author><![CDATA[null@example.com (remotexy)]]></author>
			<pubDate>Tue, 17 May 2022 10:35:24 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=4654#p4654</guid>
		</item>
		<item>
			<title><![CDATA[Associate UI element with a function instead of a pin]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=4653#p4653</link>
			<description><![CDATA[<p>Besides controlling a hardware pin a UI element could also trigger function calls. </p><p>For example, selecting a pin in the &quot;Snap to Pin&quot; dropdown for button_1 generates code:</p><p>&nbsp; &nbsp; digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1==0)?LOW:HIGH);</p><p>If &quot;Snap to Pin&quot; also had a Function Name option, you could enter &quot;myFunction&quot; and it would generate code:</p><p>&nbsp; &nbsp; if (RemoteXY.button_1==1) { myFunction(); }&nbsp; &nbsp;// call myFunction if button_1 is pressed</p>]]></description>
			<author><![CDATA[null@example.com (DougLeary)]]></author>
			<pubDate>Mon, 16 May 2022 09:22:47 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=4653#p4653</guid>
		</item>
	</channel>
</rss>
