From 977bc698db176c1886b2d716e8ef4d90a45f335e Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Mon, 20 Mar 2023 18:44:07 -0400 Subject: [Feature] lastfm_scrobbler add option to set beep volume level Change-Id: Id045f0f844b67f07ba5cd47d084f5d8f1841dad8 --- apps/plugins/lastfm_scrobbler.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/apps/plugins/lastfm_scrobbler.c b/apps/plugins/lastfm_scrobbler.c index 3269f1820b..5565eed4c5 100644 --- a/apps/plugins/lastfm_scrobbler.c +++ b/apps/plugins/lastfm_scrobbler.c @@ -101,15 +101,17 @@ static struct static struct { int savepct; + int beeplvl; bool playback; bool verbose; } gConfig; static struct configdata config[] = { - {TYPE_INT, 0, 100, { .int_p = &gConfig.savepct }, "SavePct", NULL}, - {TYPE_BOOL, 0, 1, { .bool_p = &gConfig.playback }, "Playback", NULL}, - {TYPE_BOOL, 0, 1, { .bool_p = &gConfig.verbose }, "Verbose", NULL}, + {TYPE_INT, 0, 100, { .int_p = &gConfig.savepct }, "SavePct", NULL}, + {TYPE_BOOL, 0, 1, { .bool_p = &gConfig.playback }, "Playback", NULL}, + {TYPE_BOOL, 0, 1, { .bool_p = &gConfig.verbose }, "Verbose", NULL}, + {TYPE_INT, 0, 10, { .int_p = &gConfig.beeplvl }, "BeepLvl", NULL}, }; const int gCfg_sz = sizeof(config)/sizeof(*config); /****************** config functions *****************/ @@ -118,6 +120,7 @@ static void config_set_defaults(void) gConfig.savepct = 50; gConfig.playback = false; gConfig.verbose = true; + gConfig.beeplvl = 10; } static int config_settings_menu(void) @@ -135,6 +138,7 @@ static int config_settings_menu(void) ID2P(LANG_RESUME_PLAYBACK), "Save Threshold", "Verbose", + "Beep Level", ID2P(VOICE_BLANK), ID2P(LANG_CANCEL_0), ID2P(LANG_SAVE_EXIT)); @@ -153,12 +157,15 @@ static int config_settings_menu(void) case 2: rb->set_bool("Verbose", &gConfig.verbose); break; - case 3: /*sep*/ + case 3: + rb->set_int("Beep Level", "", UNIT_INT, + &gConfig.beeplvl, NULL, 1, 0, 10, NULL); + case 4: /*sep*/ continue; - case 4: + case 5: return -1; break; - case 5: + case 6: { int res = configfile_save(CFG_FILE, config, gCfg_sz, CFG_VER); if (res >= 0) @@ -469,7 +476,8 @@ void thread(void) /*fall through*/ case EV_STARTUP: events_register(); - rb->beep_play(1500, 100, 1000); + if (gConfig.beeplvl > 0) + rb->beep_play(1500, 100, 100 * gConfig.beeplvl); break; case SYS_POWEROFF: case SYS_REBOOT: @@ -595,6 +603,8 @@ enum plugin_status plugin_start(const void* parameter) if (scrobbler_init() < 0) return PLUGIN_ERROR; + config_set_defaults(); + if (configfile_load(CFG_FILE, config, gCfg_sz, CFG_VER) < 0) { /* If the loading failed, save a new config file */ -- cgit v1.2.3