<?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>Generate Events Continuously With BSP While Holding a Button Down?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51526/generate-events-continuously-with-bsp-while-holding-a-button-down</link><description>Hi, 
 I&amp;#39;m trying to use the BSP functions to do the following. 
 1. Detect three different button pressing types. First - singular quick press, Second - Long Press with Timeout (say 1 second), and Third - Continual Press with no Timeout 
 2. Quick press</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 30 Aug 2019 13:25:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51526/generate-events-continuously-with-bsp-while-holding-a-button-down" /><item><title>RE: Generate Events Continuously With BSP While Holding a Button Down?</title><link>https://devzone.nordicsemi.com/thread/207173?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2019 13:25:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4916476-eebf-4170-be5a-47c34cd06d24</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;I suggest you start a timer on a pushed event, and in the timer callback you check if the button is still pressed with&amp;nbsp;&lt;a title="app_button_is_pushed" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__app__button.html?cp=5_1_6_11_9_10#ga868432e2144f402e618b3b7add26a47b"&gt;app_button_is_pushed&lt;/a&gt;. If so you call whatever function you want to periodically call then re-start the timer so that you create a non-blocking loop that periodically checks if the button is still pressed.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generate Events Continuously With BSP While Holding a Button Down?</title><link>https://devzone.nordicsemi.com/thread/207169?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2019 13:21:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79cc2c4f-2532-46af-bcf0-47fd45019b38</guid><dc:creator>BendaEng</dc:creator><description>&lt;p&gt;Darn, I was thinking that I could maybe modify the bsp.c to include another event (other than APP_BUTTON_PUSH and APP_BUTTON_RELEASE, etc which would be APP_BUTTON_HOLD. Not sure if that is feasible though.&lt;/p&gt;
&lt;p&gt;Do you think there is a way to use the Button Handling Library to trigger events continuously on a held button press? The only thing that caught my attention as a possible use was the following function within app_button.c, but I&amp;#39;m not sure how I could use that for generating continuous events by pressing and holding.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;bool app_button_is_pushed(uint8_t button_id)
{
    ASSERT(button_id &amp;lt;= m_button_count);
    ASSERT(mp_buttons != NULL);

    app_button_cfg_t const * p_btn = &amp;amp;mp_buttons[button_id];
    bool is_set = nrf_drv_gpiote_in_is_set(p_btn-&amp;gt;pin_no);

    return !(is_set ^ (p_btn-&amp;gt;active_state == APP_BUTTON_ACTIVE_HIGH));
}
#endif //NRF_MODULE_ENABLED(BUTTON)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generate Events Continuously With BSP While Holding a Button Down?</title><link>https://devzone.nordicsemi.com/thread/206764?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2019 07:32:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a33a52e1-bf6f-4818-8029-67241d9d7961</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Well, you only got two events to work with, pushed and released. I suggest you add a timer in the pushed event that times out after one second, that then periodically, like every 0.5seconds, check if the pin is still held in it&amp;#39;s pushed state and if so, do the thing you want to do.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;The BSP library is just intended to be used to run examples on the DK. In a real application, I would ditch the BSP in favor of the&amp;nbsp;&lt;a title="Button handling library" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_button.html?cp=5_1_3_7"&gt;Button handling library&lt;/a&gt;&amp;nbsp;(&lt;a title="Button Handler" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__app__button.html?cp=5_1_6_11_9"&gt;Button Handler&lt;/a&gt;, API). The BSP uses the button handling library as well, there&amp;#39;s just a lot of abstraction on top of it.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>