Introduce Save/Load banks for storing different preset settings. (#11)
This also includes a lot of minor fixes. Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/11 Co-authored-by: Adam Wonak <adam.wonak@gmail.com> Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
This commit is contained in:
@ -6,20 +6,20 @@
|
||||
* @date 2025-05-04
|
||||
*
|
||||
* @copyright Copyright (c) 2025
|
||||
*
|
||||
*
|
||||
* This version of Gravity firmware is a full rewrite that leverages the
|
||||
* libGravity hardware abstraction library. The goal of this project was to
|
||||
* create an open source friendly version of the firmware that makes it easy
|
||||
* for users/developers to modify and create their own original alt firmware
|
||||
* implementations.
|
||||
*
|
||||
* The libGravity library represents wrappers around the
|
||||
* implementations.
|
||||
*
|
||||
* The libGravity library represents wrappers around the
|
||||
* hardware peripherials to make it easy to interact with and add behavior
|
||||
* to them. The library tries not to make any assumptions about what the
|
||||
* to them. The library tries not to make any assumptions about what the
|
||||
* firmware can or should do.
|
||||
*
|
||||
*
|
||||
* The Gravity firmware is a slightly different implementation of the original
|
||||
* firmware. There are a few notable changes; the internal clock operates at
|
||||
* firmware. There are a few notable changes; the internal clock operates at
|
||||
* 96 PPQN instead of the original 24 PPQN, which allows for more granular
|
||||
* quantization of features like duty cycle (pulse width) or offset.
|
||||
* Additionally, this firmware replaces the sequencer with a Euclidean Rhythm
|
||||
@ -172,11 +172,24 @@ void HandleEncoderPressed() {
|
||||
// Check if leaving editing mode should apply a selection.
|
||||
if (app.editing_param) {
|
||||
if (app.selected_channel == 0) { // main page
|
||||
// TODO: rewrite as switch
|
||||
if (app.selected_param == PARAM_MAIN_ENCODER_DIR) {
|
||||
bool reversed = app.selected_sub_param == 1;
|
||||
gravity.encoder.SetReverseDirection(reversed);
|
||||
}
|
||||
// Reset state
|
||||
if (app.selected_param == PARAM_MAIN_SAVE_DATA) {
|
||||
if (app.selected_sub_param < MAX_SAVE_SLOTS) {
|
||||
app.selected_save_slot = app.selected_sub_param;
|
||||
stateManager.saveData(app);
|
||||
}
|
||||
}
|
||||
if (app.selected_param == PARAM_MAIN_LOAD_DATA) {
|
||||
if (app.selected_sub_param < MAX_SAVE_SLOTS) {
|
||||
app.selected_save_slot = app.selected_sub_param;
|
||||
stateManager.loadData(app, app.selected_save_slot);
|
||||
InitGravity(app);
|
||||
}
|
||||
}
|
||||
if (app.selected_param == PARAM_MAIN_RESET_STATE) {
|
||||
if (app.selected_sub_param == 0) { // Reset
|
||||
stateManager.reset(app);
|
||||
@ -184,10 +197,11 @@ void HandleEncoderPressed() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Only mark dirty when leaving editing mode.
|
||||
// Only mark dirty and reset selected_sub_param when leaving editing mode.
|
||||
stateManager.markDirty();
|
||||
app.selected_sub_param = 0;
|
||||
}
|
||||
app.selected_sub_param = 0;
|
||||
|
||||
app.editing_param = !app.editing_param;
|
||||
app.refresh_screen = true;
|
||||
}
|
||||
@ -224,7 +238,6 @@ void editMainParameter(int val) {
|
||||
gravity.clock.SetTempo(gravity.clock.Tempo() + val);
|
||||
app.tempo = gravity.clock.Tempo();
|
||||
break;
|
||||
|
||||
case PARAM_MAIN_SOURCE: {
|
||||
byte source = static_cast<int>(app.selected_source);
|
||||
updateSelection(source, val, Clock::SOURCE_LAST);
|
||||
@ -239,10 +252,15 @@ void editMainParameter(int val) {
|
||||
if (app.selected_pulse == Clock::PULSE_NONE) {
|
||||
gravity.pulse.Low();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PARAM_MAIN_ENCODER_DIR:
|
||||
updateSelection(app.selected_sub_param, val, 2);
|
||||
break;
|
||||
case PARAM_MAIN_SAVE_DATA:
|
||||
case PARAM_MAIN_LOAD_DATA:
|
||||
updateSelection(app.selected_sub_param, val, MAX_SAVE_SLOTS + 1);
|
||||
break;
|
||||
case PARAM_MAIN_RESET_STATE:
|
||||
updateSelection(app.selected_sub_param, val, 2);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user