I've seen #11 and agree with it. When a value is written (EEPROMClass::update), _dirty is set, because a commit is required to make this change persistent.
A commit only writes data to flash memory, if neccessary - equals to if _dirty is set and makes sense as well. But where is the _dirty flag cleared? Otherwise after the first call of EEPROMClass::update the _dirty is always true and makes no sense anymore.
I propose to clear the dirty flag at the end of the commit:
void EEPROMClass::commit()
{
if (!_initialized) init();
if (_dirty) {
_eeprom.valid = true;
eeprom_storage.write(_eeprom);
_dirty = false;
}
}
With this statement you may call commit even within a loop and it does not harm flash memory, because the data is actually only written to flash, if some data was changed with a EEPROMClass::update before.
I've seen #11 and agree with it. When a value is written (EEPROMClass::update), _dirty is set, because a commit is required to make this change persistent.
A commit only writes data to flash memory, if neccessary - equals to if _dirty is set and makes sense as well. But where is the _dirty flag cleared? Otherwise after the first call of EEPROMClass::update the _dirty is always true and makes no sense anymore.
I propose to clear the dirty flag at the end of the commit:
With this statement you may call commit even within a loop and it does not harm flash memory, because the data is actually only written to flash, if some data was changed with a EEPROMClass::update before.