<?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 push and release events</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49536/button-push-and-release-events</link><description>Hi, 
 to initialize the button properly 
 to trigger the push event on button push and the release event on button release, do I just have to change the button active state, if not how can i control it !? 
 /**@brief Button configuration structure. *</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 09 Jul 2019 10:26:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49536/button-push-and-release-events" /><item><title>RE: button push and release events</title><link>https://devzone.nordicsemi.com/thread/197326?ContentTypeID=1</link><pubDate>Tue, 09 Jul 2019 10:26:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1eba0507-9ca4-4c08-b572-257558913ba1</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;What you are setting there is the sense of the button:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define APP_BUTTON_ACTIVE_HIGH 1                               /**&amp;lt; Indicates that a button is active high. */
#define APP_BUTTON_ACTIVE_LOW  0                               /**&amp;lt; Indicates that a button is active low. */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If your button is active low, set it to &amp;quot;false&amp;quot;. If active high, set it to &amp;quot;true&amp;quot;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To address your question: The app_button library will provide an event when button is pushed, and when it is released. No need to do anything else than what is provided underneath.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: button push and release events</title><link>https://devzone.nordicsemi.com/thread/197323?ContentTypeID=1</link><pubDate>Tue, 09 Jul 2019 10:11:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c148473-287d-4de5-b5cf-e5508a7ef936</guid><dc:creator>jawadk</dc:creator><description>&lt;p&gt;Hi Hakan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;thanks for your reply.&lt;/p&gt;
&lt;p&gt;I will ask my question in other way&lt;/p&gt;
&lt;p&gt;when i configure my button as&amp;nbsp;&lt;/p&gt;
&lt;p&gt;{MY_BUTTON, &lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;true&lt;/strong&gt;&lt;/span&gt;, BUTTON_PULL, button_evt_handler},&amp;nbsp; ?&lt;/p&gt;
&lt;p&gt;and when I configure it as :&lt;/p&gt;
&lt;p&gt;{MY_BUTTON, &lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;false&lt;/strong&gt;&lt;/span&gt;, BUTTON_PULL, button_evt_handler}, ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: button push and release events</title><link>https://devzone.nordicsemi.com/thread/197315?ContentTypeID=1</link><pubDate>Tue, 09 Jul 2019 09:35:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a527d1c-3db1-4048-bd74-e4d5fc0c6d4d</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BSP depends on a module named app_button, and BSP does not send the PUSH and RELEASE event, but app_button does.&lt;/p&gt;
&lt;p&gt;I would recommend that you, instead of using BSP, implement app_button directly in your application. Here&amp;#39;s an example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void button_evt_handler(uint8_t pin_no, uint8_t button_action)
{
    switch (pin_no)
    {
        case MY_BUTTON:
        {
            if (button_action == APP_BUTTON_PUSH)
            {
                /* Button pushed */
                do_something();
            }
            else 
            {
                /* APP_BUTTON_RELEASE */
                do_something_else();
            }
        }
        break;
        default:
        break;
    }
}

static void buttons_init(void)
{
   // The array must be static because a pointer to it will be saved in the button library.
    static app_button_cfg_t buttons[] =
    {
        {MY_BUTTON, true, BUTTON_PULL, button_evt_handler},        
    };

    ret_code_t err_code = app_button_init(buttons, ARRAY_SIZE(buttons), BUTTON_DETECTION_DELAY);
    APP_ERROR_CHECK(err_code);
    
    /* You can call this other places as well, for instance when you get BLE_GAP_EVT_CONNECTED */
    err_code = app_button_enable();
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: button push and release events</title><link>https://devzone.nordicsemi.com/thread/197313?ContentTypeID=1</link><pubDate>Tue, 09 Jul 2019 09:33:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1dd3e5d3-daae-4d8b-a4b1-4ba5087480fe</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;how to properly post source code:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/1321._5F00_Insert-Code-_2D00_-Nordic.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>