diff options
-rw-r--r-- | firmware/target/arm/as3525/sansa-clip/button-clip.c | 19 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-m200v4/button-m200v4.c | 24 |
2 files changed, 38 insertions, 5 deletions
diff --git a/firmware/target/arm/as3525/sansa-clip/button-clip.c b/firmware/target/arm/as3525/sansa-clip/button-clip.c index 0d4e3a6306..99a68a506d 100644 --- a/firmware/target/arm/as3525/sansa-clip/button-clip.c +++ b/firmware/target/arm/as3525/sansa-clip/button-clip.c @@ -22,6 +22,9 @@ ****************************************************************************/ #include "button-target.h" #include "as3525.h" +#ifndef BOOTLOADER +#include "backlight.h" +#endif /* 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. @@ -124,5 +127,19 @@ int button_read_device(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; } diff --git a/firmware/target/arm/as3525/sansa-m200v4/button-m200v4.c b/firmware/target/arm/as3525/sansa-m200v4/button-m200v4.c index 5220fc4925..af57f97051 100644 --- a/firmware/target/arm/as3525/sansa-m200v4/button-m200v4.c +++ b/firmware/target/arm/as3525/sansa-m200v4/button-m200v4.c @@ -23,6 +23,10 @@ #include "cpu.h" #include "button.h" +#ifndef BOOTLOADER +#include "backlight.h" +#endif + void button_init_device(void) { 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 ret = false; +#ifndef BOOTLOADER + static bool hold_button_old = false; +#endif + bool hold_button = false; GPIOA_PIN(6) = (1<<6); if (GPIOA_PIN(2)) - ret = true; + hold_button = true; 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; } |