Go Down

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


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.


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]

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


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
#define dtNBR_ALARMS 12  // assume non-AVR has more memory

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?


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.

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