Where would I find the source code for this library?
Within the program files of your computer, go to arduino, then to libraries.
Otherwise please specify source code.
Do you need help with something? Check my signature link if so, otherwise the current code release is here: https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/libraries/EEPROM
pYro_65:
Do you need help with something? Check my signature link if so, otherwise the current code release is here: https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/libraries/EEPROM
I just wanted modify it to add some readstring, writestring and dump functions to it rather the code for them limited to the particular sketch I am working on.
If you are interested the code is attached should you wish to add it (or a modified version) to your official library
The readstring function includes an EEPROM address pointer that increments (outside the function) as you read sequentional strings from the EEPROM.
Also you can read fixed length strings or delimited strings.
bool isPrintableChar(const char cChar)
{
return (cChar >= ' ') && (cChar <= '~');
}
void dump()
{
String str;
Serial.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
for (int nEEPROMIndex = 0; nEEPROMIndex < length(); nEEPROMIndex++)
{
str += String((char)read(nEEPROMIndex));
}
Serial.print("EEPROM = ");
Serial.println(str);
Serial.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
}
bool readString(uint16_t& nAddr, const int nLen, String &str)
{
int nI = 0;
str = "";
for (nI = 0; nI < nLen; nI++)
{
if ((nI + nAddr) >= length())
break;
str += String((char)read(nI));
}
nAddr += nI;
return str.length() > 0;
};
bool readString(uint16_t& nAddr, const char cDelim, String &str)
{
char cCh = 0;
int nI = 0;
str = "";
while (true)
{
cCh = (char)read(nI + nAddr);
if ((cCh != cDelim) && isPrintableChar(cCh))
str += String(cCh);
nI++;
if (((nI + nAddr) >= length()) || (cCh == cDelim) || (!isPrintableChar(cCh)))
break;
}
nAddr += nI;
return str.length() > 0;
};
bool writeString(const uint16_t nAddr, String &str)
{
return writeString(nAddr, str.c_str());
};
bool writeString(const uint16_t nAddr, const char *sz)
{
int nI = 0;
for (nI = 0; nI < strlen(sz); nI++)
{
if ((nI + nAddr) < length())
update(nAddr + nI, sz[nI]);
else
break;
}
return nI == strlen(sz);
};
void clear(uint16_t nStartAddr, uint8_t nVal = 0)
{
for (uint16_t nI = nStartAddr; nI < length(); nI++)
write(nI, nVal);
}