Skip to content

Commit

Permalink
system: make preset change with program change in optional
Browse files Browse the repository at this point in the history
  • Loading branch information
paradajz committed Mar 15, 2024
1 parent 69e5af3 commit a332579
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/firmware/application/system/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ namespace sys
ACTIVE_PRESET = static_cast<uint8_t>(database::Config::systemSetting_t::ACTIVE_PRESET),
PRESET_PRESERVE = static_cast<uint8_t>(database::Config::systemSetting_t::PRESET_PRESERVE),
DISABLE_FORCED_REFRESH_AFTER_PRESET_CHANGE = static_cast<uint8_t>(database::Config::systemSetting_t::CUSTOM_SYSTEM_SETTING_START),
ENABLE_PRESET_CHANGE_WITH_PROGRAM_CHANGE_IN,
AMOUNT
};

Expand Down
20 changes: 17 additions & 3 deletions src/firmware/application/system/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ Instance::Instance(HWA& hwa,
{
case MIDI::messageType_t::PROGRAM_CHANGE:
{
_components.database().setPreset(event.index);
if (_components.database().read(database::Config::Section::system_t::SYSTEM_SETTINGS,
Config::systemSetting_t::ENABLE_PRESET_CHANGE_WITH_PROGRAM_CHANGE_IN))
{
_components.database().setPreset(event.index);
}
}
break;

Expand Down Expand Up @@ -627,8 +631,13 @@ std::optional<uint8_t> Instance::sysConfigGet(sys::Config::Section::global_t sec
return std::nullopt;
}

if (index != static_cast<size_t>(sys::Config::systemSetting_t::DISABLE_FORCED_REFRESH_AFTER_PRESET_CHANGE))
switch (index)
{
case static_cast<size_t>(sys::Config::systemSetting_t::DISABLE_FORCED_REFRESH_AFTER_PRESET_CHANGE):
case static_cast<size_t>(sys::Config::systemSetting_t::ENABLE_PRESET_CHANGE_WITH_PROGRAM_CHANGE_IN):
break;

default:
return std::nullopt;
}

Expand All @@ -650,8 +659,13 @@ std::optional<uint8_t> Instance::sysConfigSet(sys::Config::Section::global_t sec
return std::nullopt;
}

if (index != static_cast<size_t>(sys::Config::systemSetting_t::DISABLE_FORCED_REFRESH_AFTER_PRESET_CHANGE))
switch (index)
{
case static_cast<size_t>(sys::Config::systemSetting_t::DISABLE_FORCED_REFRESH_AFTER_PRESET_CHANGE):
case static_cast<size_t>(sys::Config::systemSetting_t::ENABLE_PRESET_CHANGE_WITH_PROGRAM_CHANGE_IN):
break;

default:
return std::nullopt;
}

Expand Down

0 comments on commit a332579

Please sign in to comment.