PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

use of the Timer classes

Ok, first off, pardon my stupidity. I am am getting up the curve on using EDGELIB (and re-familiarising myself with C++ at the same time) having done some work years ago with Gapidraw.

Anywho, this will hopefully be pretty simple for you clever folks...

How do you use the timer classes?
And how does the "timedelta" variable fit in?

I am trying to create a simple countdown timer in hours minutes and seconds.

I cannot find anywhere which explains how the timing and the timers work, I know there is the Reference Guide at EDGELIB, but it seems quite basic in this area. I will be more than happy to be pointed in the right direction if nobody wants to eloborate.

Many thanks. :lol:
Hi,

For a simple timer, we recommend using a simple variable, such as an unsigned long. The timedelta parameter is in milliseconds, for each second multiply the variable by 1000.

For example, when initializing this timer to 1 minute, 15 seconds use this formula: timervar = (minutes * 60 + seconds) * 1000.

When you need this timer to countdown, just decrease the value by timedelta each frame (make sure it doesn't get smaller than 0 though).

The EVTimer class can be useful when you want to vary the timer speed. You can pass the timedelta variable into an instance of this class, and get the modified timedelta value depending on its speed setting. A good example is a timer that slows down, the EVTimer makes it a smooth transition.