In the mean time, here's what the sketch includes in summary. I think the use of struct is something I need to wrap my brain around to move forward, but perhaps it's even more than that :-):
//...
#include <EEPROMex.h> // https://github.com/thijse/Arduino-EEPROMEx
#include <EEPROMVar.h>
//...
/* ***************************************For EEPROM (Based on an example by Thijs Elenbaas
http://playground.arduino.cc/Code/EEPROMLoadAndSaveSettings */
#define CONFIG_VERSION "ls1" // ID of the settings block
#define memoryBase 32 // Tell it where to store your config data in EEPROM
bool ok = true;
int configAdress = 0;
struct StoreStruct {
int r1h1, r1m1, r1s1, r1h2, r1m2, r1s2, r1h3, r1m3, r1s3, r1h4, r1m4, r1s4, R3h, R3m, R3s, r2tempHigh, r2tempLow;
char version[4]; // CONFIG_VERSION verification
}
/* ***Not really sure what's going on here. This probably makes no sense the way I've interpreted the example. I thought that this
might assign the user setting variables like hh1, mm1, etc in the structure, so hh1 would be stored/recalled as element usersettings.r1h1.
Have to say, a bit stuck in a thicket here...*/
storage = {
hh1, mm1, ss1, hh2, mm2, ss2, hh3, mm3, ss3, hh4, mm4, ss4, R3hh, R3mm, R3ss, tempHigh, tempLow,
CONFIG_VERSION,
};
/* Inserted these based on a YouTube video on structures, but they don't get used anywhere */
StoreStruct usersettings;
int settingsSize = sizeof(StoreStruct);
//...
void setup()
EEPROM.setMemPool(memoryBase, EEPROMSizeUno); //Set memorypool base to 32, assume Arduino Uno board
configAdress = EEPROM.getAddress(sizeof(StoreStruct)); // Size of config object
ok = loadConfig();
//...
void loop()
//...
saveConfig(); // Called once user values have been parsed and stored as ints
//...
bool loadConfig() {
EEPROM.readBlock(configAdress, storage);
Serial.println("Read alarm values: "); // Goal here is to verify some of the user values have been
Serial.println(hh1); // saved and read back correctly (debug only)
Serial.println(mm1);
Serial.println(ss1);
Serial.println(hh2);
Serial.println(mm2);
Serial.println(ss2);
return (storage.version == CONFIG_VERSION);
}
void saveConfig() {
EEPROM.writeBlock(configAdress, storage);
Serial.println("Saved to EEPROM! "); // Let's me know this function was called.
}