<?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>CAF Click Detector events too slow (latency)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/112799/caf-click-detector-events-too-slow-latency</link><description>Hi, 
 I have been testing the CAF click detector module and I find that any event callback after the click event takes almost 1000ms. That is the time between the actual click and the event trigger in the configured module seems too long. 
 I&amp;#39;ve played</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 31 Aug 2024 19:18:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/112799/caf-click-detector-events-too-slow-latency" /><item><title>RE: CAF Click Detector events too slow (latency)</title><link>https://devzone.nordicsemi.com/thread/500657?ContentTypeID=1</link><pubDate>Sat, 31 Aug 2024 19:18:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13c99c3b-9f49-4c07-9f67-26d56dbfa1f3</guid><dc:creator>neo_here</dc:creator><description>&lt;p&gt;Looks like the delay is mostly because of the logger running at a much lower priority than other threads. Even with RTT you&amp;#39;ll need to enable immediate logging to see the actual latency times.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;So testing the latency with logging is not a great idea. Although as I looked through the button debounce/ghosting logic it seems very conservative.&lt;br /&gt;&lt;br /&gt;Anyways, hoping this helps someone.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF Click Detector events too slow (latency)</title><link>https://devzone.nordicsemi.com/thread/500303?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 20:51:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c328d13-a16d-4fce-8702-7a201b1bea0c</guid><dc:creator>neo_here</dc:creator><description>&lt;p&gt;The debounce logic seems to be taking too much time. It would be great if someone could help me debug this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF Click Detector events too slow (latency)</title><link>https://devzone.nordicsemi.com/thread/500302?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 20:34:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13da8cbc-adc3-46bc-bd63-09e64a2e5bc5</guid><dc:creator>neo_here</dc:creator><description>&lt;p&gt;Specifically this condition&lt;/p&gt;
&lt;div&gt;&lt;br /&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="text"&gt;if ((is_pressed != was_pressed)
&amp;amp;&amp;amp; (is_pressed == is_raw_pressed)
&amp;amp;&amp;amp; (evt_limit &amp;lt; CONFIG_CAF_BUTTONS_EVENT_LIMIT))
{
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;is_pressed &lt;/span&gt;&lt;span&gt;!=&lt;/span&gt;&lt;span&gt; was_pressed&lt;/span&gt;&lt;span&gt;) this condition takes about 20-100 scans to evaluate to true. With the scan interval set to 2ms, is this amount of settling time normal ? I&amp;#39;m guessing this delay depends on what kind of debouncing we have on the hardware side as well ?&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF Click Detector events too slow (latency)</title><link>https://devzone.nordicsemi.com/thread/500301?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 20:11:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e978806-4fe0-4dec-a451-92c7dceb962b</guid><dc:creator>neo_here</dc:creator><description>&lt;p&gt;Looks like most of the delay is caused due to the the code written to prevent debouncing and ghosting.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;At stock configs for&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="text"&gt;#define SCAN_INTERVAL CONFIG_CAF_BUTTONS_SCAN_INTERVAL
#define DEBOUNCE_INTERVAL CONFIG_CAF_BUTTONS_DEBOUNCE_INTERVAL&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I see the scan function being called anywhere from 20-100 times. Which adds varying amounts of delay before the events are sent out. Every call of scan_fn adds about 3-4ms of delay.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="text"&gt;static void scan_fn(
struct k_work* work)&lt;/pre&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF Click Detector events too slow (latency)</title><link>https://devzone.nordicsemi.com/thread/500293?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 19:35:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:614ef59e-3ba4-4917-9b74-df0d4937a290</guid><dc:creator>neo_here</dc:creator><description>&lt;p&gt;Hi Swathy,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I was able to mess around a bit more, found that the button events themselves have a latency of about 500ms which adds to the click detector latency.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I was looking through buttons.c and wondering if the reason they&amp;#39;re delayed is because of the usage of delayable work units.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="text"&gt;static struct k_work_delayable matrix_scan;
static struct k_work_delayable button_pressed;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I&amp;#39;m wondering if the delay is caused due to the kernel context switch from sysworkq at -1 priority to a delayable work unit.&amp;nbsp;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF Click Detector events too slow (latency)</title><link>https://devzone.nordicsemi.com/thread/498050?ContentTypeID=1</link><pubDate>Tue, 13 Aug 2024 12:41:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:527f401e-8371-45ac-90e5-e656f3a54359</guid><dc:creator>SwRa</dc:creator><description>&lt;p&gt;Hi Chinmay,&lt;/p&gt;
&lt;p&gt;Sorry for the delay.&amp;nbsp; It was&amp;nbsp; Summer holidays here in Norway and hence we had most of us away on vacation.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The timeout was set so it would be possible to distinguish between single, double and long presses. The internal check is done every 100ms. Short click is by default 500ms so I expect you can get a delay of 500ms + 100ms before it is registered.&lt;/p&gt;
&lt;p&gt;One could set the short click delay in the configuration to be something shorter (150ms-200ms) (see &lt;a title="https://github.com/nrfconnect/sdk-nrf/blob/main/subsys/caf/modules/Kconfig.click_detector#L26" href="https://github.com/nrfconnect/sdk-nrf/blob/main/subsys/caf/modules/Kconfig.click_detector#L26"&gt;sdk-nrf/subsys/caf/modules/Kconfig.click_detector at main · nrfconnect/sdk-nrf (github.com)&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;At the moment&amp;nbsp;you will have to change the code here: &lt;a title="https://github.com/nrfconnect/sdk-nrf/blob/main/subsys/caf/modules/click_detector.c#L21" href="https://github.com/nrfconnect/sdk-nrf/blob/main/subsys/caf/modules/click_detector.c#L21"&gt;sdk-nrf/subsys/caf/modules/click_detector.c at main · nrfconnect/sdk-nrf (github.com)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Swathy&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF Click Detector events too slow (latency)</title><link>https://devzone.nordicsemi.com/thread/493534?ContentTypeID=1</link><pubDate>Thu, 11 Jul 2024 23:40:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c8a8ff4-e260-49aa-b7b1-f2db834835a3</guid><dc:creator>neo_here</dc:creator><description>&lt;p&gt;Thank you! that will be great&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF Click Detector events too slow (latency)</title><link>https://devzone.nordicsemi.com/thread/493385?ContentTypeID=1</link><pubDate>Thu, 11 Jul 2024 11:40:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13e0b8be-59b4-4b01-bf73-f3cbbf2f4336</guid><dc:creator>SwRa</dc:creator><description>&lt;p&gt;HI Chinmay,&lt;/p&gt;
&lt;p&gt;I have reported this internally and will get back to you with updates.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Swathy&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF Click Detector events too slow (latency)</title><link>https://devzone.nordicsemi.com/thread/492843?ContentTypeID=1</link><pubDate>Tue, 09 Jul 2024 02:12:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:237392c6-b81d-45d9-8243-1e27dd61ed7c</guid><dc:creator>neo_here</dc:creator><description>&lt;p&gt;Hey Swathy, I am using the nRFConnect SDK 2.6.1&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF Click Detector events too slow (latency)</title><link>https://devzone.nordicsemi.com/thread/492733?ContentTypeID=1</link><pubDate>Mon, 08 Jul 2024 13:36:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0c95ba7-f813-41d3-be16-21b9bf35251a</guid><dc:creator>SwRa</dc:creator><description>&lt;p&gt;Hi Chinmay,&lt;/p&gt;
&lt;p&gt;Could you let me know which version of the nRF Connect DK you are using.?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Swathy&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>