From 6932fa397ba9b9cc99ec248602f43aba8e1f86c9 Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Sat, 15 Aug 2009 15:02:51 +0000 Subject: 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 --- .../target/arm/as3525/sansa-clip/button-clip.c | 19 ++++++++++++++++- .../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; } -- cgit v1.2.3