In my project i am using a struct that is read at the start of the program.
This struct contains a mix int, bytes, longs and characters.
For saving and loading of the struct is use the example found here: http://playground.arduino.cc/Code/EEPROMLoadAndSaveSettings
But now i want to have a nice formated output to the terminal.
If i do a simple
for(unsigned int t = 0; t < sizeof(confValue); t++)
{
Serial << t << "\t" << _DEC(EEPROM.read(t)) << endl;
}
i get a list with all the EEPROM members, but they dont show the actual value.
Using EEPROMex makes is possible to read a single int, byte, long and char, but i cant figure out how to get this in a list.
I dont think i should do something like this:
In my project i am using a struct that is read at the start of the program.
This struct contains a mix int, bytes, longs and characters.
EEPROM_readAnything() and EEPROM_writeAnything() will read and write the whole struct full of data in one call.
Then, print the elements in the struct, not the raw bytes.
Yes i know, but i dont want to reload the struct, but output the EEPROM content to the Serial port.
This is how i do it now:
void dumpConfig()
{
// Send the EEPROM content to the termina
Serial << "Show EEPROM" << endl;
for(unsigned int t = 0; t < sizeof(confValue); t++)
{
Serial << t << "\t" << _DEC(EEPROM.read(t)) << endl;
}
}
An easy way to do this automatically would be to declare the struct as a local variable in a function that reads it from EEPROM and prints its content to serial.
Sometimes i feel stupid becourse i cant figure out what is wrong here:
void dumpConfig() {
struct EEPROMStruct{
long _azAdZeroOffset; // azAdZeroOffset value
long _elAdZeroOffset; // elAdZeroOffset value
long _azScaleFactor; // azimuth encoder scale factor
long _elScaleFactor; // elevation encoder scale factor
int _closeEnough; // value for catcing position
long _azimuthPark; // Position where the antenna is parked after a timeout
long _elevationPark; //
byte _rotationSpeed; // Actual rotation speed
byte _rotationSpeed4; // Rotator speed High
byte _rotationSpeed3; //
byte _rotationSpeed2; //
byte _rotationSpeed1; // Rotator speed Low
unsigned long _rotorParkInterval; // Duration after wich the rotors are parked
char softwareVersion[4]; // contains version number
}
EEPROM_Value;
EEPROM_readAnything(0, EEPROM_value);
}
I get a 'EEPROM_value' was not declared in this scope error.
Maybe its to late and i should go to sleep.
Its hopeles with me, now got a different error:
EEPROM:127: error: no matching function for call to 'EEPROM_readAnything(int, dumpConfig()::EEPROM_Struct&)'
The only thing i dit was chancing EEPROM_value in EEPROM_Value and nothing else.
I now do it the old fasioned way
void dumpConfig() {
struct EEPROM_Struct{
long _azAdZeroOffset; // azAdZeroOffset value
long _elAdZeroOffset; // elAdZeroOffset value
long _azScaleFactor; // azimuth encoder scale factor
long _elScaleFactor; // elevation encoder scale factor
int _closeEnough; // value for catcing position
long _azimuthPark; // Position where the antenna is parked after a timeout
long _elevationPark; //
byte _rotationSpeed; // Actual rotation speed
byte _rotationSpeed4; // Rotator speed High
byte _rotationSpeed3; //
byte _rotationSpeed2; //
byte _rotationSpeed1; // Rotator speed Low
unsigned long _rotorParkInterval; // Duration after wich the rotors are parked
char softwareVersion[4]; // contains version number
}
EEPROM_Value;
Serial << "Show EEPROM" << endl;
for (unsigned int t=0; t<sizeof(EEPROM_Value); t++) {
*((char*)&EEPROM_Value + t) = EEPROM.read(t);
}
Serial << EEPROM_Value._azAdZeroOffset << endl; // azAdZeroOffset value
Serial << EEPROM_Value._elAdZeroOffset << endl; // elAdZeroOffset value
Serial << EEPROM_Value._azScaleFactor << endl; // azimuth encoder scale factor
Serial << EEPROM_Value._elScaleFactor << endl; // elevation encoder scale factor
Serial << EEPROM_Value._closeEnough << endl; // value for catcing position
Serial << EEPROM_Value._azimuthPark << endl; // Position where the antenna is parked after a timeout
Serial << EEPROM_Value._elevationPark << endl; //
Serial << EEPROM_Value._rotationSpeed << endl; // Actual rotation speed
Serial << EEPROM_Value._rotationSpeed4 << endl; // Rotator speed High
Serial << EEPROM_Value._rotationSpeed3 << endl; //
Serial << EEPROM_Value._rotationSpeed2 << endl; //
Serial << EEPROM_Value._rotationSpeed1 << endl; // Rotator speed Low
Serial << EEPROM_Value._rotorParkInterval << endl; // Duration after wich the rotors are parked
Serial << EEPROM_Value.softwareVersion << endl; // contains version number
}
gharryh:
The only thing i dit was chancing EEPROM_value in EEPROM_Value and nothing else.
I now do it the old fasioned way
I can't imagine why you wrote a function that reads the config and prints it, in a way that does not provide you any means to access the values that you read. Why on earth would you do it like that? All you need to do is declare a struct that holds the config values, write a function to read it from EEPROM (or use the simple pre-existing function that does the job for you) and write a function to print the content.
I can't imagine why you wrote a function that reads the config and prints it, in a way that does not provide you any means to access the values that you read. Why on earth would you do it like that?
It was a test. This is a follow-on from another thread.