<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — Associate UI element with a function instead of a pin]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1496&amp;type=atom" />
	<updated>2022-09-04T15:20:13Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=1496</id>
		<entry>
			<title type="html"><![CDATA[Re: Associate UI element with a function instead of a pin]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4792#p4792" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2022-09-04T15:20:13Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4792#p4792</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Associate UI element with a function instead of a pin]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4791#p4791" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[w9ran]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1722</uri>
			</author>
			<updated>2022-09-04T02:17:13Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4791#p4791</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Associate UI element with a function instead of a pin]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4763#p4763" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2022-08-13T20:47:54Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4763#p4763</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Associate UI element with a function instead of a pin]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4654#p4654" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[remotexy]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=2</uri>
			</author>
			<updated>2022-05-17T10:35:24Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4654#p4654</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Associate UI element with a function instead of a pin]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4653#p4653" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[DougLeary]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=2129</uri>
			</author>
			<updated>2022-05-16T09:22:47Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4653#p4653</id>
		</entry>
</feed>
