From 48ddce71c6a26d1254b6c763ca85cd8651be976d Mon Sep 17 00:00:00 2001 From: Markus Sattler Date: Sun, 3 May 2015 18:15:54 +0200 Subject: [PATCH] add EEPROM.getDataPtr() fix all warnings in EEPROMClass --- libraries/EEPROM/EEPROM.cpp | 11 ++++++++--- libraries/EEPROM/EEPROM.h | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libraries/EEPROM/EEPROM.cpp b/libraries/EEPROM/EEPROM.cpp index 0949e4195..74e7f3b0f 100644 --- a/libraries/EEPROM/EEPROM.cpp +++ b/libraries/EEPROM/EEPROM.cpp @@ -35,7 +35,7 @@ #define CONFIG_ADDR (SPI_FLASH_SEC_SIZE * CONFIG_SECTOR) EEPROMClass::EEPROMClass() -: _data(0), _size(0) +: _data(0), _size(0), _dirty(false) { } @@ -67,7 +67,7 @@ void EEPROMClass::end() uint8_t EEPROMClass::read(int address) { - if (address < 0 || address >= _size) + if (address < 0 || (size_t)address >= _size) return 0; return _data[address]; @@ -75,7 +75,7 @@ uint8_t EEPROMClass::read(int address) void EEPROMClass::write(int address, uint8_t value) { - if (address < 0 || address >= _size) + if (address < 0 || (size_t)address >= _size) return; _data[address] = value; @@ -101,5 +101,10 @@ bool EEPROMClass::commit() return ret; } +uint8_t * EEPROMClass::getDataPtr() +{ + return &_data[0]; +} + EEPROMClass EEPROM; diff --git a/libraries/EEPROM/EEPROM.h b/libraries/EEPROM/EEPROM.h index 932b791bb..97dd4c26a 100644 --- a/libraries/EEPROM/EEPROM.h +++ b/libraries/EEPROM/EEPROM.h @@ -36,6 +36,8 @@ class EEPROMClass bool commit(); void end(); + uint8_t * getDataPtr(); + template T &get(int address, T &t) { if (address < 0 || address + sizeof(T) > _size)