mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-24 13:39:14 +01:00
21 lines
507 B
C++
21 lines
507 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;
|
|
}
|