Timers with PROS

How do I timer in PROS? Is the feature built in, or do I need to create my own timer functions? If the latter, I can think of how I would do it, but I’m sure somebody has a better way of writing timers than I do.

Thanks in advance

Use millis() or a task.

What are you trying to do? Are you looking for something analogous to ROBOTC timers?

Yes, I’m looking for something equivalent to ROBOTC timers. I’m trying to create a timeout for a PID loop.

So millis will return a time index? EDIT: Looked at the API for that function, yup that’s what it does. Searching for timer doesn’t give any results, so expanding parameters helps :slight_smile:

This is normally how I do a timeout in ROBOTC.

void
foo( )
{
    long    currentTime;

    // some code here

    // wait for end - 5 seconds maximum
    for( currentTime = nSysTime; currentTime > (nSysTime - 5000);)
        {
        // Some more code here
        // that would call break when complete
        
        wait1Msec(10);
        }

    // yet more code
}

replacing nSysTime with mills() should work.

void
foo( )
{
    long    currentTime;

    // some code here

    // wait for end - 5 seconds maximum
    for( currentTime = millis(); currentTime > (millis() - 5000);)
        {
        // Some more code here
        // that would call break when complete
        
        delay(10);
        }

    // yet more code
}