<?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>Detect button callback trigger</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60319/detect-button-callback-trigger</link><description>Hello, 
 
 In relation to button press detection, I&amp;#39;m curious if I&amp;#39;m utilizing both GPIO_INT_EDGE and GPIO_IN_DOUBLE_EDGE if I can pass the interrupt type to my callback to know whether it was triggered by rising or falling of the button? At the moment</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Apr 2020 14:46:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60319/detect-button-callback-trigger" /><item><title>RE: Detect button callback trigger</title><link>https://devzone.nordicsemi.com/thread/245882?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2020 14:46:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96ef48b9-8cc5-4886-9ceb-e30243457195</guid><dc:creator>joshuab1986</dc:creator><description>&lt;p&gt;Perfect... I&amp;#39;m not sure why I decided to use math prior instead of just reading the pin state. I created a simplified function where I do this all through my code, but never crossed my mind for the button press. This method works perfect, so I&amp;#39;ll go that route. Thank your for your time &lt;a href="https://devzone.nordicsemi.com/members/edvin-holmseth"&gt;Edvin&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect button callback trigger</title><link>https://devzone.nordicsemi.com/thread/245824?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2020 11:29:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02ace49f-0ce2-4493-a713-ee8f821180cc</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Ok, can you try to set up two different handlers for the events? One for rising and one for falling? Alternatively, you can read the pin state in the callback, but if so, you may want to add a delay to prevent reading the wrong state when the pin is bouncing, which it typically is on a button press.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect button callback trigger</title><link>https://devzone.nordicsemi.com/thread/245812?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2020 10:41:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8472f064-56e0-47d4-befe-2cd0b4a32cd5</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello, Sorry. I didn&amp;#39;t see that you used the nRF9160 tag. I thought you were using the nRF52. Let me look into this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect button callback trigger</title><link>https://devzone.nordicsemi.com/thread/245625?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2020 15:31:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6165a941-c4a2-40eb-8fce-520fab0b2471</guid><dc:creator>joshuab1986</dc:creator><description>&lt;p&gt;Edvin,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for your detailed reply. I&amp;#39;ll give the app_button library a look and test implementing it.&amp;nbsp;I should have been more specific rather than just using a tag of nRF9160, but I&amp;#39;m using the connect SDK and also using this same button as a wakeup_pin to wake the nRF9160 module from deep sleep. Do you see any issues with this functioning under Connect SDK?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detect button callback trigger</title><link>https://devzone.nordicsemi.com/thread/245534?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2020 12:41:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c29c5ee-ee58-412d-9f9e-6dff247be158</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;There are a couple approaches for this. One is to actually read the pin state in the interrupt.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you use any libraries for your button handling? bsp or app_button, for example?&lt;/p&gt;
&lt;p&gt;If you want a bit more than just the basic button handler, such as whether the button was pressed or not, I would suggest that you look into using the app_button library directly (which is used by the bsp library). The reason for this is that the bsp library strips away quite a lot from the app_button functionality.&lt;/p&gt;
&lt;p&gt;If you take a closer look in the bsp example found in SDK\examples\peripheral\bsp, and look inside the bsp_init() function, you can see that it calls app_button_init(), with&amp;nbsp;app_buttons as an argument. In app_buttons, there is an event handler;&amp;nbsp;bsp_button_event_handler(). In this event handler you can see that it checks whether the button was pressed or released.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;NB: Note that the app_button library requires you to start the app_timer in order to work. (It is used for debounce)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>