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

corrupt EEPROM data #5

Open
swede89 opened this issue Sep 9, 2019 · 2 comments
Open

corrupt EEPROM data #5

swede89 opened this issue Sep 9, 2019 · 2 comments

Comments

@swede89
Copy link
Collaborator

swede89 commented Sep 9, 2019

Occasionaly, EEPROM data is corrupt. Each config element should be checked for validity and set to a default value in case of error.

@swede89
Copy link
Collaborator Author

swede89 commented Sep 12, 2019

Proposed solution:
Add another check in checkConfig(boolean init) for each config element
BEFORE:
int tempInt = atoi(config.c1);
if (validConfig.c1 != tempInt and tempInt > 0 and tempInt <= 256)
 {
  validConfig.c1 = tempInt;
  changeColor = true;
  Serial.println("Color 1 changed");  
}

AFTER
int tempInt = atoi(config.c1);
if (tempInt > 0 and tempInt <= 256)
 {
if(validConfig.c1 != tempInt)
{
  validConfig.c1 = tempInt;
  changeColor = true;
  Serial.println("Color 1 changed");  
}
}
else if(init) //that means the current EEPROM value is out of bounds and it is not due to user input (as checkConfig was triggered by setup() method with init=true). The condition init can also be left apart causing every misinput to set the EEPROM.
{
Serial.println("Reset c1");
itoa(validConfig.c1, config.c1, 10)
}

@swede89
Copy link
Collaborator Author

swede89 commented Sep 12, 2019

Solved in branch bugfixCorrupEEPROM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant