Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue with allowed writes and updateBlock. #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixes issue with allowed writes and updateBlock.
stevemayhew committed Aug 1, 2016

Verified

This commit was signed with the committer’s verified signature. The key has expired.
viccuad Víctor Cuadrado Juan
commit f075414832ef840dbdcff4484ed31cd9d0bb7a53
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.cproject
.project
11 changes: 9 additions & 2 deletions EEPROMex.cpp
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
******************************************************************************/

#define _EEPROMEX_VERSION 1_0_0 // software version of this library
//#define _EEPROMEX_DEBUG // Enables logging of maximum of writes and out-of-memory
#define _EEPROMEX_DEBUG // Enables logging of maximum of writes and out-of-memory
/******************************************************************************
* Constructors
******************************************************************************/
@@ -99,7 +99,14 @@ int EEPROMClassEx::getAddress(int noOfBytes){
* Check if EEPROM memory is ready to be accessed
*/
bool EEPROMClassEx::isReady() {
return eeprom_is_ready();
bool isReady = eeprom_is_ready();
#ifdef _EEPROMEX_DEBUG
Serial.print("isReady() returns: "); Serial.println(isReady);
Serial.print("allowedWrites: "); Serial.println(_allowedWrites);
#else
Serial.print("isReady() returns: "); Serial.println(isReady);
#endif
return isReady;
}

/**
2 changes: 0 additions & 2 deletions EEPROMex.h
Original file line number Diff line number Diff line change
@@ -144,7 +144,6 @@ class EEPROMClassEx
template <class T> int updateBlock(int address, const T value[], int items)
{
int writeCount=0;
if (!isWriteOk(address+items*sizeof(T))) return 0;
unsigned int i;
for (i = 0; i < (unsigned int)items; i++)
writeCount+= updateBlock<T>(address+(i*sizeof(T)),value[i]);
@@ -158,7 +157,6 @@ class EEPROMClassEx
template <class T> int updateBlock(int address, const T& value)
{
int writeCount=0;
if (!isWriteOk(address+sizeof(value))) return 0;
const byte* bytePointer = (const byte*)(const void*)&value;
for (unsigned int i = 0; i < (unsigned int)sizeof(value); i++) {
if (read(address)!=*bytePointer) {