Improve live clock performance when loading pattern data. If the clock is playing, only load pattern and tempo, do not load global settings which impact performance.

Refactor the save / load state use of disabling interrupts by wrapping all private methods from inside the public method. This ensures we will not have a race condition if an interrupt is called in between the private method calls.
This commit is contained in:
2026-02-21 10:45:13 -08:00
parent 624d453b9d
commit 62a74fe3ee
4 changed files with 58 additions and 28 deletions

View File

@ -244,8 +244,16 @@ void HandleEncoderPressed() {
if (app.selected_param == PARAM_MAIN_LOAD_DATA) {
if (app.selected_sub_param < StateManager::MAX_SAVE_SLOTS) {
app.selected_save_slot = app.selected_sub_param;
// Load pattern data into app state.
stateManager.loadData(app, app.selected_save_slot);
InitGravity(app);
// Load global performance settings if they have changed.
if (gravity.clock.Tempo() != app.tempo) {
gravity.clock.SetTempo(app.tempo);
}
// Load global settings only if clock is not active.
if (gravity.clock.IsPaused()) {
InitGravity(app);
}
}
}
if (app.selected_param == PARAM_MAIN_RESET_STATE) {