diff --git a/right/src/config_parser/config_globals.c b/right/src/config_parser/config_globals.c index 4207681..aa05e3a 100644 --- a/right/src/config_parser/config_globals.c +++ b/right/src/config_parser/config_globals.c @@ -6,6 +6,7 @@ static uint8_t hardwareConfig[HARDWARE_CONFIG_SIZE]; static uint8_t ATTR_DATA2 stagingUserConfig[USER_CONFIG_SIZE]; static uint8_t validatedUserConfig[USER_CONFIG_SIZE]; +uint16_t ValidatedUserConfigLength; config_buffer_t HardwareConfigBuffer = { hardwareConfig }; config_buffer_t StagingUserConfigBuffer = { stagingUserConfig }; config_buffer_t ValidatedUserConfigBuffer = { validatedUserConfig }; diff --git a/right/src/config_parser/config_globals.h b/right/src/config_parser/config_globals.h index 3cc5dde..bac7455 100644 --- a/right/src/config_parser/config_globals.h +++ b/right/src/config_parser/config_globals.h @@ -17,6 +17,7 @@ // Variables: extern bool ParserRunDry; + extern uint16_t ValidatedUserConfigLength; extern config_buffer_t HardwareConfigBuffer; extern config_buffer_t StagingUserConfigBuffer; extern config_buffer_t ValidatedUserConfigBuffer; diff --git a/right/src/config_parser/parse_config.c b/right/src/config_parser/parse_config.c index 95bcd29..2e1e036 100644 --- a/right/src/config_parser/parse_config.c +++ b/right/src/config_parser/parse_config.c @@ -51,7 +51,6 @@ parser_error_t ParseConfig(config_buffer_t *buffer) const char *deviceName = ReadString(buffer, &len); uint16_t doubleTapSwitchLayerTimeout = ReadUInt16(buffer); - (void)userConfigLength; (void)dataModelMajorVersion; (void)dataModelMinorVersion; (void)dataModelPatchVersion; @@ -141,6 +140,8 @@ parser_error_t ParseConfig(config_buffer_t *buffer) // Update LED brightnesses and reinitialize LED drivers + ValidatedUserConfigLength = userConfigLength; + IconsAndLayerTextsBrightness = iconsAndLayerTextsBrightness; AlphanumericSegmentsBrightness = alphanumericSegmentsBrightness; KeyBacklightBrightness = keyBacklightBrightness; diff --git a/right/src/eeprom.c b/right/src/eeprom.c index 5dd0893..45c5daf 100644 --- a/right/src/eeprom.c +++ b/right/src/eeprom.c @@ -94,14 +94,14 @@ void EEPROM_Init(void) I2C_MasterTransferCreateHandle(I2C_EEPROM_BUS_BASEADDR, &i2cHandle, i2cCallback, NULL); } -status_t EEPROM_LaunchTransfer(eeprom_operation_t operation, config_buffer_id_t config_buffer_id, void (*successCallback)) +status_t EEPROM_LaunchTransfer(eeprom_operation_t operation, config_buffer_id_t configBufferId, void (*successCallback)) { if (IsEepromBusy) { return kStatus_I2C_Busy; } CurrentEepromOperation = operation; - CurrentConfigBufferId = config_buffer_id; + CurrentConfigBufferId = configBufferId; SuccessCallback = successCallback; bool isHardwareConfig = CurrentConfigBufferId == ConfigBufferId_HardwareConfig; @@ -117,7 +117,8 @@ status_t EEPROM_LaunchTransfer(eeprom_operation_t operation, config_buffer_id_t case EepromOperation_Write: sourceBuffer = ConfigBufferIdToConfigBuffer(CurrentConfigBufferId)->buffer; sourceOffset = 0; - sourceLength = isHardwareConfig ? HARDWARE_CONFIG_SIZE : USER_CONFIG_SIZE; + uint16_t userConfigSize = ValidatedUserConfigLength && configBufferId == ConfigBufferId_ValidatedUserConfig ? ValidatedUserConfigLength : USER_CONFIG_SIZE; + sourceLength = isHardwareConfig ? HARDWARE_CONFIG_SIZE : userConfigSize; LastEepromTransferStatus = writePage(); break; }