We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ed76e56 commit 69158c2Copy full SHA for 69158c2
hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.h
@@ -35,6 +35,27 @@ class EEPROMClass
35
void commit();
36
void end();
37
38
+ template<typename T> T &get(int address, T &t)
39
+ {
40
+ if (address < 0 || address >= _size)
41
+ return t;
42
+
43
+ uint8_t *ptr = (uint8_t*) &t;
44
+ for(int count = 0; count < sizeof(T); ++count) *ptr++ = _data[address + count];
45
46
+ }
47
48
+ template<typename T> const T &put(int address, const T &t)
49
50
51
52
53
+ const uint8_t *ptr = (const uint8_t*) &t;
54
+ for(int count = 0; count < sizeof(T); ++count) _data[address + count] = *ptr++;
55
+ _dirty = true;
56
57
58
59
protected:
60
uint8_t* _data;
61
size_t _size;
0 commit comments