diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index 7d142b0311..1f5e8706f9 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c @@ -564,6 +564,9 @@ bool option_screen(const struct settings_list *setting, /* callback */ if ( function ) function(*variable); + /* if the volume is changing we need to let the skins know */ + if (function == sound_get_fn(SOUND_VOLUME)) + global_status.last_volume_change = current_tick; } return false; } diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 434e7c9fa5..7f6e80d108 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -1632,7 +1632,6 @@ void skin_data_reset(struct wps_data *wps_data) #endif wps_data->tokens = NULL; wps_data->num_tokens = 0; - wps_data->button_time_volume = 0; #ifdef HAVE_LCD_BITMAP wps_data->peak_meter_enabled = false; diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index aeb7bdbbde..5156dd7ce7 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -818,8 +818,8 @@ const char *get_token_value(struct gui_wps *gwps, return NULL; #endif case WPS_TOKEN_BUTTON_VOLUME: - if (data->button_time_volume && - TIME_BEFORE(current_tick, data->button_time_volume + + if (global_status.last_volume_change && + TIME_BEFORE(current_tick, global_status.last_volume_change + token->value.i * TIMEOUT_UNIT)) return "v"; return NULL; diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 1fd68646ad..d54b54ff00 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h @@ -264,8 +264,6 @@ struct wps_data /* Total number of tokens in the WPS. During WPS parsing, this is the index of the token being parsed. */ int num_tokens; - /* tick the volume button was last pressed */ - unsigned int button_time_volume; #ifdef HAVE_LCD_BITMAP bool peak_meter_enabled; diff --git a/apps/gui/wps.c b/apps/gui/wps.c index e449644502..441ac3f9d8 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -1130,8 +1130,6 @@ long gui_wps_show(void) if (vol_changed) { - FOR_NB_SCREENS(i) - gui_wps[i].data->button_time_volume = current_tick; bool res = false; setvol(); FOR_NB_SCREENS(i) diff --git a/apps/main.c b/apps/main.c index 4c7d48e2d9..677eeb5b21 100644 --- a/apps/main.c +++ b/apps/main.c @@ -158,6 +158,7 @@ static void app_main(void) } #endif /* #ifdef AUTOROCK */ + global_status.last_volume_change = 0; root_menu(); } diff --git a/apps/misc.c b/apps/misc.c index 6be9f8f010..f1c38f376c 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -739,6 +739,7 @@ void setvol(void) if (global_settings.volume > max_vol) global_settings.volume = max_vol; sound_set_volume(global_settings.volume); + global_status.last_volume_change = current_tick; settings_save(); } diff --git a/apps/settings.h b/apps/settings.h index 07f6f22efb..6de820807f 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -308,6 +308,7 @@ struct system_status #endif signed char last_screen; int viewer_icon_count; + int last_volume_change; /* tick the last volume change happened. skins use this */ }; struct user_settings