Added option for electric distribution system (230/400)

This commit is contained in:
Gunnar Skjold
2020-01-31 21:30:20 +01:00
parent fc1f1554d8
commit 57d8603790
5 changed files with 46 additions and 20 deletions

View File

@@ -8,7 +8,7 @@ bool configuration::hasConfig()
{
bool hasConfig = false;
EEPROM.begin(EEPROM_SIZE);
hasConfig = EEPROM.read(EEPROM_CONFIG_ADDRESS) == EEPROM_CHECK_SUM;
hasConfig = EEPROM.read(EEPROM_CONFIG_ADDRESS) >= 71;
EEPROM.end();
return hasConfig;
}
@@ -46,6 +46,7 @@ bool configuration::save()
}
address += saveInt(address, fuseSize);
address += saveInt(address, distSys);
bool success = EEPROM.commit();
EEPROM.end();
@@ -73,6 +74,7 @@ bool configuration::load()
authUser = 0;
authPass = 0;
fuseSize = 0;
distSys = 0;
EEPROM.begin(EEPROM_SIZE);
int cs = EEPROM.read(address);
@@ -118,6 +120,9 @@ bool configuration::load()
if(cs >= 73) {
address += readInt(address, &fuseSize);
}
if(cs >= 74) {
address += readByte(address, &distSys);
}
EEPROM.end();
return success;
}

View File

@@ -30,6 +30,7 @@ public:
char* authPass;
int fuseSize;
byte distSys;
bool hasConfig();
bool isSecure();
@@ -41,7 +42,7 @@ protected:
private:
const int EEPROM_SIZE = 512;
const byte EEPROM_CHECK_SUM = 73; // Used to check if config is stored. Change if structure changes
const byte EEPROM_CHECK_SUM = 74; // Used to check if config is stored. Change if structure changes
const int EEPROM_CONFIG_ADDRESS = 0;
int saveString(int pAddress, char* pString);