Initialisation
This commit is contained in:
20
libraries/EEPROMAnything/EEPROMAnything.h
Normal file
20
libraries/EEPROMAnything/EEPROMAnything.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <EEPROM.h>
|
||||
#include <Arduino.h> // for type definitions
|
||||
|
||||
template <class T> int EEPROM_writeAnything(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 EEPROM_readAnything(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;
|
||||
}
|
||||
Reference in New Issue
Block a user