We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 9645fd9 + 5a4c4c3 commit 3ef9f9dCopy full SHA for 3ef9f9d
libraries/EEPROM/EEPROM.h
@@ -24,6 +24,7 @@
24
25
#include <stddef.h>
26
#include <stdint.h>
27
+#include <string.h>
28
29
class EEPROMClass
30
{
@@ -35,6 +36,27 @@ class EEPROMClass
35
36
void commit();
37
void end();
38
39
+ template<typename T> T &get(int address, T &t)
40
+ {
41
+ if (address < 0 || address + sizeof(T) > _size)
42
+ return t;
43
+
44
+ uint8_t *ptr = (uint8_t*) &t;
45
+ memcpy(ptr, _data + address, sizeof(T));
46
47
+ }
48
49
+ template<typename T> const T &put(int address, const T &t)
50
51
52
53
54
+ const uint8_t *ptr = (const uint8_t*) &t;
55
+ memcpy(_data + address, ptr, sizeof(T));
56
+ _dirty = true;
57
58
59
60
protected:
61
uint8_t* _data;
62
size_t _size;
0 commit comments