# Timer

## API: ALLEGRO_TIMER

This is an abstract data type representing a timer object.
A timer object can act as an event source so can be casted to
ALLEGRO_EVENT_SOURCE*.

## API: ALLEGRO_USECS_TO_SECS

Convert microseconds to seconds.

## API: ALLEGRO_MSECS_TO_SECS

Convert milliseconds to seconds.

## API: ALLEGRO_BPS_TO_SECS

Convert beats per second to seconds.

## API: ALLEGRO_BPM_TO_SECS

Convert beats per minute to seconds.

## API: al_get_timer_count

Return the timer's counter value. The timer can be started or stopped.

## API: al_get_timer_speed

Return the timer's speed, in seconds.

## API: al_install_timer

Install a new timer. If successful, a pointer to a new timer object is
returned, otherwise NULL is returned.  *speed_secs* is in seconds per
"tick", and must be positive. The new timer is initially stopped.

The system driver must be installed before this function can be called.

Usage note: typical granularity is on the order of microseconds, but with
some drivers might only be milliseconds.

## API: al_set_timer_count

Change a timer's counter value. The timer can be started or stopped.
COUNT value may be positive or negative, but will always be incremented
by +1.

## API: al_set_timer_speed

Set the timer's speed, i.e. the rate at which its counter will be
incremented when it is started. This can be done when the timer is
started or stopped. If the timer is currently running, it is made to
look as though the speed change occured precisely at the last tick.

*speed_secs* has exactly the same meaning as with [al_install_timer].

## API: al_start_timer

Start the timer specified.  From then, the timer's counter will increment
at a constant rate, and it will begin generating events.  Starting a
timer that is already started does nothing.

## API: al_stop_timer

Stop the timer specified.  The timer's counter will stop incrementing and
it will stop generating events.  Stopping a timer that is already stopped
does nothing.

## API: al_timer_is_started

Return true if the timer specified is currently started.

## API: al_uninstall_timer

Uninstall the timer specified. If the timer is started, it will
automatically be stopped before uninstallation. It will also
automatically unregister the timer with any event queues.

Does nothing if passed the NULL pointer.

