sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
EEPROMAnything.h
Go to the documentation of this file.
1 #include <EEPROM.h>
2 #include <Arduino.h> // for type definitions
3 
4 template <class T> int EEPROM_writeAnything(int ee, const T& value)
5 {
6  const byte* p = (const byte*)(const void*)&value;
7  unsigned int i;
8  for (i = 0; i < sizeof(value); i++)
9  EEPROM.write(ee++, *p++);
10  return i;
11 }
12 
13 template <class T> int EEPROM_readAnything(int ee, T& value)
14 {
15  byte* p = (byte*)(void*)&value;
16  unsigned int i;
17  for (i = 0; i < sizeof(value); i++)
18  *p++ = EEPROM.read(ee++);
19  return i;
20 }
uint8_t byte
Definition: Arduino.h:123
float T
Definition: Yun_Log_BatteryDisCharging.ino:108
int EEPROM_writeAnything(int ee, const T &value)
Definition: EEPROMAnything.h:4
int EEPROM_readAnything(int ee, T &value)
Definition: EEPROMAnything.h:13
uint8_t p
Definition: onewire.c:408
int i
Definition: ser-log.py:25