From d20ca1c5ac52246afe73a3481c0844fc848d79f7 Mon Sep 17 00:00:00 2001 From: TheTrain <32771064+TheTrainGoes@users.noreply.github.com> Date: Mon, 17 Nov 2025 21:59:37 -0500 Subject: [PATCH] 20251117 fix for profile 6 this PR fixes the saving issue with profile 6 in web-config. I am unsure about the changes on line 1655-1661 in config_utils.cpp as they were a recommended change. --- proto/config.proto | 2 +- src/config_utils.cpp | 11 +++++++++-- src/webconfig.cpp | 4 ++-- www/src/Store/useProfilesStore.ts | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/proto/config.proto b/proto/config.proto index a2e7dcaf35..0721508c27 100644 --- a/proto/config.proto +++ b/proto/config.proto @@ -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 diff --git a/src/config_utils.cpp b/src/config_utils.cpp index 478a6b21a8..7c854da225 100644 --- a/src/config_utils.cpp +++ b/src/config_utils.cpp @@ -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; } @@ -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; } @@ -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 diff --git a/src/webconfig.cpp b/src/webconfig.cpp index d59cb1ac47..67061013e2 100644 --- a/src/webconfig.cpp +++ b/src/webconfig.cpp @@ -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)); @@ -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 diff --git a/www/src/Store/useProfilesStore.ts b/www/src/Store/useProfilesStore.ts index daed0c080b..6c7b94f30b 100644 --- a/www/src/Store/useProfilesStore.ts +++ b/www/src/Store/useProfilesStore.ts @@ -87,6 +87,7 @@ const useProfilesStore = create()((set, get) => ({ { ...state.profiles[0], profileLabel: `Profile ${state.profiles.length + 1}`, + enabled: true, }, ], }));