mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-11 07:25:07 +01:00
21 lines
488 B
C++
21 lines
488 B
C++
#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;
|
|
}
|