diff --git a/libraries/EEPROM/EEPROM.h b/libraries/EEPROM/EEPROM.h index 0c7068d1c..52de83909 100644 --- a/libraries/EEPROM/EEPROM.h +++ b/libraries/EEPROM/EEPROM.h @@ -24,6 +24,7 @@ #include #include +#include class EEPROMClass { @@ -35,6 +36,27 @@ class EEPROMClass void commit(); void end(); + template T &get(int address, T &t) + { + if (address < 0 || address + sizeof(T) > _size) + return t; + + uint8_t *ptr = (uint8_t*) &t; + memcpy(ptr, _data + address, sizeof(T)); + return t; + } + + template const T &put(int address, const T &t) + { + if (address < 0 || address + sizeof(T) > _size) + return t; + + const uint8_t *ptr = (const uint8_t*) &t; + memcpy(_data + address, ptr, sizeof(T)); + _dirty = true; + return t; + } + protected: uint8_t* _data; size_t _size; diff --git a/platform.txt b/platform.txt index 505bfea89..3490ef416 100644 --- a/platform.txt +++ b/platform.txt @@ -91,5 +91,5 @@ tools.esptool.path={runtime.ide.path}/hardware/tools/esp8266 tools.esptool.upload.protocol=esp tools.esptool.upload.params.verbose=-vv tools.esptool.upload.params.quiet= -tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp {serial.port} -ca 0x00000 -cf "{build.path}/{build.project_name}_00000.bin" -ca 0x40000 -cf "{build.path}/{build.project_name}_40000.bin" +tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" -ca 0x00000 -cf "{build.path}/{build.project_name}_00000.bin" -ca 0x40000 -cf "{build.path}/{build.project_name}_40000.bin"