-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Implement paged reads and writes (32 bytes pages, as 64 bits doesn't fit on Wire library's buffer) to mitigate EEPROM wearing. - Added html documentation - Splitted docs and extras to another repository
- Loading branch information
Showing
7 changed files
with
275 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Naguissa - https://github.com/Naguissa | ||
hyperion11 - https://github.com/hyperion11 - Multibyte EEPROM read/write | ||
linusnielsen - https://github.com/linusnielsen - Remove stray Serial.print | ||
Alex Wong - https://github.com/alw1746 - Find long reads bug, #3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* I2C EEPROM library example. Split from uRTCLib https://github.com/Naguissa/uRTCLib | ||
* | ||
* This library controls any I2C EEPROM, independent ones or incorporated on DS1307 or DS3231 RTCs. | ||
* | ||
* @copyright Naguissa | ||
* @author Naguissa | ||
* @email naguissa@foroelectro.net | ||
* @url https://www.foroelectro.net/librerias-arduino-ide-f29/ueepromlib-arduino-libreria-simple-y-eficaz-para-e-t225.html | ||
* @url https://github.com/Naguissa/uEEPROMLib | ||
* @version 1.0.0 | ||
* @created 2018-07-27 | ||
*/ | ||
#include "Arduino.h" | ||
#include "Wire.h" | ||
#include "uEEPROMLib.h" | ||
|
||
|
||
// uEEPROMLib eeprom; | ||
uEEPROMLib eeprom(0x57); | ||
|
||
// 305 bytes | ||
char longMessage[310] = "I2C EEPROM library example. Split from uRTCLib\n\nThis library controls any I2C EEPROM, independent ones or incorporated on DS1307 or DS3231 RTCs.\n\nhttps://github.com/Naguissa/uEEPROMLib\nhttps://www.foroelectro.net/librerias-arduino-ide-f29/ueepromlib-arduino-libreria-simple-y-eficaz-para-e-t225.html\0"; | ||
|
||
void setup() { | ||
delay (2000); | ||
Serial.begin(9600); | ||
Serial.println("Serial OK"); | ||
|
||
delay(2500); | ||
Serial.println("Delay OK"); | ||
|
||
#ifdef ARDUINO_ARCH_ESP8266 | ||
Wire.begin(0, 2); // D3 and D4 on ESP8266 | ||
#else | ||
Wire.begin(); | ||
#endif | ||
|
||
// Alligned | ||
if (!eeprom.eeprom_write(0, (byte *) &longMessage[0], 305)) { | ||
Serial.println("Failed to store aligned STRING"); | ||
} else { | ||
Serial.println("Aligned STRING correctly stored"); | ||
} | ||
|
||
if (!eeprom.eeprom_write(311, (byte *) &longMessage[0], 305)) { | ||
Serial.println("Failed to store unaligned STRING"); | ||
} else { | ||
Serial.println("Unaligned STRING correctly stored"); | ||
} | ||
|
||
} | ||
|
||
void loop() { | ||
char *readMessageA; | ||
char *readMessageB; | ||
readMessageA = (char * ) malloc(210); | ||
readMessageB = (char * ) malloc(210); | ||
Serial.println("-------------------------------------"); | ||
Serial.println(); | ||
|
||
Serial.println("Algined string:"); | ||
eeprom.eeprom_read(0, (byte *) readMessageA, 305); | ||
Serial.println(readMessageA); | ||
|
||
Serial.println(); | ||
|
||
Serial.println("Unalgined string:"); | ||
eeprom.eeprom_read(0, (byte *) readMessageB, 305); | ||
Serial.println(longMessage); | ||
|
||
Serial.println(); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.