<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — Button "hold" time....]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1526&amp;type=atom" />
	<updated>2022-10-29T22:17:39Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=1526</id>
		<entry>
			<title type="html"><![CDATA[Re: Button "hold" time....]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4837#p4837" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>remotexy wrote:</cite><blockquote><p>FIRE button and entering a password when it is pressed)). Yes, it is interesting. Let&#039;s think.</p></blockquote></div><p>Another interesting idea ....</p><p>You are using a uint8_t variable to convey the state of a button, 0 or 1.</p><p>Could you not use the other 7 bits to convey a 100mS count of how long the button was pressed. Doing so would relieve the tedium of having to do our own timing in our sketches.&nbsp; 7 bits would allow for a count of 127, allowing for a &quot;hold&quot; timer of up to 12.7 seconds, plenty long enough for most functions.</p><p>Even better if the variable = zero, button up, and if non-zero, the button is down, and the positive count is the number of 100mS clocks it was held for, giving up to 25.5 seconds before rollover.&nbsp; That initial 100mS before the button is declared down would be a useful &quot;de-bounce&quot; time.</p><p>I&#039;m all for using the space you have already allocated for something useful, and my suggestion would not incur any data transfer or bandwidth penalties.</p><p>I&#039;m guessing the 100mS clock count doesn&#039;t need to be that accurate either, around 25 seconds would be more than ample for detecting a button &quot;held&quot; situation.</p><p>Here&#039;s the code I am using to implement a &quot;reset timers&quot; function....</p><div class="codebox"><pre><code>// reset button code
switch(GUI.hours_reset) {
  case 0:
    reset_start_time = millis();  // keep tracking while button off
    break;
  case 1:
  // reset button has to be held for 10 seconds
  if(millis() &gt;= reset_start_time + 10000) {
    EPD.hours_run = EPD.minutes_run = seconds_run = 0;
    update_EPD();
    GUI.hours_reset = 0;          // kill the button
    } // if(millis() &gt;= reset_start_time + 10000)
    break;
} // switch(GUI.hours_reset)</code></pre></div><p>How much simpler it could be....</p><div class="codebox"><pre><code>// reset button code
if(GUI.hours_reset&gt;100) {      // 100 * 100mS = 10 Seconds
    EPD.hours_run = EPD.minutes_run = seconds_run = 0;
    update_EPD();
    GUI.hours_reset = 0;          // kill the button
} // if(GUI.hours_reset&gt;100)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2022-10-29T22:17:39Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4837#p4837</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Button "hold" time....]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4836#p4836" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>remotexy wrote:</cite><blockquote><p>FIRE button and entering a password when it is pressed)). Yes, it is interesting. Let&#039;s think.</p></blockquote></div><p>I like it, &quot;Confirm with your password&quot;, a switchable attribute, not all elements will need it.</p>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2022-10-29T21:26:13Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4836#p4836</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Button "hold" time....]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4829#p4829" />
			<content type="html"><![CDATA[<p>FIRE button and entering a password when it is pressed)). Yes, it is interesting. Let&#039;s think.</p>]]></content>
			<author>
				<name><![CDATA[remotexy]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=2</uri>
			</author>
			<updated>2022-10-27T05:26:46Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4829#p4829</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Button "hold" time....]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4824#p4824" />
			<content type="html"><![CDATA[<p>I made an operation here, I think this may be useful for you, so I can find out how many seconds the button was pressed.</p><p>const int KISABASMA = 1000; // 1000 milliseconds<br />const int UZUNBASMA&nbsp; = 1000; // 1000 milliseconds</p><p>int PRESET1SONDURUM = LOW;&nbsp; // the previous state from the input pin<br />int PRESET1DURUM;&nbsp; &nbsp; &nbsp;// the current reading from the input pin<br />unsigned long PRESET1BASILMA&nbsp; = 0;<br />unsigned long PRESET1CEKME = 0;</p><p>void PRESET1 ()<br />{<br />&nbsp; PRESET1DURUM = RemoteXY.PRESET1;</p><p>&nbsp; if(PRESET1SONDURUM == LOW &amp;&amp; PRESET1DURUM == HIGH)&nbsp; &nbsp; &nbsp; &nbsp; // BUTONA BASILDIGINDA<br />&nbsp; &nbsp; PRESET1BASILMA = millis();<br />&nbsp; else if(PRESET1SONDURUM == HIGH &amp;&amp; PRESET1DURUM == LOW) { // BUTONDAN CEKILDIGINDE<br />&nbsp; &nbsp; PRESET1CEKME = millis();</p><p>&nbsp; &nbsp; long PRESET1BASILMASURESI = PRESET1CEKME - PRESET1BASILMA;</p><p>&nbsp; &nbsp; if( PRESET1BASILMASURESI &lt; KISABASMA )<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; Serial.println(&quot;PRESET-1 CAGIRILDI&quot;);<br />&nbsp; &nbsp; RemoteXY.RGB_1_r = EEPROM.read(15);<br />&nbsp; &nbsp; RemoteXY.RGB_1_g = EEPROM.read(16);<br />&nbsp; &nbsp; RemoteXY.RGB_1_b = EEPROM.read(17);<br />&nbsp; &nbsp; RemoteXY.RGB_2_r = EEPROM.read(18);<br />&nbsp; &nbsp; RemoteXY.RGB_2_g = EEPROM.read(19);<br />&nbsp; &nbsp; RemoteXY.RGB_2_b = EEPROM.read(20);<br />&nbsp; &nbsp; RemoteXY.RGB_3_r = EEPROM.read(21);<br />&nbsp; &nbsp; RemoteXY.RGB_3_g = EEPROM.read(22);<br />&nbsp; &nbsp; RemoteXY.RGB_3_b = EEPROM.read(23);<br />&nbsp; &nbsp; RemoteXY.RGB_4_r = EEPROM.read(24);<br />&nbsp; &nbsp; RemoteXY.RGB_4_g = EEPROM.read(25);<br />&nbsp; &nbsp; RemoteXY.RGB_4_b = EEPROM.read(26);<br />&nbsp; &nbsp; RemoteXY.RGB_5_r = EEPROM.read(27);<br />&nbsp; &nbsp; RemoteXY.RGB_5_g = EEPROM.read(28);<br />&nbsp; &nbsp; RemoteXY.RGB_5_b = EEPROM.read(29);<br />&nbsp; &nbsp; EPPROMLARAYAZ ();<br />&nbsp; &nbsp; }</p><br /><p>&nbsp; &nbsp; if( PRESET1BASILMASURESI &gt; UZUNBASMA )<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; Serial.println(&quot;PRESET-1 KAYDEDILDI&quot;);<br />&nbsp; &nbsp; EEPROM.write(15,RemoteXY.RGB_1_r);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(16,RemoteXY.RGB_1_g);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(17,RemoteXY.RGB_1_b);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(18,RemoteXY.RGB_2_r);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(19,RemoteXY.RGB_2_g);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(20,RemoteXY.RGB_2_b);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(21,RemoteXY.RGB_3_r);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(22,RemoteXY.RGB_3_g);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(23,RemoteXY.RGB_3_b);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(24,RemoteXY.RGB_4_r);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(25,RemoteXY.RGB_4_g);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(26,RemoteXY.RGB_4_b);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(27,RemoteXY.RGB_5_r);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(28,RemoteXY.RGB_5_g);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EEPROM.write(29,RemoteXY.RGB_5_b);<br />&nbsp; &nbsp; EEPROM.commit();<br />&nbsp; &nbsp; EPPROMLARAYAZ ();<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED1_r = EEPROM.read(15);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED1_g = EEPROM.read(16);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED1_b = EEPROM.read(17);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED2_r = EEPROM.read(18);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED2_g = EEPROM.read(19);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED2_b = EEPROM.read(20);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED3_r = EEPROM.read(21);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED3_g = EEPROM.read(22);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED3_b = EEPROM.read(23);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED4_r = EEPROM.read(24);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED4_g = EEPROM.read(25);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED4_b = EEPROM.read(26);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED5_r = EEPROM.read(27);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED5_g = EEPROM.read(28);<br />&nbsp; &nbsp; RemoteXY.PRESET1RGBLED5_b = EEPROM.read(29);<br />&nbsp; &nbsp; }<br />&nbsp; }<br />&nbsp; PRESET1SONDURUM = PRESET1DURUM;<br />}</p>]]></content>
			<author>
				<name><![CDATA[ogunekici]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=2226</uri>
			</author>
			<updated>2022-10-26T13:57:09Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4824#p4824</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Button "hold" time....]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4750#p4750" />
			<content type="html"><![CDATA[<p>It would be great if the RemoteXY buttons had a parameter that says the button has to be down for a minimum time before it is sent to the host.</p><p>Using touch screen phones it would be easy to create nuisance button presses which could be disastrous ....</p><p>Yes, I know we can code for that scenario in our sketches, but it would be much much simpler to set the timing parameter in the RemoteXY GUI.</p>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2022-08-06T20:35:46Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4750#p4750</id>
		</entry>
</feed>
