OK, I have been searching for the answer on the forums for over 4 hours, I hate to post a questions but I am getting frustrated!
I know this is going to be easy, at least I hope - I am just hitting a mind block. I am looking for a way to print out array values that were defined in a "Struct"
struct config_t
{
unsigned long Val_a; // timer value a
unsigned long Val_b; // timer value b
unsigned long Val_c; // timer value c
.... // there are a total of 16 variables here
} configuration;
I am using the "EEPROMAnything.h" method of reading and writing to the EEPROM. What I am looking to do is Serial.print a menu with the variable names (which I have loaded in a char array) along with the current values in the structure shown above.
So, I have the names located here:
char* EEVarNames[]={"","Timer A","Timer B","Timer C","... (16 var names) }; // null at beginning so first used spot is 1, not 0. Makes displaying the menu nicer :-)
Serial.println("Settings Menu");
Serial.println("Timer Values in milliseconds.");
Serial.println("Enter 99 to exit");
Serial.println("------------------------------" );
for (int i = 1; i < 16; i++)
{
Serial.print(i);
Serial.print(". ");
Serial.print(EEVarNames[i]); //works great, prints out the individual names.
Serial.print(" ");
Serial.println(configuration.[EEVarNames[i]); //this doesn't work... looking to walk the struct using the same technique as above.
}
The last line there is what I am trying to figure out. How do I get it to walk the array? I have tried pointers but am not sure of the proper syntax.
I am looking for an output like this:
- Timer A 60000
- Timer B 120000
- Timer C 3000
... etc. I have a prompt at the end that asks what # you would like to change and updates the configuration.Val_x value. Once you're done you can commit it to the EEPROM. I just need to figure out how to walk the damm array!
I know, this is probably a basic question but I couldn't find any examples looking at arduino references as well as more general C++ ones.
Thanks for your help!
Steve