Sansa Clip & m200v4 : calls backlight_hold_changed() when hold button is toggled

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22323 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Rafaël Carré 2009-08-15 15:02:51 +00:00
parent bd4fc82b3b
commit 6932fa397b
2 changed files with 38 additions and 5 deletions

View file

@ -22,6 +22,9 @@
****************************************************************************/ ****************************************************************************/
#include "button-target.h" #include "button-target.h"
#include "as3525.h" #include "as3525.h"
#ifndef BOOTLOADER
#include "backlight.h"
#endif
/* The Sansa Clip uses a button matrix that is scanned by selecting one of /* The Sansa Clip uses a button matrix that is scanned by selecting one of
three rows and reading back the button states from the columns. three rows and reading back the button states from the columns.
@ -124,5 +127,19 @@ int button_read_device(void)
bool button_hold(void) bool button_hold(void)
{ {
return (GPIOA_PIN(3) != 0); #ifndef BOOTLOADER
static bool hold_button_old = false;
#endif
bool hold_button = (GPIOA_PIN(3) != 0);
#ifndef BOOTLOADER
/* light handling */
if (hold_button != hold_button_old)
{
hold_button_old = hold_button;
backlight_hold_changed(hold_button);
}
#endif /* BOOTLOADER */
return hold_button;
} }

View file

@ -23,6 +23,10 @@
#include "cpu.h" #include "cpu.h"
#include "button.h" #include "button.h"
#ifndef BOOTLOADER
#include "backlight.h"
#endif
void button_init_device(void) void button_init_device(void)
{ {
GPIOA_DIR &= ~((1<<3) | (1<<2) | (1<<1) | (1<<0)); /* A3-A0 is input */ GPIOA_DIR &= ~((1<<3) | (1<<2) | (1<<1) | (1<<0)); /* A3-A0 is input */
@ -89,12 +93,24 @@ int button_read_device(void)
bool button_hold(void) bool button_hold(void)
{ {
bool ret = false; #ifndef BOOTLOADER
static bool hold_button_old = false;
#endif
bool hold_button = false;
GPIOA_PIN(6) = (1<<6); GPIOA_PIN(6) = (1<<6);
if (GPIOA_PIN(2)) if (GPIOA_PIN(2))
ret = true; hold_button = true;
GPIOA_PIN(6) = 0x00; GPIOA_PIN(6) = 0x00;
return ret; #ifndef BOOTLOADER
/* light handling */
if (hold_button != hold_button_old)
{
hold_button_old = hold_button;
backlight_hold_changed(hold_button);
}
#endif /* BOOTLOADER */
return hold_button;
} }