Go Down

Topic: Time and TimeAlarms Libraries – Ask here for help or suggestions (Read 215016 times) previous topic - next topic

MBC99

Read the time from the RTC. If it is time to do something, do it. If not, don't.

The TimeAlarm class does take care of making sure that the thing to be done is done only once, when the time is right, so you'll need to deal with that, too.
So you say to just compare for example if programedHour==hour(), programmedMinute==minute() etc. then do something?

I will take a look at that

Have you used Alarm.delay() anywhere in your program
Alarm.dealay() not for sure.
However there's a 1ms delay, it's the only delay on the whole code. I have alredy taken care that OneWire doesen't use delays.


MBC99

I'd also read from the RTC after setting the time, just as a sanity check, to make sure that you have the correct number of values, in the correct order. If you are setting the time to 9:29, but the time that gets read after you do that is 255:255, well, something isn't right.
Do you mean to just this:
Code: [Select]
Serial.print(hour());
  Serial.print("\t");
  Serial.print(minute());
  Serial.print("\t");
  Serial.println(second());


just after setting the time?
I've tried it, the results are consistent and correct.

MBC99

Ok, I feel very stupid. It was the freaking 1ms delay.
I knew they could interfer with the code, but come on, it's just 1ms  >:(

Thanks to all of you.


However I'll try to do what @PaulS has said. Because I'm at 96% capacity on my arduino nano...

One last question...
To change the number of alarms I have to modify the .h file:
Code: [Select]
#if defined(__AVR__)
#define dtNBR_ALARMS 6   // max is 255
#else
#define dtNBR_ALARMS 12  // assume non-AVR has more memory
#endif


I have to change the number 6 by the number of alarms I want, but what does the second line (the one with the 12) do?

PaulS

Quote
I knew they could interfer with the code, but come on, it's just 1ms
It's not that they interfere with each other. The call to delay() in the Alarm class is the only way that the class has of knowing that ANY time has passed. That method could be called checkForTimePassing(), and maybe it would be more obvious that it needed to be called regularly.

Quote
but what does the second line (the one with the 12) do?
It sets the number of alarms on boards that do not have an AVR chip, such as the SAM32 boards. The ARM (non-AVR) boards have, in general, much more memory.
The art of getting good answers lies in asking good questions.

Go Up