summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugin.c2
-rw-r--r--apps/plugin.h2
-rw-r--r--firmware/drivers/button.c10
-rw-r--r--firmware/export/button.h1
-rw-r--r--firmware/export/powermgmt.h1
-rw-r--r--firmware/powermgmt.c9
-rw-r--r--uisimulator/win32/button.c4
7 files changed, 18 insertions, 11 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index a990463b8c..b7646c021d 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -240,6 +240,8 @@ static struct plugin_api rockbox_api = {
240#ifdef HAVE_LCD_CHARCELLS 240#ifdef HAVE_LCD_CHARCELLS
241 lcd_icon, 241 lcd_icon,
242#endif 242#endif
243
244 reset_poweroff_timer,
243}; 245};
244 246
245int plugin_load(char* plugin, void* parameter) 247int plugin_load(char* plugin, void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index ec16376b11..1405ba3924 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -276,6 +276,8 @@ struct plugin_api {
276#ifdef HAVE_LCD_CHARCELLS 276#ifdef HAVE_LCD_CHARCELLS
277 void (*lcd_icon)(int icon, bool enable); 277 void (*lcd_icon)(int icon, bool enable);
278#endif 278#endif
279
280 void (*reset_poweroff_timer)(void);
279}; 281};
280 282
281/* defined by the plugin loader (plugin.c) */ 283/* defined by the plugin loader (plugin.c) */
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index f3b90211cd..9f19bc0945 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -31,10 +31,10 @@
31#include "serial.h" 31#include "serial.h"
32#include "power.h" 32#include "power.h"
33#include "system.h" 33#include "system.h"
34#include "powermgmt.h"
34 35
35struct event_queue button_queue; 36struct event_queue button_queue;
36 37
37long last_keypress;
38static int lastbtn; 38static int lastbtn;
39#ifdef HAVE_RECORDER_KEYPAD 39#ifdef HAVE_RECORDER_KEYPAD
40static bool flipped; /* bottons can be flipped to match the LCD flip */ 40static bool flipped; /* bottons can be flipped to match the LCD flip */
@@ -141,7 +141,7 @@ static void button_tick(void)
141 queue_post(&button_queue, btn, NULL); 141 queue_post(&button_queue, btn, NULL);
142 backlight_on(); 142 backlight_on();
143 143
144 last_keypress = current_tick; 144 reset_poweroff_timer();
145 } 145 }
146 } 146 }
147 else 147 else
@@ -216,7 +216,7 @@ void button_init()
216 queue_init(&button_queue); 216 queue_init(&button_queue);
217 lastbtn = 0; 217 lastbtn = 0;
218 tick_add_task(button_tick); 218 tick_add_task(button_tick);
219 last_keypress = current_tick; 219 reset_poweroff_timer();
220 flipped = false; 220 flipped = false;
221} 221}
222 222
@@ -359,7 +359,7 @@ void button_init(void)
359 lastbtn = 0; 359 lastbtn = 0;
360 tick_add_task(button_tick); 360 tick_add_task(button_tick);
361 361
362 last_keypress = current_tick; 362 reset_poweroff_timer();
363} 363}
364 364
365static int button_read(void) 365static int button_read(void)
@@ -396,7 +396,7 @@ void button_init(void)
396 lastbtn = 0; 396 lastbtn = 0;
397 tick_add_task(button_tick); 397 tick_add_task(button_tick);
398 398
399 last_keypress = current_tick; 399 reset_poweroff_timer();
400} 400}
401int button_read(void) 401int button_read(void)
402{ 402{
diff --git a/firmware/export/button.h b/firmware/export/button.h
index efe3684473..d1d5ddea5c 100644
--- a/firmware/export/button.h
+++ b/firmware/export/button.h
@@ -24,7 +24,6 @@
24#include "config.h" 24#include "config.h"
25 25
26extern struct event_queue button_queue; 26extern struct event_queue button_queue;
27extern long last_keypress;
28 27
29void button_init (void); 28void button_init (void);
30int button_get (bool block); 29int button_get (bool block);
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index 72a36b04bf..eb0ba29f28 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -100,5 +100,6 @@ void set_battery_capacity(int capacity); /* set local battery capacity value */
100void set_sleep_timer(int seconds); 100void set_sleep_timer(int seconds);
101int get_sleep_timer(void); 101int get_sleep_timer(void);
102void set_car_adapter_mode(bool setting); 102void set_car_adapter_mode(bool setting);
103void reset_poweroff_timer(void);
103 104
104#endif 105#endif
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 61006459ff..aade687ba8 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -38,6 +38,13 @@
38#include "fmradio.h" 38#include "fmradio.h"
39#endif 39#endif
40 40
41long last_event_tick;
42
43void reset_poweroff_timer(void)
44{
45 last_event_tick = current_tick;
46}
47
41#ifdef SIMULATOR 48#ifdef SIMULATOR
42 49
43int battery_level(void) 50int battery_level(void)
@@ -316,7 +323,7 @@ static void handle_auto_poweroff(void)
316 ((mpeg_stat == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE)) && 323 ((mpeg_stat == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE)) &&
317 !sleeptimer_active))) 324 !sleeptimer_active)))
318 { 325 {
319 if(TIME_AFTER(current_tick, last_keypress + timeout) && 326 if(TIME_AFTER(current_tick, last_event_tick + timeout) &&
320 TIME_AFTER(current_tick, last_disk_activity + timeout) && 327 TIME_AFTER(current_tick, last_disk_activity + timeout) &&
321 TIME_AFTER(current_tick, last_charge_time + timeout)) 328 TIME_AFTER(current_tick, last_charge_time + timeout))
322 { 329 {
diff --git a/uisimulator/win32/button.c b/uisimulator/win32/button.c
index 807e08fe22..c9bd1ad04e 100644
--- a/uisimulator/win32/button.c
+++ b/uisimulator/win32/button.c
@@ -33,7 +33,6 @@
33/* speed repeat finishes at */ 33/* speed repeat finishes at */
34#define REPEAT_INTERVAL_FINISH 2 34#define REPEAT_INTERVAL_FINISH 2
35 35
36long last_keypress;
37struct event_queue button_queue; 36struct event_queue button_queue;
38 37
39void button_event(int key, bool pressed) 38void button_event(int key, bool pressed)
@@ -160,8 +159,6 @@ void button_event(int key, bool pressed)
160 queue_post(&button_queue, btn, NULL); 159 queue_post(&button_queue, btn, NULL);
161 160
162 backlight_on(); 161 backlight_on();
163
164 last_keypress = current_tick;
165 } 162 }
166 } 163 }
167 else 164 else
@@ -175,7 +172,6 @@ void button_event(int key, bool pressed)
175 172
176void button_init(void) 173void button_init(void)
177{ 174{
178 last_keypress = 0;
179} 175}
180 176
181/* Again copied from real button.c... */ 177/* Again copied from real button.c... */