diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2003-02-25 03:03:55 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2003-02-25 03:03:55 +0000 |
commit | 561a06ed7500d817590fe0d3db9a45dd666964c5 (patch) | |
tree | df287a0dca0debfc3e406688e178a4282f2ba102 /firmware | |
parent | 45a8413be79cee854fe2b4f76981e34740ccd52a (diff) | |
download | rockbox-561a06ed7500d817590fe0d3db9a45dd666964c5.tar.gz rockbox-561a06ed7500d817590fe0d3db9a45dd666964c5.zip |
Faster shutoff with OFF key on FM Recorder
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3331 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/button.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 69d041f65e..025c8cf77d 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -47,6 +47,9 @@ long last_keypress; | |||
47 | /* speed repeat finishes at */ | 47 | /* speed repeat finishes at */ |
48 | #define REPEAT_INTERVAL_FINISH 2 | 48 | #define REPEAT_INTERVAL_FINISH 2 |
49 | 49 | ||
50 | /* Number of repeated keys before shutting off */ | ||
51 | #define POWEROFF_COUNT 8 | ||
52 | |||
50 | static int button_read(void); | 53 | static int button_read(void); |
51 | 54 | ||
52 | static void button_tick(void) | 55 | static void button_tick(void) |
@@ -55,6 +58,7 @@ static void button_tick(void) | |||
55 | static int count = 0; | 58 | static int count = 0; |
56 | static int lastbtn = 0; | 59 | static int lastbtn = 0; |
57 | static int repeat_speed = REPEAT_INTERVAL_START; | 60 | static int repeat_speed = REPEAT_INTERVAL_START; |
61 | static int repeat_count = 0; | ||
58 | static bool repeat = false; | 62 | static bool repeat = false; |
59 | int diff; | 63 | int diff; |
60 | int btn; | 64 | int btn; |
@@ -103,6 +107,27 @@ static void button_tick(void) | |||
103 | if (repeat_speed < REPEAT_INTERVAL_FINISH) | 107 | if (repeat_speed < REPEAT_INTERVAL_FINISH) |
104 | repeat_speed = REPEAT_INTERVAL_FINISH; | 108 | repeat_speed = REPEAT_INTERVAL_FINISH; |
105 | count = repeat_speed; | 109 | count = repeat_speed; |
110 | |||
111 | repeat_count++; | ||
112 | |||
113 | /* Shutdown if we have a device which doesn't shut | ||
114 | down easily with the OFF key */ | ||
115 | #ifdef HAVE_POWEROFF_ON_PB5 | ||
116 | if(btn == BUTTON_OFF && !charger_inserted() && | ||
117 | repeat_count > POWEROFF_COUNT) | ||
118 | power_off(); | ||
119 | #endif | ||
120 | |||
121 | /* Reboot if the OFF button is pressed long enough | ||
122 | and we are connected to a charger. */ | ||
123 | #ifdef HAVE_RECORDER_KEYPAD | ||
124 | if(btn == BUTTON_OFF && charger_inserted() && | ||
125 | repeat_count > POWEROFF_COUNT) | ||
126 | #elif HAVE_PLAYER_KEYPAD | ||
127 | if(btn == BUTTON_STOP && charger_inserted() && | ||
128 | repeat_count > POWEROFF_COUNT) | ||
129 | #endif | ||
130 | system_reboot(); | ||
106 | } | 131 | } |
107 | } | 132 | } |
108 | else | 133 | else |
@@ -111,17 +136,9 @@ static void button_tick(void) | |||
111 | { | 136 | { |
112 | post = true; | 137 | post = true; |
113 | repeat = true; | 138 | repeat = true; |
139 | repeat_count = 0; | ||
114 | /* initial repeat */ | 140 | /* initial repeat */ |
115 | count = REPEAT_INTERVAL_START; | 141 | count = REPEAT_INTERVAL_START; |
116 | |||
117 | /* Reboot if the OFF button is pressed long enough | ||
118 | and we are connected to a charger. */ | ||
119 | #ifdef HAVE_RECORDER_KEYPAD | ||
120 | if(btn == BUTTON_OFF && charger_inserted()) | ||
121 | #elif HAVE_PLAYER_KEYPAD | ||
122 | if(btn == BUTTON_STOP && charger_inserted()) | ||
123 | #endif | ||
124 | system_reboot(); | ||
125 | } | 142 | } |
126 | } | 143 | } |
127 | } | 144 | } |