mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
Added debouncing to the Ondio button driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5115 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
7f7afe434b
commit
23f2a59865
1 changed files with 11 additions and 1 deletions
|
@ -458,6 +458,8 @@ void button_init(void)
|
||||||
static int button_read(void)
|
static int button_read(void)
|
||||||
{
|
{
|
||||||
int btn = BUTTON_NONE;
|
int btn = BUTTON_NONE;
|
||||||
|
int retval;
|
||||||
|
|
||||||
int data = adc_read(ADC_BUTTON_ROW1);
|
int data = adc_read(ADC_BUTTON_ROW1);
|
||||||
|
|
||||||
if(adc_read(ADC_BUTTON_OPTION) > 0x200) /* active high */
|
if(adc_read(ADC_BUTTON_OPTION) > 0x200) /* active high */
|
||||||
|
@ -475,7 +477,15 @@ static int button_read(void)
|
||||||
else if (data >= 0x0A1)
|
else if (data >= 0x0A1)
|
||||||
btn |= BUTTON_DOWN;
|
btn |= BUTTON_DOWN;
|
||||||
|
|
||||||
return btn;
|
/* Filter the button status. It is only accepted if we get the same
|
||||||
|
status twice in a row. */
|
||||||
|
if(btn != last_read)
|
||||||
|
retval = lastbtn;
|
||||||
|
else
|
||||||
|
retval = btn;
|
||||||
|
last_read = btn;
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue