Skip to content

Commit

Permalink
Convert all of the settings_addr_ uses to settings_base_ to better ma…
Browse files Browse the repository at this point in the history
…tch the rest of our code.
  • Loading branch information
obra committed Feb 29, 2024
1 parent c31c4ee commit e1618d0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class MouseKeysConfig : public Plugin {

private:
// The base address in persistent storage for configuration data:
uint16_t settings_addr_;
uint16_t settings_base_;
};

} // namespace plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ namespace plugin {
// MouseKeys configurator

EventHandlerResult MouseKeysConfig::onSetup() {
settings_addr_ = ::EEPROMSettings.requestSliceAndData(&::MouseKeys.settings_, sizeof(MouseKeys::settings_));
settings_base_ = ::EEPROMSettings.requestSliceAndData(&::MouseKeys.settings_, sizeof(MouseKeys::settings_));


// If the EEPROM is empty, store the default settings.
if (!::EEPROMSettings.isSliceValid(settings_addr_, sizeof(::MouseKeys.settings_))) {
Runtime.storage().put(settings_addr_, ::MouseKeys.settings_);
if (!::EEPROMSettings.isSliceValid(settings_base_, sizeof(::MouseKeys.settings_))) {
Runtime.storage().put(settings_base_, ::MouseKeys.settings_);
Runtime.storage().commit();
}

Expand Down Expand Up @@ -141,7 +141,7 @@ EventHandlerResult MouseKeysConfig::onFocusEvent(const char *input) {

// Update settings stored in EEPROM, and indicate that this Focus event has
// been handled successfully.
Runtime.storage().put(settings_addr_, ::MouseKeys.settings_);
Runtime.storage().put(settings_base_, ::MouseKeys.settings_);
Runtime.storage().commit();
return EventHandlerResult::EVENT_CONSUMED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class OneShotConfig : public Plugin {

private:
// The base address in persistent storage for configuration data:
uint16_t settings_addr_;
uint16_t settings_base_;
};

} // namespace plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ namespace kaleidoscope {
namespace plugin {

EventHandlerResult OneShotConfig::onSetup() {
settings_addr_ = ::EEPROMSettings.requestSliceAndData(&::OneShot.settings_, sizeof(::OneShot.settings_));
settings_base_ = ::EEPROMSettings.requestSliceAndData(&::OneShot.settings_, sizeof(::OneShot.settings_));

// If the EEPROM is empty, store the default settings.
if (!::EEPROMSettings.isSliceValid(settings_addr_, sizeof(::OneShot.settings_))) {
Runtime.storage().put(settings_addr_, ::OneShot.settings_);
if (!::EEPROMSettings.isSliceValid(settings_base_, sizeof(::OneShot.settings_))) {
Runtime.storage().put(settings_base_, ::OneShot.settings_);
Runtime.storage().commit();
}

Expand Down Expand Up @@ -143,7 +143,7 @@ EventHandlerResult OneShotConfig::onFocusEvent(const char *input) {
default:
return EventHandlerResult::ABORT;
}
Runtime.storage().put(settings_addr_, ::OneShot.settings_);
Runtime.storage().put(settings_base_, ::OneShot.settings_);
Runtime.storage().commit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ EventHandlerResult PersistentLEDMode::onSetup() {
settings_base_ = ::EEPROMSettings.requestSliceAndData(&settings_, sizeof(settings_));

// If the EEPROM is empty, store the default settings.
if (::EEPROMSettings.isSliceValid(settings_addr_, sizeof(settings_))) {
if (::EEPROMSettings.isSliceValid(settings_base_, sizeof(settings_))) {
::LEDControl.set_mode(settings_.default_mode_index);
}

Expand Down

0 comments on commit e1618d0

Please sign in to comment.