hello guy, i need some help here
i get some error at maxpeople , my people
#include <EEPROM.h>
#define DEBUG 1 // We want to see debug print statements
// Comment out these lines to avoid seeing print
statements
const int MAXPEOPLE = 10;
struct servicePeople { // Structure definition for servicePeople
int ID;
char Name[20];
char PW[10];
long Phone;
};
union servicePeopleUnion { // A union definition for myUnion
int testID;
struct servicePeople testServicePeople;
}
myUnion;
servicePeople myPeople[MAXPEOPLE] = { // company data for testing
{
0, "This is a dummy","admin",5555555 }
,
{
101,"Kack Lawn Service","Clowder",2345678 }
,
{
222,"Jane's Plants","Noah",4202513 }
,
{
333,"Terrys Pool Service","Billings",4301832 }
};
// function declarations:
void DataDump(struct servicePeople temp);
int FindEepromTop();
int ReadIntFlag();
void ReadOneRecord(int index);
void WriteFirstRecord();
int loopCounter = 0; // Number of passes to make through loop
int initFlag = 0; // Has the EEPROM been initialized?
struct servicePeople temp; // A temporary structure
void setup()
{
int eepromMax;
int i;
Serial.begin(9600);
eepromMax = FindEepromTop(); // How much EEPROM?
Serial.print("EepromMax = ");
Serial.println(eepromMax);
initFlag = ReadIntFlag(); // Initialized?
Serial.print(" flag = ");
Serial.println(initFlag);
for (i = 0; i < MAXPEOPLE; i++) {
WriteOneRecord(i);
}
}
int FindEepromTop()
{
return E2END + 1;
}
int ReadIntFlag()
{
int *ptr = &myUnion.testID;
*ptr = EEPROM.read(0);
return myUnion.testID;
}
void WriteOneRecord(int index)
{
byte *b;
int i;
int offset = index * sizeof(servicePeople);
b = (byte *) &myPeople[index]; // Going to write this record
for (i = 0; i < sizeof(servicePeople); i++)
EEPROM.write(i + offset, *b++);
}
void loop()
{
static int eepromIndex = 1; // Assume there are records
loopCounter++;
if (initFlag > 0) { // There are records to read
ReadOneRecord(eepromIndex++);
if (myUnion.testServicePeople.ID != 0) { // Read some real data
DataDump(myUnion.testServicePeople);
}
}
else {
eepromIndex++; // Make sure loop can end with no records.
}
Serial.println("==========");
if (eepromIndex == MAXPEOPLE) {
TerminationStep(1);
}
}
void ReadOneRecord(int index)
{
byte *bPtr;
int i;
int offset;
offset = index * sizeof(servicePeople); // must offset from 0 in EEPROM
bPtr = (byte *) &myUnion.testServicePeople; // where to place the data read
for (i = 0; i < sizeof(temp); i++) { // Loop through the bytes…
*bPtr = EEPROM.read(offset + i);
bPtr++;
}
}
void DataDump(struct servicePeople temp)
{
Serial.println();
Serial.print("ID = ");
Serial.print(temp.ID);
Serial.print(" Name = ");
Serial.println(temp.Name);
Serial.print(" PW = ");
Serial.print(temp.PW);
Serial.print(" Phone = ");
Serial.println(temp.Phone);
}
