Shop OBEX P1 Docs P2 Docs Learn Events
nerdDoro; date/time math calculations? — Parallax Forums

nerdDoro; date/time math calculations?

JeffaJeffa Posts: 80
edited 2011-07-17 12:09 in Accessories
One function I am attempting to add to nerdDoro before the fast approaching deadline is a timer to implement a pomodoro. A pomodoro is 25 minutes of time focused on a specific task.
See http://www.pomodorotechnique.com/ for information. I sometimes use it to disipline myself, I hide my email and twitter windows and elminate other distractions to focus on a specific task.

I'm wondering if anyone has any .spin examples of datetime maipulation. I think the more elagent approach would be to take the current tod from the rtc and add 25 minutes and set one of the rtc alarms then check that alarm in my main program loop. Probably wouldn't need an extra cog this way. I've read about how to set the alarm on the rtc, but the datetime addtion of current time plus 25 minutes may be a lot to accomplish in the time I have available.

Alternatley perhaps use a timer object such as this one from the obex: http://obex.parallax.com/objects/45/ This one would probably be easier for me to implement, but the alarm method just seems like the 'right' way to go.

A unix or posix http://en.wikipedia.org/wiki/Unix_time timestamp could be handy. Grab the current timestamp and add 25 minutes. I can accomplish something like this with the previously mentioned object.

Any thoughts, suggestions are welcome. Perhaps someone knows of an object I missed that might have some utility for me in this phase of my Spinneret project nerdDoro.

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-07-17 12:09
    The RTC object has a minute getter. So all you have to do is grab the current minute and add 25. If the result is larger than 60 subtract 60. Then set the alarm. The INT1Alarm(-1, -1, 46) method of the S35390A_RTCEngine.spin object lets you set a minute timer. The INT1AlarmCheck method checks if the alarm went off.
Sign In or Register to comment.