mirror of
https://github.com/RobTillaart/I2C_EEPROM.git
synced 2026-07-27 20:06:07 +00:00
- simplify **begin()**, remove setting Wire pins from library. - add **getAddress()** - update readme.md - update examples
56 lines
2.6 KiB
Markdown
56 lines
2.6 KiB
Markdown
|
|
[](https://github.com/marketplace/actions/arduino_ci)
|
|
[](https://github.com/RobTillaart/I2C_EEPROM/actions/workflows/arduino-lint.yml)
|
|
[](https://github.com/RobTillaart/I2C_EEPROM/actions/workflows/jsoncheck.yml)
|
|
[](https://github.com/RobTillaart/I2C_EEPROM/issues)
|
|
|
|
[](https://github.com/RobTillaart/I2C_EEPROM/blob/master/LICENSE)
|
|
[](https://github.com/RobTillaart/I2C_EEPROM/releases)
|
|
[](https://registry.platformio.org/libraries/robtillaart/I2C_EEPROM)
|
|
|
|
|
|
# I2C_eeprom_cyclic_store
|
|
|
|
Utility class for storing data using cyclic writes to eeprom memory.
|
|
|
|
|
|
## Description
|
|
|
|
In order to maximize the life expectancy of an eeprom this class implements
|
|
a method to spread the write operations across as much of the eeprom as possible,
|
|
rather than writing to the same fixed location.
|
|
|
|
This is suitable for a situation where a single data structure (buffer),
|
|
such as settings, configuration or metric data, is written to the eeprom.
|
|
|
|
It operates by partitioning the eeprom into slots large enough to hold the
|
|
declared buffer (and header) and then writing each new version of the data
|
|
to the next slot, overwriting any older version already in there.
|
|
As it reaches the end of the alotted region of the eeprom it wraps around
|
|
and starts writing from the start of the memory again.
|
|
When initializing an instance it scans the eeprom to find the last written
|
|
version and continues from that.
|
|
|
|
In order to use an eeprom that already has data (and if the structure of the
|
|
buffer changes) the eeprom has to be prepared by formatting the indexes.
|
|
|
|
The interface is pretty straightforward
|
|
|
|
- **begin(eeprom, pageSize, totalPages)** initialization
|
|
- **format()** erase data from eeprom
|
|
- **read(buffer)** read buffer from last location prom
|
|
- **write(buffer)** write buffer to next location on eeprom
|
|
- **getMetrics(slots, writeCounter)** get usage metrics
|
|
|
|
|
|
## Limitation
|
|
|
|
The class does not handle changes in buffer size or structure, nor does
|
|
it detect an eeprom that has data that wasn't written using the class.
|
|
|
|
|
|
## Operational
|
|
|
|
See examples
|
|
|