WildBill,
Your reply earlier on was most valuable.
Alas I need help again.
And I don't really like asking for help but when it gets to this, I will try anything.
The code was "working" - yeah, there was still a couple of bugs floating around, but they weren't THAT bad.
I was tracking them down, but was working on some other stuff.
I have/had TWO copies of the file. One for the laptop to flash into the clock and one on the main PC.
I did some code modifications, uploaded them and all seemed ok. Alas: SEEMED!
So with that, I copied over the PC version as well.
Now I have a problem and I think it is in this routine, because if I change it to just return 0; the sketch works.
(As seen at the top of the sketch.)
(and yeah: I can't spell defer/e.)
Talk though below.
// My routine to defer alarms for people who beat the alarm.
/*
Call it with 0 return the status of the defered alarms DISPLAY ONLY.
Call it with 1 to set the flag to skip the next alarm.
Call it with 2 to set the MASTER defere flag.
Call it with 3 to return the status and clear if needed. This is called when the alarm is active.
*/
int alarm_defere(int fctn)
{
//
return 0;
int rc;
if (fctn==0)
//return defered_flag;
rc = defered_flag;
if (fctn==1)
{
defered_flag = defered_flag +1;
defered_flag = defered_flag %2;
rc = defered_flag;
}
if (fctn==2) // This is for future use as a quick turn off for all alarm - toggle.
{
defered_flag = defered_flag +1;
defered_flag = defered_flag %2;
//
if (defered_flag == 1)
{
defered_flag = 3;
}
rc = 1;
}
else
if (fctn==3)
{
//
Serial.println("IOIOIOIO");
if (defered_flag == 3)
{
//return 1;
rc = 1;
}
else
if(defered_flag == 1)
{
defered_flag = 0;
rc = 1;
}
else
{
rc = 0;
}
}
EEPROM.write(EEPROM_user+3,defered_flag);
delay(100);
Serial.print("defered flag is ");
Serial.println(rc);
Serial.println("-=-=-=-=-=-=-=-=-=-=");
return rc;
}
You can see my effort at tracking the code at the bottom - which is probably a dismal effort - but please indulge me.
When the clock is running I want a way to defer alarms, so if I am going away for a day, get up earlier than the alarm, feel sick and am not going to work the next day: I can defer the alarm.
Probably not the best word, but the one which came to mind when I needed the function.
Pressing one button makes it skip ONLY the next alarm. Pressing another button makes it skip ALL alarms until the button is pressed again.
Now, excuse how I { } things. I want to see the start and end of the { }. Some people put the { at the end of the previous line.
To each their own. This is how I do mine.
I also try to avoid the "trick" of things like:
if (blah == foo) do_something;
Because I am not that confident yet at parsing the code correctly, so it is all how it is above.
This is also a big cut down on what it was. There were EEPROM_write() all over the place in each sub-routine. I rationalised them and put ONE at the bottom.
I have checked the { } match and they are all there.
Now what I am worried about is I have become "obsessed" with all the ELSE statements.
Do I need to explain any more on what the routine is doing?
Any variables which aren't named here - defered_flag for instance - are GLOBAL.
P.S.
"Normally" defered_flag is 0.
The clock is "ticking" and then it just stops ticking.
I have code that sends the time out the serial port/debug thingy.
I don't get to see any of the stuff I put in, because it just stops ticking and hangs.
Yeah, so I should "track" what happens with defered_flag == 0.
So I shall guess the problem is in/around there.