Code Cleanups (removed SI, max profiles) (#1427)

Minor code cleanup, removed SI as we never ended up using it, added MAX_PROFILES to get rid of 4; magic number
This commit is contained in:
Luke A
2025-07-15 18:26:52 -04:00
committed by GitHub
parent 314c0b3240
commit 8c4ac5c7b5
2 changed files with 6 additions and 6 deletions

View File

@@ -20,8 +20,6 @@
#include "eventmanager.h"
#include "GPStorageSaveEvent.h"
#define SI Storage::getInstance()
// Storage manager for board, LED options, and thread-safe settings
class Storage {
public:

View File

@@ -267,6 +267,8 @@
#define GPIO_PIN_29 GpioAction::NONE
#endif
#define MAX_PROFILES (uint8_t)6
// -----------------------------------------------------
// Migration leftovers
// -----------------------------------------------------
@@ -1342,7 +1344,7 @@ void gpioMappingsMigrationProfiles(Config& config)
}
};
for (uint8_t profileNum = 0; profileNum <= 4; profileNum++) {
for (uint8_t profileNum = 0; profileNum <= MAX_PROFILES-2; 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;
}
@@ -1380,7 +1382,7 @@ void migrateTurboPinToGpio(Config& config) {
Pin_t pin = turboOptions.deprecatedButtonPin;
// previous config had a value we haven't migrated yet, it can/should apply in the new config
config.gpioMappings.pins[pin].action = GpioAction::BUTTON_PRESS_TURBO;
for (uint8_t profileNum = 0; profileNum <= 4; profileNum++) {
for (uint8_t profileNum = 0; profileNum <= MAX_PROFILES-2; profileNum++) {
config.profileOptions.gpioMappingsSets[profileNum].pins[pin].action = GpioAction::BUTTON_PRESS_TURBO;
}
turboOptions.deprecatedButtonPin = -1; // set our turbo options to -1 for subsequent calls
@@ -1462,7 +1464,7 @@ void migrateMacroPinsToGpio(Config& config) {
if (macroOptions.has_deprecatedPin && isValidPin(macroOptions.deprecatedPin) ) {
Pin_t pin = macroOptions.deprecatedPin;
config.gpioMappings.pins[pin].action = GpioAction::BUTTON_PRESS_MACRO;
for (uint8_t profileNum = 0; profileNum <= 4; profileNum++) {
for (uint8_t profileNum = 0; profileNum <= MAX_PROFILES-2; profileNum++) {
config.profileOptions.gpioMappingsSets[profileNum].pins[pin].action = GpioAction::BUTTON_PRESS_MACRO;
}
macroOptions.deprecatedPin = -1; // set our turbo options to -1 for subsequent calls
@@ -1478,7 +1480,7 @@ void migrateMacroPinsToGpio(Config& config) {
isValidPin(macroOptions.macroList[i].deprecatedMacroTriggerPin) ) {
Pin_t pin = macroOptions.macroList[i].deprecatedMacroTriggerPin;
config.gpioMappings.pins[pin].action = actionList[i];
for (uint8_t profileNum = 0; profileNum <= 4; profileNum++) {
for (uint8_t profileNum = 0; profileNum <= MAX_PROFILES-2; profileNum++) {
config.profileOptions.gpioMappingsSets[profileNum].pins[pin].action = actionList[i];
}
macroOptions.macroList[i].deprecatedMacroTriggerPin = -1; // set our turbo options to -1 for subsequent calls