It looks a lot like I'm getting Exceeded writes issue after my program has reported it has written everything it needed to.
but that doesn't make sense, I would be thankful for another set of eyes on this one.
The goal is to get a serial print out of whatever random assignment is made to the layout array
however what I get is an error from the EEPROMex library that prints "Exceeded maximum number of writes" continually line after line
#include <EEPROMex.h>
//eepromextest using the uno
//builds a letter layout with randomly assigned ints
int alphaAddress = 0;
int key=12;
boolean builtLayout=false;
char theLetter;
byte Lcount=0;
#define LSIZE 26
int layout[LSIZE]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
#define ALPHA 97
void setup()
{
Serial.begin(9600);
//still figuring out these safty functions are suposed to work
//EEPROM.setMemPool(350, EEPROMSizeUno);
//EEPROM.setMaxAllowedWrites(420);
//delay(100);
if (beenHere(511,key)==false){//this prevents writing the assignment over and over, persistently
randAssignment(0,25);//lowercase storage, addressspace=letter
EEPROM.write(511,key);//set key so assignment only happens once/change to rewrite
Serial.println("key wrote");
}
else{builtLayout=true;};
Serial.print("build ");
Serial.println(builtLayout);//---------!Continuealy prints "Exceeded maximum number of writes"
//-------------------------------------------!after this point, with "built" reading true
//this finds the values and reports what letter they will corespond with
for (int theValue=1;theValue<32761;theValue++){
theLetter=checkEX(theValue);
if(theLetter==0){
continue;
}
else{
Serial.print(theLetter);
Serial.print(" == ");
Serial.println(theValue);
Lcount++;
};
if(Lcount==LSIZE){
break;
}
}
}
void loop()
{
}
//-----------------------------------------------functions
//-------------------------------------------------random assignement function
void randAssignment(byte startL, byte endL)
{//random assignment
for (int makeLetter=startL;makeLetter<endL;makeLetter++){
int data=random(1, 32760);
layout[makeLetter]=data;
delay(30);
}
EEPROM.writeBlock<int>(alphaAddress, layout, LSIZE);
builtLayout=true;
}
//----------------------------------------------layout checking function
char checkEX(int chordvalue)
{
EEPROM.readBlock<int>(alphaAddress, layout, LSIZE);
for(int i=0;i<LSIZE;i++){
if(layout[i]==chordvalue){
return char(i+ALPHA);
}
}
return 0;
}
//-----------------------------check for persistent key
boolean beenHere(int address, byte code)
{//establishes if source has been run on uploaded to unit with a key/code
byte potentialCode=EEPROM.read(address);
if(code==potentialCode){
return true;
}
else{return false;};
}
I've taken a closer look at the library source but i'm not quite sure I understand whats going on yet
shouldn't the size of the layout in eeprom be 52 bytes?