Index: apps/settings.c =================================================================== --- apps/settings.c (revision 15216) +++ apps/settings.c (working copy) @@ -727,6 +727,9 @@ #if BATTERY_TYPES_COUNT > 1 set_battery_type(global_settings.battery_type); #endif +#ifdef POWEROFF_NOW_BUTTON + set_poweroff_on_hold(global_settings.poweroff_on_hold); +#endif #ifdef HAVE_LCD_BITMAP lcd_set_invert_display(global_settings.invert); Index: apps/lang/english.lang =================================================================== --- apps/lang/english.lang (revision 15216) +++ apps/lang/english.lang (working copy) @@ -11417,3 +11417,20 @@ *: "Blank" + + id: LANG_POWEROFF_ON_HOLD + desc: system setting + user: + + *: none + poweroff_now_button: "Poweroff on hold" + + + *: none + poweroff_now_button: "Poweroff on hold" + + + *: none + poweroff_now_button: "Power off on hold" + + Index: apps/settings.h =================================================================== --- apps/settings.h (revision 15216) +++ apps/settings.h (working copy) @@ -469,6 +469,9 @@ bool peak_meter_clipcounter; /* clipping count indicator */ #endif bool car_adapter_mode; /* 0=off 1=on */ +#ifdef HAS_POWEROFF_NOW_BUTTON + bool poweroff_on_hold; /* 0=no 1=yes */ +#endif /* show status bar */ bool statusbar; /* 0=hide, 1=show */ Index: apps/menus/settings_menu.c =================================================================== --- apps/menus/settings_menu.c (revision 15216) +++ apps/menus/settings_menu.c (working copy) @@ -334,6 +334,9 @@ #if CONFIG_CHARGING MENUITEM_SETTING(car_adapter_mode, &global_settings.car_adapter_mode, NULL); #endif +#ifdef HAS_POWEROFF_NOW_BUTTON +MENUITEM_SETTING(poweroff_on_hold, &global_settings.poweroff_on_hold, NULL); +#endif MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL); #ifdef HAVE_BUTTON_LIGHT @@ -370,6 +373,9 @@ #if CONFIG_CHARGING &car_adapter_mode, #endif +#ifdef HAS_POWEROFF_NOW_BUTTON + &poweroff_on_hold, +#endif #ifdef HAVE_BUTTON_LIGHT &buttonlight_timeout, #endif Index: apps/settings_list.c =================================================================== --- apps/settings_list.c (revision 15216) +++ apps/settings_list.c (working copy) @@ -510,6 +510,10 @@ OFFON_SETTING(NVRAM(1), car_adapter_mode, LANG_CAR_ADAPTER_MODE, false, "car adapter mode", NULL), #endif +#ifdef HAS_POWEROFF_NOW_BUTTON + OFFON_SETTING(0, poweroff_on_hold, LANG_POWEROFF_ON_HOLD, false, + "poweroff on hold", set_poweroff_on_hold), +#endif /* tuner */ #if CONFIG_TUNER OFFON_SETTING(0,fm_force_mono, LANG_FM_MONO_MODE, Index: apps/features.txt =================================================================== --- apps/features.txt (revision 15216) +++ apps/features.txt (working copy) @@ -156,3 +156,7 @@ #if defined(HAVE_USBSTACK) usbstack #endif + +#ifdef HAS_POWEROFF_NOW_BUTTON +poweroff_now_button +#endif Index: firmware/export/button.h =================================================================== --- firmware/export/button.h (revision 15216) +++ firmware/export/button.h (working copy) @@ -36,6 +36,9 @@ #ifdef HAVE_LCD_BITMAP void button_set_flip(bool flip); /* turn 180 degrees */ #endif +#ifdef HAS_POWEROFF_NOW_BUTTON +void set_poweroff_on_hold(bool yesno); +#endif #ifdef HAVE_BACKLIGHT void set_backlight_filter_keypress(bool value); #ifdef HAVE_REMOTE_LCD Index: firmware/target/arm/sandisk/sansa-e200/button-e200.c =================================================================== --- firmware/target/arm/sandisk/sansa-e200/button-e200.c (revision 15216) +++ firmware/target/arm/sandisk/sansa-e200/button-e200.c (working copy) @@ -280,6 +280,9 @@ } #endif /* BOOTLOADER */ + if (hold_button) + int_btn |= BUTTON_HOLD_ON; + /* The int_btn variable is set in the button interrupt handler */ return int_btn; } Index: firmware/target/arm/sandisk/sansa-e200/button-target.h =================================================================== --- firmware/target/arm/sandisk/sansa-e200/button-target.h (revision 15216) +++ firmware/target/arm/sandisk/sansa-e200/button-target.h (working copy) @@ -24,6 +24,7 @@ #include "config.h" #define HAS_BUTTON_HOLD +#define HAS_POWEROFF_NOW_BUTTON bool button_hold(void); void button_init_device(void); @@ -43,6 +44,8 @@ #define BUTTON_SCROLL_UP 0x00000080 #define BUTTON_SCROLL_DOWN 0x00000100 +#define BUTTON_HOLD_ON 0x00000200 + #define BUTTON_MAIN 0x00000fff /* No Remote control */ @@ -50,5 +53,6 @@ #define POWEROFF_BUTTON BUTTON_POWER #define POWEROFF_COUNT 10 +#define POWEROFF_NOW_BUTTON BUTTON_HOLD_ON #endif /* _BUTTON_TARGET_H_ */ Index: firmware/target/coldfire/iaudio/m5/button-m5.c =================================================================== --- firmware/target/coldfire/iaudio/m5/button-m5.c (revision 15216) +++ firmware/target/coldfire/iaudio/m5/button-m5.c (working copy) @@ -156,5 +156,8 @@ if (!remote_hold_button && !(data & 0x02000000)) btn |= BUTTON_RC_PLAY; + if (hold_button) + btn |= BUTTON_HOLD_ON; + return btn; } Index: firmware/target/coldfire/iaudio/button-target.h =================================================================== --- firmware/target/coldfire/iaudio/button-target.h (revision 15216) +++ firmware/target/coldfire/iaudio/button-target.h (working copy) @@ -24,6 +24,7 @@ #define HAS_BUTTON_HOLD #define HAS_REMOTE_BUTTON_HOLD +#define HAS_POWEROFF_NOW_BUTTON bool button_hold(void); bool remote_button_hold(void); @@ -46,8 +47,10 @@ #define BUTTON_PLAY 0x00000040 #define BUTTON_SELECT 0x00000080 +#define BUTTON_HOLD_ON 0x00000100 + #define BUTTON_MAIN (BUTTON_POWER|BUTTON_PLAY|BUTTON_LEFT|BUTTON_RIGHT\ - |BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_SELECT) + |BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_SELECT|BUTTON_HOLD_ON) /* Remote control's buttons */ #define BUTTON_RC_PLAY 0x00100000 @@ -67,6 +70,7 @@ |BUTTON_RC_REC|BUTTON_RC_MENU|BUTTON_RC_MODE) #define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_NOW_BUTTON BUTTON_HOLD_ON #define RC_POWEROFF_BUTTON BUTTON_RC_PLAY #define POWEROFF_COUNT 30 Index: firmware/target/coldfire/iaudio/x5/button-x5.c =================================================================== --- firmware/target/coldfire/iaudio/x5/button-x5.c (revision 15216) +++ firmware/target/coldfire/iaudio/x5/button-x5.c (working copy) @@ -156,5 +156,8 @@ if (!remote_hold_button && !(data & 0x02000000)) btn |= BUTTON_RC_PLAY; + if (hold_button) + btn |= BUTTON_HOLD_ON; + return btn; } Index: firmware/drivers/button.c =================================================================== --- firmware/drivers/button.c (revision 15216) +++ firmware/drivers/button.c (working copy) @@ -54,6 +54,9 @@ #ifdef HAVE_LCD_BITMAP static bool flipped; /* buttons can be flipped to match the LCD flip */ #endif +#ifdef HAS_POWEROFF_NOW_BUTTON +static bool do_poweroff_on_hold = false; +#endif #ifdef HAVE_BACKLIGHT static bool filter_first_keypress; #ifdef HAVE_REMOTE_LCD @@ -88,6 +91,9 @@ static bool skip_remote_release = false; #endif #endif +#ifdef HAS_POWEROFF_NOW_BUTTON + static long shutdown_tick = 0; +#endif int diff; int btn; @@ -119,6 +125,20 @@ btn = button_read(); +#ifdef HAS_POWEROFF_NOW_BUTTON + if((btn & POWEROFF_NOW_BUTTON) && do_poweroff_on_hold +#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) + && !charger_inserted() +#endif + && shutdown_tick == 0) + { + shutdown_tick = current_tick; + sys_poweroff(); + } else if(shutdown_tick && TIME_AFTER(current_tick, shutdown_tick +10*HZ)) + /* Safety net */ + power_off(); +#endif + /* Find out if a key has been released */ diff = btn ^ lastbtn; if(diff && (btn & diff) == 0) @@ -441,6 +461,13 @@ } #endif /* HAVE_LCD_BITMAP */ +#ifdef HAS_POWEROFF_NOW_BUTTON +void set_poweroff_on_hold(bool yesno) +{ + do_poweroff_on_hold = yesno; +} +#endif + #ifdef HAVE_BACKLIGHT void set_backlight_filter_keypress(bool value) {