<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to create single Button with multiple condition based on the period of the button press?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/41786/how-to-create-single-button-with-multiple-condition-based-on-the-period-of-the-button-press</link><description>Hi There, 
 
 HW: PCA10056 
 SW: nRF5_SDK_15.2.0_9412b96 
 Test source code: ble_app_blinky 
 How can I create single Button with multiple condition based on the period of the button press? 
 Here is the conditions: 
 1) press button and release without</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 21 Dec 2018 15:18:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/41786/how-to-create-single-button-with-multiple-condition-based-on-the-period-of-the-button-press" /><item><title>RE: How to create single Button with multiple condition based on the period of the button press?</title><link>https://devzone.nordicsemi.com/thread/162879?ContentTypeID=1</link><pubDate>Fri, 21 Dec 2018 15:18:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86e918c5-df0c-4901-9e12-7917ef318887</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;The approach I would go for is to use&amp;nbsp;the&amp;nbsp;&lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-2-0/lib_button"&gt;Button handling library&lt;/a&gt;&amp;nbsp;(app_button.c/h)&amp;nbsp;which can detect both a button release and button push, and handles debouncing as well. In order to measure time of a button press, I would use the &lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-2-0/lib_timer"&gt;Timer library&lt;/a&gt;&amp;nbsp;(app_timer.c/h). Which uses the low frequency RTC, and is &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/10952/timer-vs-app_timer"&gt;sufficient for your needs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The way I would go about measuring the time, is to create a timestamp on button push and button release, and then calculate the difference. Take a look at&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/11961/recording-time-for-which-the-button-is-pressed"&gt;this&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/3632/how-to-use-timer-to-get-button-pushed-time"&gt;this&lt;/a&gt;&amp;nbsp;link for inspiration.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>