Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion proto/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ message AlternativePinMappings
message ProfileOptions
{
repeated AlternativePinMappings deprecatedAlternativePinMappings = 1 [(nanopb).max_count = 3, deprecated = true];
repeated GpioMappings gpioMappingsSets = 2 [(nanopb).max_count = 5];
repeated GpioMappings gpioMappingsSets = 2 [(nanopb).max_count = 6];
}

message DisplayOptions
Expand Down
11 changes: 9 additions & 2 deletions src/config_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ void gpioMappingsMigrationProfiles(Config& config)
}
};

for (uint8_t profileNum = 0; profileNum <= MAX_PROFILES-2; profileNum++) {
for (uint8_t profileNum = 0; profileNum <= MAX_PROFILES-1; profileNum++) {
for (Pin_t pin = 0; pin < (Pin_t)NUM_BANK0_GPIOS; pin++) {
config.profileOptions.gpioMappingsSets[profileNum].pins[pin].action = config.gpioMappings.pins[pin].action;
}
Expand All @@ -1579,7 +1579,7 @@ void gpioMappingsMigrationProfiles(Config& config)
config.profileOptions.gpioMappingsSets[profileNum].pins_count = NUM_BANK0_GPIOS;
}
// reminder that this must be set or else nanopb won't retain anything
config.profileOptions.gpioMappingsSets_count = 5;
config.profileOptions.gpioMappingsSets_count = MAX_PROFILES-1;

config.migrations.buttonProfilesMigrated = true;
}
Expand Down Expand Up @@ -1652,6 +1652,13 @@ void profileEnabledFlagsMigration(Config& config) {
config.profileOptions.gpioMappingsSets[profileNum].enabled = false;
continue;
}
// If the profile is already marked as enabled (by user), keep it enabled
// regardless of whether pins differ from base profile
bool profileAlreadyEnabled = config.profileOptions.gpioMappingsSets[profileNum].enabled;
if (profileAlreadyEnabled) {
continue;
}
// For uninitialized enabled state, check if pins differ from base profile
for (uint8_t pinNum = 0; pinNum < config.gpioMappings.pins_count; pinNum++) {
// check each pin: if the alt. mapping pin is different than the base (profile 1)
// mapping, enable the profile and check the next one
Expand Down
4 changes: 2 additions & 2 deletions src/webconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ std::string setProfileOptions()
profileOptions.gpioMappingsSets[altsIndex].enabled = alt["enabled"];

profileOptions.gpioMappingsSets_count = ++altsIndex;
if (altsIndex > 4) break;
if (altsIndex > 5) break;
}

EventManager::getInstance().triggerEvent(new GPStorageSaveEvent(true));
Expand All @@ -590,7 +590,7 @@ std::string setProfileOptions()

std::string getProfileOptions()
{
const size_t capacity = JSON_OBJECT_SIZE(500);
const size_t capacity = JSON_OBJECT_SIZE(900);
DynamicJsonDocument doc(capacity);

const auto writePinDoc = [&](const int item, const char* key, const GpioMappingInfo& value) -> void
Expand Down
1 change: 1 addition & 0 deletions www/src/Store/useProfilesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const useProfilesStore = create<State & Actions>()((set, get) => ({
{
...state.profiles[0],
profileLabel: `Profile ${state.profiles.length + 1}`,
enabled: true,
},
],
}));
Expand Down