<?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>button long-press &amp;amp; short press implement on nRF52</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/36593/button-long-press-short-press-implement-on-nrf52</link><description>I am very new begginer and dont know where to start about nordic nrf52832 chip. Started a week ago with downloading SDK and playing with examples in it. 
 I in specific need some guidance to operate the long press and short press on same button and thereby</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 15 Jul 2019 10:10:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/36593/button-long-press-short-press-implement-on-nrf52" /><item><title>RE: button long-press &amp; short press implement on nRF52</title><link>https://devzone.nordicsemi.com/thread/198406?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2019 10:10:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de6b68ba-4888-4134-a634-b6a7fd6b8dca</guid><dc:creator>CY</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am also trying to do the same feature.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void bsp_button_event_handler(uint8_t pin_no, uint8_t button_action)
{
    bsp_event_t        event  = BSP_EVENT_NOTHING;
    uint32_t           button = 0;
    uint32_t           err_code;
    static uint8_t     current_long_push_pin_no;              /**&amp;lt; Pin number of a currently pushed button, that could become a long push if held long enough. */
    static bsp_event_t release_event_at_push[BUTTONS_NUMBER]; /**&amp;lt; Array of what the release event of each button was last time it was pushed, so that no release event is sent if the event was bound after the push of the button. */

    button = bsp_board_pin_to_button_idx(pin_no);

    if (button &amp;lt; BUTTONS_NUMBER)
    {
        switch (button_action)
        {
        		case BSP_BUTTON_ACTION_PUSH:
                event = m_events_list[button].push_event;
                if (m_events_list[button].long_push_event != BSP_EVENT_NOTHING)
                {
                    //11/27 Wedy add the note: here can set the timer for long press button
                    err_code = app_timer_start(m_bsp_button_tmr, APP_TIMER_TICKS(BSP_LONG_PUSH_TIMEOUT_MS), (void*)&amp;amp;current_long_push_pin_no); //0716 Wedy add for marked to change the time condition &amp;quot;timer start&amp;quot;
                    if (err_code == NRF_SUCCESS)
                    {
                        current_long_push_pin_no = pin_no;
                    }
                }
                release_event_at_push[button] = m_events_list[button].release_event;
                break;
            case APP_BUTTON_RELEASE:
                (void)app_timer_stop(m_bsp_button_tmr); //0716 Wedy note for timer stop
                if (release_event_at_push[button] == m_events_list[button].release_event)
                {
                    event = m_events_list[button].release_event;
                }
                //11/27 Wedy add to set the long press release function
                /*if (release_event_at_push [button] == m_events_list[button].long_push_event)
                {
                    event=m_events_list[button].release_event;
                }*/
                break;
            case BSP_BUTTON_ACTION_LONG_PUSH:
                event = m_events_list[button].long_push_event;
                //11/27 Wedy add for the long press release Setting
                release_event_at_push[button]=m_events_list[button].long_push_event;
        }
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As you mentioned, is it can be achieved by modified the app_button_push to bsp_button_action_push?&lt;/p&gt;
&lt;p&gt;I just modified my code, but it still trigger the short press when I was trying to trigger the long press event.&lt;/p&gt;
&lt;p&gt;Besides, do you have any idea of double click based on this structure can be shared?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Wedy&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: button long-press &amp; short press implement on nRF52</title><link>https://devzone.nordicsemi.com/thread/141537?ContentTypeID=1</link><pubDate>Thu, 26 Jul 2018 13:40:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90f87f68-cec9-47f7-a1d3-e376e14610a0</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This is expected. The&amp;nbsp;APP_BUTTON_PUSH from the app_button library is on a different &amp;quot;level&amp;quot; (app button library) then&amp;nbsp;BSP_BUTTON_ACTION_LONG_PUSH (BSP library). app_button itself only support button press and release events, and has no concept of the duration of the pushes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want t use&amp;nbsp;BSP_BUTTON_ACTION_LONG_PUSH to get long pushes, then it makes sense to use the&amp;nbsp;BSP_BUTTON_ACTION_PUSH event for the short/normal push, ignoring the app_button events.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: button long-press &amp; short press implement on nRF52</title><link>https://devzone.nordicsemi.com/thread/141322?ContentTypeID=1</link><pubDate>Wed, 25 Jul 2018 12:33:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:709340fc-74b1-47a6-a7c6-8262d8bcf68b</guid><dc:creator>jyothi</dc:creator><description>&lt;p&gt;Hey , I used both push, and long push used in bsp.h,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The functions in the following code in bsp.h are those which I called in main.c&lt;/p&gt;
&lt;p&gt;case APP_BUTTON_PUSH:&lt;br /&gt; event = m_events_list[button].push_event;&lt;br /&gt; //if (m_events_list[button].long_push_event != BSP_EVENT_NOTHING)&lt;br /&gt; {&lt;br /&gt; err_code = app_timer_start(m_button_timer_id, BSP_MS_TO_TICK(BSP_LONG_PUSH_TIMEOUT_MS), (void*)&amp;amp;current_long_push_pin_no);&lt;br /&gt; if (err_code == NRF_SUCCESS)&lt;br /&gt; {&lt;br /&gt; current_long_push_pin_no = pin_no;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; release_event_at_push[button] = m_events_list[button].release_event;&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; case APP_BUTTON_RELEASE:&lt;br /&gt; (void)app_timer_stop(m_button_timer_id);&lt;br /&gt; if (release_event_at_push[button] == m_events_list[button].release_event)&lt;br /&gt; {&lt;br /&gt; event = m_events_list[button].release_event;&lt;br /&gt; }&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; case BSP_BUTTON_ACTION_LONG_PUSH:&lt;br /&gt; event = m_events_list[button].long_push_event;&lt;br /&gt; press = 2; // long&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The thing is that short push is working fine, but for long push button, the output detected is related to both the short push and long push. Its just not giving the output of long push.&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: button long-press &amp; short press implement on nRF52</title><link>https://devzone.nordicsemi.com/thread/140657?ContentTypeID=1</link><pubDate>Thu, 19 Jul 2018 11:40:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a90b4680-8fa4-46ca-9891-c6d54a7016be</guid><dc:creator>jyothi</dc:creator><description>&lt;p&gt;okay, will try using this. But since I am begginer, I just want to sample codes if there are any!&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;And also, I need to use the timer right? for making funtionality? So just want to know where do we start timer and detect the press if we use bsp.c&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: button long-press &amp; short press implement on nRF52</title><link>https://devzone.nordicsemi.com/thread/140627?ContentTypeID=1</link><pubDate>Thu, 19 Jul 2018 08:57:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad794784-7963-4f3e-847e-24e9dac59600</guid><dc:creator>noseed</dc:creator><description>&lt;div class="frame"&gt;
&lt;div class="page tlid-homepage homepage translate-text"&gt;
&lt;div class="homepage-content-wrap"&gt;
&lt;div class="tlid-source-target main-header small-font"&gt;
&lt;div class="source-target-row"&gt;
&lt;div class="tlid-result result-dict-wrapper"&gt;
&lt;div class="result"&gt;
&lt;div class="text-wrap"&gt;
&lt;div class="result-shield-container"&gt;&lt;span class="tlid-translation translation"&gt;&lt;span title=""&gt;If you look at the code(bsp.c), you can use it without the BLE function.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="result-shield-container"&gt;&lt;span class="tlid-translation translation"&gt;&lt;span title=""&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1531990590913v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: button long-press &amp; short press implement on nRF52</title><link>https://devzone.nordicsemi.com/thread/140626?ContentTypeID=1</link><pubDate>Thu, 19 Jul 2018 08:47:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95f5e170-ddd8-4ed5-ab0b-e2c2695b271f</guid><dc:creator>jyothi</dc:creator><description>&lt;p&gt;yeah exactly, but i want to implement without connecting to softdevice and BLE.&lt;/p&gt;
&lt;p&gt;I just want to detect long press and detect short press and there by perform&amp;nbsp; small functionalities like prining basing upon the type of pressing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: button long-press &amp; short press implement on nRF52</title><link>https://devzone.nordicsemi.com/thread/140616?ContentTypeID=1</link><pubDate>Thu, 19 Jul 2018 08:18:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7914224a-673d-4763-8eee-0d877ff2ee57</guid><dc:creator>noseed</dc:creator><description>&lt;div class="frame"&gt;
&lt;div class="page tlid-homepage homepage translate-text"&gt;
&lt;div class="homepage-content-wrap"&gt;
&lt;div class="tlid-source-target main-header"&gt;
&lt;div class="source-target-row"&gt;
&lt;div class="tlid-result result-dict-wrapper"&gt;
&lt;div class="result"&gt;
&lt;div class="text-wrap"&gt;
&lt;div class="result-shield-container"&gt;&lt;span class="tlid-translation translation"&gt;&lt;span title=""&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;그것은 이미 SDK에서 구현됩니다. (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt; 참조&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/examples_bsp_btn_ble.html?cp=4_0_0_3_6_1"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt; BSP BLE 버튼 모듈&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt; )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>