Nick,
I fully agree.
But - and there's always a but - I DON'T KNOW HOW TO DO THAT.
Considering I bought my FIRST Arduino on 12 April 2012 at 14:19 (Yeah, I still have the receipt).
Before that I knew NOTHING about this language. N O T H I N G !
All I knew was Level2 Basic and a bit of Z80 machine code.
Oh, well and a bit of AREXX.
The person who "introduced" me to them still insists I lean C rather than C++ before I try too much.
Ofcourse it is problematic when the code I am using uses C++ stuff. Anyway.....
Me, being who I am, couldn't wait and also needed an Alarm clock - mine died.
So it was 300% priority!
I got it working as supplied and have since learned how to code BY MY SELF.
Yes, people here have helped me, and I am very appreciative of that. VERY.
I can't afford to sit down and "learn" the language just yet. Probably won't every. Dunno. That's the future.
I get curious and try things. Sure maybe I should study things before I do it, but again: That isn't me.
So, what's gone on.
Well, I got home and sat down and read, read and read the code. Re-wrote whole routines from a working version.
Guess what!
I got it working. It now does what I want.
Now, to what you were suggesting:
How do I put "names" on return values?
If I am shown what to do/how to do it, I learn.
Friday I buy a solenoid and get back to my plant watering system. That's going to be fun.
After that, I have other projects lined up which are backing up on me. (Have I created a monster?) (smile)
For what ever reason: This is what the code looks like now.
** NOTE **
Yes, it is full of old code (// lines) because I have only just got it working and I keep "throwing code at the thing until it works" kind of thing.
Or, should I say:
When I get it working, I change things and leave the old there so I can see where I have been.
/*
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)
{
Serial.print("alarm defer called with ");
Serial.println(fctn);
int rc;
if (fctn==0)
return defered_flag;
if (fctn==1)
{
defered_flag = defered_flag +1;
defered_flag = defered_flag %2;
// EEPROM.write(EEPROM_user+3,defered_flag);
// delay(100);
// return 0;
rc = 0;
}
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)
{
if (defered_flag == 3)
{
rc = 1;
}
if(defered_flag == 1)
{
defered_flag = 0;
//EEPROM.write(EEPROM_user+3,defered_flag);
//delay(100);
rc = 1;
}
else
rc = 0;
// this is because defered_flag is not set and so I need to return a 0 to make the alarm happen.
}
// more EEPROM writing to go here - right?
//EEPROM.write(EEPROM_user+3,defered_flag);
//delay(100);
Serial.print("Alarm defer returning value ");
Serial.println(rc);
return rc;
}
Oh, and the rhetorical question at the end is for me.
As you can see, I have the lines there now, just didn't get to actually make them ...... (what's the term?) "work"?