Permalink
Branch: master
Find file Copy path
58d9125 Sep 20, 2015
2 contributors

Users who have contributed to this file

@collin80 @Beanow
33 lines (26 sloc) 678 Bytes
//EEPROMAnything is taken from here: http://www.arduino.cc/playground/Code/EEPROMWriteAnything
#ifndef EEPROMAnything_h
#define EEPROMAnything_h
#include "EEPROM.h"
#if ARDUINO < 100
#include <WProgram.h>
#else
#include <Arduino.h>
#endif
template <class T> int EEPROM_writeAnything(int ee, const T& value)
{
const byte* p = (const byte*)(const void*)&value;
int i;
for (i = 0; i < sizeof(value); i++)
EEPROM.update(ee++, *p++);
return i;
}
template <class T> int EEPROM_readAnything(int ee, T& value)
{
byte* p = (byte*)(void*)&value;
int i;
for (i = 0; i < sizeof(value); i++)
*p++ = EEPROM.read(ee++);
return i;
}
#endif