diff --git a/examples/Gravity/channel.h b/examples/Gravity/channel.h index 23c1f51..9d01553 100644 --- a/examples/Gravity/channel.h +++ b/examples/Gravity/channel.h @@ -42,7 +42,7 @@ static const int CLOCK_MOD_PULSES[MOD_CHOICE_SIZE] PROGMEM = { 192, 288, 384, 480, 576, 672, 768, 864, 960, 1056, 1152, 1536, 2304, 3072, 6144, 12288 }; -static const byte DEFAULT_CLOCK_MOD = 8; // x1 or 96 PPQN. +static const byte DEFAULT_CLOCK_MOD_INDEX = 8; // x1 or 96 PPQN. class Channel { public: @@ -52,7 +52,7 @@ class Channel { void Init() { // Reset base values to their defaults - base_clock_mod_index = DEFAULT_CLOCK_MOD; + base_clock_mod_index = DEFAULT_CLOCK_MOD_INDEX; base_probability = 100; base_duty_cycle = 50; base_offset = 0; diff --git a/examples/Gravity/save_state.cpp b/examples/Gravity/save_state.cpp index 8ac0960..3c1e9d9 100644 --- a/examples/Gravity/save_state.cpp +++ b/examples/Gravity/save_state.cpp @@ -18,6 +18,7 @@ bool StateManager::initialize(AppState& app) { // Initialize eeprom and save default patter to all save slots. reset(app); _saveMetadata(); + // MAX_SAVE_SLOTS slot is reserved for transient state. for (int i = 0; i <= MAX_SAVE_SLOTS; i++) { app.selected_save_slot = i; _saveState(app, i); diff --git a/examples/Gravity/save_state.h b/examples/Gravity/save_state.h index 96415b3..b8d39cd 100644 --- a/examples/Gravity/save_state.h +++ b/examples/Gravity/save_state.h @@ -19,6 +19,11 @@ static const unsigned long SAVE_DELAY_MS = 2000; /** * @brief Manages saving and loading of the application state to and from EEPROM. + * The number of user slots is defined by MAX_SAVE_SLOTS, and one additional slot + * is reseved for transient state to persist state between power cycles before + * state is explicitly saved to a user slot. Metadata is stored in the beginning + * of the memory space which stores firmware version information to validate that + * the data can be loaded into the current version of AppState. */ class StateManager { public: @@ -28,7 +33,7 @@ class StateManager { bool initialize(AppState& app); // Load data from specified slot. bool loadData(AppState& app, byte slot_index); - // Save data to slot defined by app. + // Save data to specified slot. void saveData(const AppState& app); // Reset AppState instance back to default values. void reset(AppState& app);