Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to gpioMappings migration and webconfig #610

Merged
merged 4 commits into from
Nov 5, 2023
Merged
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
1 change: 0 additions & 1 deletion configs/Pico/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
#define TILT2_FACTOR_LEFT_Y 65 //Default value for the TILT button to function.
#define TILT2_FACTOR_RIGHT_X 65 //Default value for the TILT button to function.
#define TILT2_FACTOR_RIGHT_Y 65 //Default value for the TILT button to function.
#define PIN_TILT_FUNCTION -1
#define PIN_TILT_LEFT_ANALOG_UP -1
#define PIN_TILT_LEFT_ANALOG_DOWN -1
#define PIN_TILT_LEFT_ANALOG_LEFT -1
Expand Down
1 change: 0 additions & 1 deletion configs/PicoW/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@
// TILTAdd-on Options
#define PIN_TILT_1 -1
#define PIN_TILT_2 -1
#define PIN_TILT_FUNCTION -1
#define PIN_TILT_LEFT_ANALOG_UP -1
#define PIN_TILT_LEFT_ANALOG_DOWN -1
#define PIN_TILT_LEFT_ANALOG_LEFT -1
Expand Down
2 changes: 1 addition & 1 deletion proto/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ message TiltOptions

optional int32 tilt1Pin = 2;
optional int32 tilt2Pin = 3;
optional int32 tiltFunctionPin = 4;
optional int32 deprecatedTiltFunctionPin = 4;
optional int32 tiltLeftAnalogUpPin = 5;
optional int32 tiltLeftAnalogDownPin = 6;
optional int32 tiltLeftAnalogLeftPin = 7;
Expand Down
26 changes: 3 additions & 23 deletions src/config_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,27 +168,6 @@ void ConfigUtils::initUnsetPropertiesWithDefaults(Config& config)
// forcedSetupMode
INIT_UNSET_PROPERTY(config.forcedSetupOptions, mode, DEFAULT_FORCED_SETUP_MODE);

// pinMappings
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinDpadUp, PIN_DPAD_UP);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinDpadDown, PIN_DPAD_DOWN);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinDpadLeft, PIN_DPAD_LEFT);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinDpadRight, PIN_DPAD_RIGHT);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonB1, PIN_BUTTON_B1);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonB2, PIN_BUTTON_B2);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonB3, PIN_BUTTON_B3);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonB4, PIN_BUTTON_B4);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonL1, PIN_BUTTON_L1);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonR1, PIN_BUTTON_R1);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonL2, PIN_BUTTON_L2);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonR2, PIN_BUTTON_R2);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonS1, PIN_BUTTON_S1);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonS2, PIN_BUTTON_S2);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonL3, PIN_BUTTON_L3);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonR3, PIN_BUTTON_R3);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonA1, PIN_BUTTON_A1);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonA2, PIN_BUTTON_A2);
INIT_UNSET_PROPERTY(config.deprecatedPinMappings, pinButtonFn, PIN_BUTTON_FN);

// keyboardMapping
INIT_UNSET_PROPERTY(config.keyboardMapping, keyDpadUp, KEY_DPAD_UP);
INIT_UNSET_PROPERTY(config.keyboardMapping, keyDpadDown, KEY_DPAD_DOWN);
Expand Down Expand Up @@ -842,7 +821,6 @@ void gpioMappingsMigrationCore(Config& config)
markAddonPinIfUsed(config.addonOptions.analogADS1219Options.i2cSDAPin);
markAddonPinIfUsed(config.addonOptions.tiltOptions.tilt1Pin);
markAddonPinIfUsed(config.addonOptions.tiltOptions.tilt2Pin);
markAddonPinIfUsed(config.addonOptions.tiltOptions.tiltFunctionPin);
markAddonPinIfUsed(config.addonOptions.tiltOptions.tiltLeftAnalogUpPin);
markAddonPinIfUsed(config.addonOptions.tiltOptions.tiltLeftAnalogDownPin);
markAddonPinIfUsed(config.addonOptions.tiltOptions.tiltLeftAnalogLeftPin);
Expand Down Expand Up @@ -1041,7 +1019,6 @@ void ConfigUtils::load(Config& config)

// run migrations
if (!config.migrations.hotkeysMigrated) hotkeysMigration(config);
if (!config.migrations.gpioMappingsMigrated) gpioMappingsMigrationCore(config);

// Make sure that fields that were not deserialized are properly initialized.
// They were probably added with a newer version of the firmware.
Expand All @@ -1051,6 +1028,9 @@ void ConfigUtils::load(Config& config)
// Further migrations can be performed here
// ----------------------------------------

// run migrations that need to happen after initUnset...
if (!config.migrations.gpioMappingsMigrated) gpioMappingsMigrationCore(config);

// Update boardVersion, in case we migrated from an older version
strncpy(config.boardVersion, GP2040VERSION, sizeof(config.boardVersion));
config.boardVersion[sizeof(config.boardVersion) - 1] = '\0';
Expand Down
8 changes: 4 additions & 4 deletions src/configs/webconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,10 @@ std::string setLedOptions()
readIndex(ledOptions.indexA1, "ledButtonMap", "A1");
readIndex(ledOptions.indexA2, "ledButtonMap", "A2");
readDoc(ledOptions.pledType, doc, "pledType");
readDoc(ledOptions.pledPin1, doc, "pledPin1");
readDoc(ledOptions.pledPin2, doc, "pledPin2");
readDoc(ledOptions.pledPin3, doc, "pledPin3");
readDoc(ledOptions.pledPin4, doc, "pledPin4");
docToPin(ledOptions.pledPin1, doc, "pledPin1");
docToPin(ledOptions.pledPin2, doc, "pledPin2");
docToPin(ledOptions.pledPin3, doc, "pledPin3");
docToPin(ledOptions.pledPin4, doc, "pledPin4");
readDoc(ledOptions.pledColor, doc, "pledColor");

Storage::getInstance().save();
Expand Down