EEPROMextent
Arduino EEPROM library
EEPROMextent.cpp
1 /*************************************************************
2 project: <EEPROMextent>
3 author: <Thierry PARIS>
4 description: <Class for basic EEPROM functions>
5 *************************************************************/
6 
7 #include "arduino.h"
8 #include "EEPROMextent.h"
9 
10 EEPROMextentClass EEPROMextent;
11 
12 char *EEPROMextentClass::readString(int ee, char *outData, int inSize)
13 {
14  byte* p = (byte*)outData;
15  for (int i = 0; i < inSize; i++)
16  {
17  *p = eeprom_read_byte((uint8_t *) INT64 ee++);
18 
19  if (*p == 0)
20  break;
21  p++;
22  }
23 
24  return outData;
25 }
26 
27 int EEPROMextentClass::writeString(int ee, const char *inData)
28 {
29  const byte* p = (const byte*)inData;
30  int i;
31 
32  for (i = 0;; i++)
33  {
34  const byte b = *p;
35  eeprom_write_byte((uint8_t *) INT64 ee++, b), ++p;
36 
37  if (b == 0)
38  return i + 1;
39  }
40 
41  return i;
42 }
43 
44 int EEPROMextentClass::updateString(int ee, const char *inData)
45 {
46  const byte* p = (const byte*)inData;
47  int i;
48 
49  for (i = 0;; i++)
50  {
51  const byte b = *p;
52  eeprom_update_byte((uint8_t *) INT64 ee++, b), ++p;
53 
54  if (b == 0)
55  return i + 1;
56  }
57 
58  return i;
59 }
60 
61 void EEPROMextentClass::clear(int inStartingAddress, int inSize, byte inFillCharacter)
62 {
63  for (int i = inStartingAddress; i < inStartingAddress + inSize; i++)
64  eeprom_update_byte((uint8_t *)INT64 i, inFillCharacter);
65 }
void clear(int address, int inSize, byte inFillCharacter = 0)
int updateString(int address, const char *inString)
int writeString(int address, const char *inString)
char * readString(int address, char *outString, int inMaxLen)
Main class for basic functions.
Definition: EEPROMextent.h:58