Make saving the user configuration faster by only writing the part of the EEPROM which actually contains the user configuration. Resolves #111.
This commit is contained in:
@@ -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 };
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user