public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Przemyslaw Marczak <p.marczak@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 4/5] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay
Date: Wed, 30 Apr 2014 12:10:27 +0200	[thread overview]
Message-ID: <5360CC13.40706@samsung.com> (raw)
In-Reply-To: <20140428134456.GA3006@book.gsilab.sittig.org>

Hello Gerhard,

On 04/28/2014 03:44 PM, Gerhard Sittig wrote:
> On Fri, 2014-04-25 at 12:20 +0200, Przemyslaw Marczak wrote:
>>
>> This change prevents gpio keys bouncing by adding 50 ms delay
>> when key pressed condition met.
>>
>> [ ... ]
>> @@ -105,6 +105,10 @@ static int check_keys(void)
>>   	if (key_pressed(KEY_VOLUMEDOWN))
>>   		keys += KEY_VOLUMEDOWN;
>>
>> +	/* Avoids gpio keys debouncing */
>> +	if (keys)
>> +		mdelay(50);
>> +
>>   	return keys;
>>   }
>
> The approach might have helped in your case, since you tested it
> and found it's good.  I'm just wondering whether the code really
> does correct de-bouncing.
>
> The delay does decrease the polling frequency (assuming that the
> routine is called in a loop).  But you return data that was
> sampled before the delay.  You don't re-fetch samples after the
> delay.  And this would not necessarily help either, I'm afraid.
>
> In case the GPIO (or the key_pressed() call) does debouncing, you
> wouldn't need it here.  If the key_pressed() result still is
> bouncy, then the above logic would not debounce it.  What you
> need is some kind of "trigger" where you notice that the line
> levels are changing, and a delayed fetch of the lines' values
> after they have settled.  Without the first condition, you always
> have the risk of sampling arbitrary data that does not reflect
> the keys' status.
>
> nit: The comment still appears to be misleading, you don't want
> to avoid debouncing. :)
>
>
> virtually yours
> Gerhard Sittig
>

This is right notice. Actually the problem was not a key bouncing.
The right problem is about the menu loop where check_keys() is called 
too many times for a one second.
And changing menu position few times in a second is useless and hard to 
choose proper menu option.

Putting delay into check_keys() function was good enough to make this 
menu more useful but in fact this was not a solution for key bouncing.

Function check_keys() should be as fast as it could be.
So I think that I need only increase a delay in the menu loop which is 
now 100ms.

Increasing it to 200ms gives good results. It's a simple solution.

What do you think about this?

Thank you for comments.
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

  parent reply	other threads:[~2014-04-30 10:10 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28 14:30 [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options Przemyslaw Marczak
2014-02-28 14:30 ` [U-Boot] [PATCH 1/3] samsung: misc: check_keys(), key_pressed() - remove type static Przemyslaw Marczak
2014-03-06  6:51   ` Minkyu Kang
2014-03-21  9:13     ` Przemyslaw Marczak
2014-02-28 14:30 ` [U-Boot] [PATCH 2/3] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
2014-02-28 14:30 ` [U-Boot] [PATCH 3/3] samsung: misc: add env default " Przemyslaw Marczak
2014-02-28 14:36 ` [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options Przemyslaw Marczak
2014-04-02  9:41 ` [U-Boot] [PATCH v2 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
2014-04-02  9:41   ` [U-Boot] [PATCH v2 2/4] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
2014-04-02  9:42   ` [U-Boot] [PATCH v2 3/4] samsung: misc: add env default " Przemyslaw Marczak
2014-04-02  9:42   ` [U-Boot] [PATCH v2 4/4] samsung: misc: keys: fix gpio key debouncing by adding 50 ms delay Przemyslaw Marczak
2014-04-02 17:26     ` Gerhard Sittig
2014-04-03  7:03       ` Przemyslaw Marczak
2014-04-03  8:27 ` [U-Boot] [PATCH v3 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
2014-04-03  8:27   ` [U-Boot] [PATCH v3 2/4] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
2014-04-03  8:27   ` [U-Boot] [PATCH v3 3/4] samsung: misc: add env default " Przemyslaw Marczak
2014-04-03  8:27   ` [U-Boot] [PATCH v3 4/4] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay Przemyslaw Marczak
2014-04-25 10:20   ` [U-Boot] [PATCH v4 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
2014-04-25 10:20     ` [U-Boot] [PATCH v4 2/5] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
2014-04-25 10:20     ` [U-Boot] [PATCH v4 3/5] samsung: misc: add env default " Przemyslaw Marczak
2014-04-25 10:20     ` [U-Boot] [PATCH v4 4/5] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay Przemyslaw Marczak
2014-04-28 13:44       ` Gerhard Sittig
2014-04-28 14:03         ` Gerhard Sittig
2014-04-30 10:10         ` Przemyslaw Marczak [this message]
2014-04-25 10:20     ` [U-Boot] [PATCH v4 5/5] samsung: misc: remove download mode info screen Przemyslaw Marczak
2014-04-30 11:28     ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
2014-04-30 11:28       ` [U-Boot] [PATCH v5 2/5] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
2014-05-08  2:36         ` Minkyu Kang
2014-04-30 11:28       ` [U-Boot] [PATCH v5 3/5] samsung: misc: add env default " Przemyslaw Marczak
2014-05-08  2:36         ` Minkyu Kang
2014-04-30 11:28       ` [U-Boot] [PATCH v5 4/5] samsung: misc: menu: increase delay in menu main loop Przemyslaw Marczak
2014-05-05 13:35         ` Gerhard Sittig
2014-05-06  8:32           ` Przemyslaw Marczak
2014-05-08  2:36         ` Minkyu Kang
2014-04-30 11:28       ` [U-Boot] [PATCH v5 5/5] samsung: misc: remove download mode info screen Przemyslaw Marczak
2014-05-05 13:27         ` Minkyu Kang
2014-05-06  8:45           ` Przemyslaw Marczak
2014-05-07  8:07             ` Minkyu Kang
2014-05-08  2:36         ` Minkyu Kang
2014-05-08  2:36       ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Minkyu Kang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5360CC13.40706@samsung.com \
    --to=p.marczak@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox