summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/as3525/sansa-clip/button-clip.c19
-rw-r--r--firmware/target/arm/as3525/sansa-m200v4/button-m200v4.c24
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 @@
22 ****************************************************************************/ 22 ****************************************************************************/
23#include "button-target.h" 23#include "button-target.h"
24#include "as3525.h" 24#include "as3525.h"
25#ifndef BOOTLOADER
26#include "backlight.h"
27#endif
25 28
26/* The Sansa Clip uses a button matrix that is scanned by selecting one of 29/* The Sansa Clip uses a button matrix that is scanned by selecting one of
27 three rows and reading back the button states from the columns. 30 three rows and reading back the button states from the columns.
@@ -124,5 +127,19 @@ int button_read_device(void)
124 127
125bool button_hold(void) 128bool button_hold(void)
126{ 129{
127 return (GPIOA_PIN(3) != 0); 130#ifndef BOOTLOADER
131 static bool hold_button_old = false;
132#endif
133 bool hold_button = (GPIOA_PIN(3) != 0);
134
135#ifndef BOOTLOADER
136 /* light handling */
137 if (hold_button != hold_button_old)
138 {
139 hold_button_old = hold_button;
140 backlight_hold_changed(hold_button);
141 }
142#endif /* BOOTLOADER */
143
144 return hold_button;
128} 145}
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 @@
23#include "cpu.h" 23#include "cpu.h"
24#include "button.h" 24#include "button.h"
25 25
26#ifndef BOOTLOADER
27#include "backlight.h"
28#endif
29
26void button_init_device(void) 30void button_init_device(void)
27{ 31{
28 GPIOA_DIR &= ~((1<<3) | (1<<2) | (1<<1) | (1<<0)); /* A3-A0 is input */ 32 GPIOA_DIR &= ~((1<<3) | (1<<2) | (1<<1) | (1<<0)); /* A3-A0 is input */
@@ -89,12 +93,24 @@ int button_read_device(void)
89 93
90bool button_hold(void) 94bool button_hold(void)
91{ 95{
92 bool ret = false; 96#ifndef BOOTLOADER
97 static bool hold_button_old = false;
98#endif
99 bool hold_button = false;
93 100
94 GPIOA_PIN(6) = (1<<6); 101 GPIOA_PIN(6) = (1<<6);
95 if (GPIOA_PIN(2)) 102 if (GPIOA_PIN(2))
96 ret = true; 103 hold_button = true;
97 GPIOA_PIN(6) = 0x00; 104 GPIOA_PIN(6) = 0x00;
98 105
99 return ret; 106#ifndef BOOTLOADER
107 /* light handling */
108 if (hold_button != hold_button_old)
109 {
110 hold_button_old = hold_button;
111 backlight_hold_changed(hold_button);
112 }
113#endif /* BOOTLOADER */
114
115 return hold_button;
100} 116}