I just started with MegUnoLink and I really likke it's potential but I run in to a EEprom problem.
So I have this EEprom struct
Code: Select all
//EEPROM Storage
struct DecoderSettings
{
int wrongAnswerPenalty;
static volatile int countDownClock;
void Reset()
{
int wrongAnswerPenalty = 0; //Number of minutes to penalise teams for wrong answer (0 = no penalty, 1 = 1 minute penalty)
static volatile int countDownClock = 1200; //Time in seconds (3300 = 55 minutes, 2700 = 45 minutes)
}
};
EEPROMStore<DecoderSettings> DecoderConfig;
Code: Select all
//Command Handler
CommandHandler<> SerialCommandHandler;
void Cmd_GetDecoderValues(CommandParameter &Parameters)
{
Parameters.GetSource().print(F("Aantal strafminuten = "));
Parameters.GetSource().println(DecoderConfig.Data.wrongAnswerPenalty);
Parameters.GetSource().print(F("Timer = "));
Parameters.GetSource().println(DecoderConfig.Data.countDownClock);
}
So my solution was simple. I took DecoderConfig.Data.wrongAnswerPenalty from the GET function and put that in place of the variable like this
Before using EEprom with Global Variable
Code: Select all
//Apply penalty for incorrect answers (may be no penalty if wrongAnswerPenalty = 0)
countDownClock -= wrongAnswerPenalty * 60);
if(countDownClock< 0){
countDownClock = 0;
}
Now while using EEprom with variable in struct:
Code: Select all
//Apply penalty for incorrect answers (may be no penalty if wrongAnswerPenalty = 0)
countDownClock -= (DecoderConfig.Data.wrongAnswerPenalty * 60);
if(countDownClock< 0){
countDownClock = 0;
}
I tried to do the same with the second variable countDownClock.
But now if I use the Interface the GET button only shows GETDecoderValues in the serialmonitor but no values....
So while I don't get any errors, I'm not even sure what values the EEprom holds for those variables..
My questions are :
What is the best way to put the Eeprom value in to my code as a variable (substituting the previous Global variable)?
Why doesn't the GET button show the values on the serial monitor while SET still seems to work?
What is the best way to save multiple values from the Interface in to EEprom with just one button?
Thank you already!