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
Show file tree
Hide file tree
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
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
Expand Up @@ -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
******************************************************************************/
Expand Down Expand Up @@ -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;
}

/**
Expand Down
2 changes: 0 additions & 2 deletions EEPROMex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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) {
Expand Down