summaryrefslogtreecommitdiff
path: root/EEPROM_IO.h
diff options
context:
space:
mode:
Diffstat (limited to 'EEPROM_IO.h')
-rw-r--r--EEPROM_IO.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/EEPROM_IO.h b/EEPROM_IO.h
new file mode 100644
index 0000000..1c59780
--- /dev/null
+++ b/EEPROM_IO.h
@@ -0,0 +1,24 @@
+#include <Arduino.h>
+
+
+/*********************************************************************************/
+/* EEPROM read/write functions */
+
+template <class T> int eepromWrite(int ee, const T& value) {
+ const byte* p = (const byte*)(const void*)&value;
+ unsigned int i;
+ for (i = 0; i < sizeof(value); i++)
+ EEPROM.write(ee++, *p++);
+ return i;
+}
+
+
+template <class T> int eepromRead(int ee, T& value) {
+ byte* p = (byte*)(void*)&value;
+ unsigned int i;
+ for (i = 0; i < sizeof(value); i++)
+ *p++ = EEPROM.read(ee++);
+ return i;
+}
+
+