C Language Development Kit/Functions/TimerValue

From OptiWiki

Jump to: navigation, search
Description Returns the time that is left of the time that was specified with the starttimer() function. The time is specified in units of 20 milliseconds.
Syntax
int timervalue(void);
Arguments None
Returns Remaining timer value in units of 20 milliseconds. For example, if timervalue() returns 5, 100 milliseconds will elapse before the timer is finished.
Remarks The timer can be started with the starttimer() function.
Example
#include "lib.h"
#include <stdio.h>
 
void main( void )
{
    while( 1 )
    {
        printf("\fTick off 5 sec");
        starttimer( 255 );
        while( !endtimer())
        {
            printf("\nTime left %d s", timervalue()/50);
            sound( TSTANDARD, VSTANDARD, SMEDIUM, 0);
            delay( 50 );
        }
 
        printf("\nDone");
        resetkey();
        while( !kbhit())
            idle();
    }
}


Views
Personal tools