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

Restore master branch back to original content #1

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Update Eeprom.ino
avandalen authored Aug 24, 2017
commit 3f2d6b912124058f2a3ce958c3b5aa1b4cca3426
62 changes: 30 additions & 32 deletions Eeprom.ino
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
const unsigned maxWrites = 100;
// const unsigned initValue = 123456; // take another value for new initialization
const uint16_t initValue = 12345; // take another value for new initialization

void Eeprom::init()
{ setMemPool(0, EEPROMSizeATmega328);
setMaxAllowedWrites(maxWrites);
storedInitValue = getAddress(sizeof(unsigned));
preweld_ms = getAddress(sizeof(unsigned));
pause_ms = getAddress(sizeof(unsigned));
weld_ms = getAddress(sizeof(unsigned));
orientation = getAddress(sizeof(unsigned));
if(!initialized()) write(); // fill an empty EEPROM
}

void Eeprom::read()
{ menuItems[0].upDownVal.value = readInt(preweld_ms);
menuItems[1].upDownVal.value = readInt(pause_ms);
menuItems[2].upDownVal.value = readInt(weld_ms);
}

void Eeprom::write()
{ writeInt(storedInitValue, initValue); // todo with update()?
writeInt(preweld_ms, menuItems[0].upDownVal.value);
writeInt(pause_ms, menuItems[1].upDownVal.value);
writeInt(weld_ms, menuItems[2].upDownVal.value);
writeInt(orientation, 0);
}

bool Eeprom::initialized()
{ return readInt(storedInitValue) == initValue;
}
const unsigned maxWrites = 100;
const unsigned initValue = 123455; // take another value for new initialization

void Eeprom::init()
{ setMemPool(0, EEPROMSizeATmega328);
setMaxAllowedWrites(maxWrites);
storedInitValue = getAddress(sizeof(unsigned));
preweld_ms = getAddress(sizeof(unsigned));
pause_ms = getAddress(sizeof(unsigned));
weld_ms = getAddress(sizeof(unsigned));
orientation = getAddress(sizeof(unsigned));
if(!initialized()) write(); // fill an empty EEPROM
}

void Eeprom::read()
{ menuItems[0].upDownVal.value = readInt(preweld_ms);
menuItems[1].upDownVal.value = readInt(pause_ms);
menuItems[2].upDownVal.value = readInt(weld_ms);
}

void Eeprom::write()
{ writeInt(storedInitValue, initValue); // todo with update()?
writeInt(preweld_ms, menuItems[0].upDownVal.value);
writeInt(pause_ms, menuItems[1].upDownVal.value);
writeInt(weld_ms, menuItems[2].upDownVal.value);
writeInt(orientation, 0);
}

bool Eeprom::initialized()
{ return readInt(storedInitValue) == initValue;
}