diff --git a/apps/filetree.c b/apps/filetree.c index 60443a163c..c7a2dbf071 100644 --- a/apps/filetree.c +++ b/apps/filetree.c @@ -447,13 +447,11 @@ int ft_enter(struct tree_context* c) } if ( play ) { - if ( global_settings.resume ) { - /* the resume_index must always be the index in the - shuffled list in case shuffle is enabled */ - global_settings.resume_index = start_index; - global_settings.resume_offset = 0; - settings_save(); - } + /* the resume_index must always be the index in the + shuffled list in case shuffle is enabled */ + global_settings.resume_index = start_index; + global_settings.resume_offset = 0; + settings_save(); start_wps = true; } diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 3b068bf50d..91858fde4e 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -391,12 +391,6 @@ eng: "Is Full!" voice: "" new: -id: LANG_RESUME_ASK -desc: question asked at the begining when resume is on -eng: "Resume?" -voice: "" -new: - id: LANG_RESUME_CONFIRM_PLAYER desc: possible answers to resume question eng: "(PLAY/STOP)" @@ -847,12 +841,6 @@ eng: "Dec" voice: "December" new: -id: LANG_RESUME_SETTING_ASK_ONCE -desc: in settings_menu -eng: "Ask Once" -voice: "Ask Once" -new: - id: LANG_BATTERY_DISPLAY desc: Battery type title eng: "Battery Display" diff --git a/apps/screens.c b/apps/screens.c index 04a32813d1..59ffd06c50 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -693,15 +693,15 @@ bool quick_screen(int context, int button) break; case BUTTON_F3 | BUTTON_RIGHT: -// case BUTTON_F3 | BUTTON_RIGHT | BUTTON_REPEAT: + case BUTTON_F3 | BUTTON_RIGHT | BUTTON_REPEAT: global_settings.statusbar = !global_settings.statusbar; used = true; break; case BUTTON_F3 | BUTTON_DOWN: -// case BUTTON_F3 | BUTTON_DOWN | BUTTON_REPEAT: + case BUTTON_F3 | BUTTON_DOWN | BUTTON_REPEAT: case BUTTON_F3 | BUTTON_UP: -// case BUTTON_F3 | BUTTON_UP | BUTTON_REPEAT: + case BUTTON_F3 | BUTTON_UP | BUTTON_REPEAT: global_settings.flip_display = !global_settings.flip_display; button_set_flip(global_settings.flip_display); lcd_set_flip(global_settings.flip_display); diff --git a/apps/settings.c b/apps/settings.c index 60e41fcfdd..d40223bd78 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -197,7 +197,7 @@ static const struct bit_entry rtc_bits[] = "stereo,mono,custom,mono left,mono right,karaoke" }, {8, S_O(stereo_width), 100, "stereo width", NULL}, /* playback */ - {2, S_O(resume), RESUME_ASK, "resume", "off,ask,ask once,on" }, + {2, S_O(resume), false, "resume", off_on }, {1, S_O(playlist_shuffle), false, "shuffle", off_on }, {16 | SIGNED, S_O(resume_index), -1, NULL, NULL }, {16 | SIGNED, S_O(resume_first_index), 0, NULL, NULL }, diff --git a/apps/settings.h b/apps/settings.h index bb4f5fbf32..d630db7f35 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -78,11 +78,6 @@ /* data structures */ -#define RESUME_OFF 0 -#define RESUME_ASK 1 -#define RESUME_ASK_ONCE 2 -#define RESUME_ON 3 - #define BOOKMARK_NO 0 #define BOOKMARK_YES 1 #define BOOKMARK_ASK 2 @@ -211,7 +206,7 @@ struct user_settings /* resume settings */ - int resume; /* resume option: 0=off, 1=ask, 2=on */ + bool resume; /* resume option: 0=off, 1=on */ int resume_index; /* index in playlist (-1 for no active resume) */ int resume_first_index; /* index of first track in playlist */ int resume_offset; /* byte offset in mp3 file */ diff --git a/apps/settings_menu.c b/apps/settings_menu.c index b10c7d32ab..5dcf66789f 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c @@ -656,14 +656,7 @@ static bool sort_dir(void) static bool resume(void) { - static const struct opt_items names[] = { - { STR(LANG_SET_BOOL_NO) }, - { STR(LANG_RESUME_SETTING_ASK) }, - { STR(LANG_RESUME_SETTING_ASK_ONCE) }, - { STR(LANG_SET_BOOL_YES) } - }; - return set_option( str(LANG_RESUME), &global_settings.resume, INT, - names, 4, NULL ); + return set_bool( str(LANG_RESUME), &global_settings.resume); } static bool autocreatebookmark(void) diff --git a/apps/tree.c b/apps/tree.c index 6d25203eac..6dcb52d1a4 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -430,92 +430,6 @@ static int showdir(void) return tc.filesindir; } -static bool ask_resume(bool just_powered_on) -{ - int button; - bool stop = false; - static bool ignore_power = true; - -#ifdef HAVE_LCD_CHARCELLS - lcd_double_height(false); -#endif - -#ifdef HAVE_ALARM_MOD - if ( rtc_check_alarm_started(true) ) { - rtc_enable_alarm(false); - return true; - } -#endif - - /* always resume? */ - if ( global_settings.resume == RESUME_ON || ! just_powered_on) - return true; - - lcd_clear_display(); - lcd_puts(0,0,str(LANG_RESUME_ASK)); -#ifdef HAVE_LCD_CHARCELLS - status_draw(false); - lcd_puts(0,1,str(LANG_RESUME_CONFIRM_PLAYER)); -#else - lcd_puts(0,1,str(LANG_CONFIRM_WITH_PLAY_RECORDER)); - lcd_puts(0,2,str(LANG_CANCEL_WITH_ANY_RECORDER)); -#endif - lcd_update(); - - while (!stop) { - button = button_get(true); - switch (button) { -#ifdef TREE_RUN_PRE - case TREE_RUN_PRE: /* catch the press, not the release */ -#else - case TREE_RUN: -#endif - -#ifdef TREE_RC_RUN_PRE - case TREE_RC_RUN_PRE: /* catch the press, not the release */ -#else -#ifdef TREE_RC_RUN - case TREE_RC_RUN: -#endif -#endif - ignore_power = false; - /* Don't ignore the power button for subsequent calls */ - return true; - -#ifdef TREE_POWER_BTN - /* Initially ignore the button which powers on the box. It - * might still be pressed since booting. */ - case TREE_POWER_BTN: - case TREE_POWER_BTN | BUTTON_REPEAT: - if(!ignore_power) - stop = true; - break; - - /* No longer ignore the power button after it was released */ - case TREE_POWER_BTN | BUTTON_REL: - ignore_power = false; - break; -#endif - - /* Handle sys events, ignore button releases */ - default: - if(default_event_handler(button) == SYS_USB_CONNECTED || - (!IS_SYSEVENT(button) && !(button & BUTTON_REL))) - stop = true; - break; - } - } - - if ( global_settings.resume == RESUME_ASK_ONCE && just_powered_on) { - global_settings.resume_index = -1; - settings_save(); - } - - ignore_power = false; - /* Don't ignore the power button for subsequent calls */ - return false; -} - /* load tracks from specified directory to resume play */ void resume_directory(const char *dir) { @@ -549,15 +463,26 @@ void reload_directory(void) static void start_resume(bool just_powered_on) { - if ( ( global_settings.resume || ! just_powered_on ) && - global_settings.resume_index != -1 ) { + bool do_resume = false; + + if ( global_settings.resume_index != -1 ) { DEBUGF("Resume index %X offset %X\n", global_settings.resume_index, global_settings.resume_offset); - if (!ask_resume(just_powered_on) ) - return; +#ifdef HAVE_ALARM_MOD + if ( rtc_check_alarm_started(true) ) { + rtc_enable_alarm(false); + do_resume = true; + } +#endif + /* always resume? */ + if ( global_settings.resume || ! just_powered_on) + do_resume = true; + + if (! do_resume) return; + if (playlist_resume() != -1) { playlist_start(global_settings.resume_index, diff --git a/apps/wps.c b/apps/wps.c index be0ad448dd..40c9194793 100644 --- a/apps/wps.c +++ b/apps/wps.c @@ -252,7 +252,6 @@ static bool update(void) /* save resume data */ if ( id3 && - global_settings.resume && global_settings.resume_offset != id3->offset ) { if (!playlist_get_resume_info(&global_settings.resume_index)) @@ -391,7 +390,7 @@ long wps_show(void) /* if another thread paused audio, we are probably in car mode, about to shut down. lets save the settings. */ - if (paused && global_settings.resume) { + if (paused) { settings_save(); #ifndef HAVE_RTC ata_flush(); @@ -544,12 +543,10 @@ long wps_show(void) fade(0); else audio_pause(); - if (global_settings.resume) { - settings_save(); + settings_save(); #ifndef HAVE_RTC - ata_flush(); + ata_flush(); #endif - } } break; diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index e644267b19..b2de8b8157 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c @@ -220,7 +220,8 @@ void button_init(void) #endif /* CONFIG_KEYPAD */ queue_init(&button_queue); - lastbtn = 0; + button_read(); + lastbtn = button_read(); tick_add_task(button_tick); reset_poweroff_timer();