Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8e6d333

Browse files
committed
Added EEPROM support for char*, char const* and String.
1 parent eabd762 commit 8e6d333

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

‎libraries/EEPROM/src/EEPROM.h‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,40 @@ struct EEPROMClass{
133133
for( int count = sizeof(T) ; count ; --count, ++e ) *ptr++ = *e;
134134
return t;
135135
}
136-
136+
137+
String& get(int idx, String& data) {
138+
data = "";
139+
char c;
140+
for (size_t i = idx; (c = get(i, c)); i++) {
141+
data += c;
142+
}
143+
return data;
144+
}
145+
137146
template< typename T > const T &put( int idx, const T &t ){
138147
EEPtr e = idx;
139148
const uint8_t *ptr = (const uint8_t*) &t;
140149
for( int count = sizeof(T) ; count ; --count, ++e ) (*e).update( *ptr++ );
141150
return t;
142151
}
152+
153+
char* put(int idx, char* data) {
154+
size_t i;
155+
for (i = 0; data[i]; i++) {
156+
put(idx + i, data[i]);
157+
}
158+
put (idx + i, '\x00');
159+
return data;
160+
}
161+
162+
char const* put(int idx, char const* data) {
163+
return put(idx, const_cast<char*>(data));
164+
}
165+
166+
String& put(int idx, String& data) {
167+
put(idx, data.c_str());
168+
return data;
169+
}
143170
};
144171

145172
static EEPROMClass EEPROM;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /