|
Pico Headers
|
A simple time management library. More...
#include <stdint.h>
Go to the source code of this file.
Macros | |
| #define | _POSIX_C_SOURCE 199309L |
Typedefs | |
| typedef uint64_t | ptime_t |
| Time value expressed in microseconds. | |
Functions | |
| ptime_t | pt_now (void) |
| Returns the present high-res clock time. | |
| void | pt_sleep (ptime_t duration) |
| Sleeps for at least the specified duration. | |
| int64_t | pt_to_usec (ptime_t time) |
| Converts time to microseconds. | |
| int32_t | pt_to_msec (ptime_t time) |
| Converts time to milliseconds. | |
| double | pt_to_sec (ptime_t time) |
| Converts time to seconds. | |
| ptime_t | pt_from_usec (int64_t usec) |
| Make time from microseconds. | |
| ptime_t | pt_from_msec (int32_t msec) |
| Make time from miliseconds. | |
| ptime_t | pt_from_sec (double sec) |
| Make time from seconds. | |
A simple time management library.
This library provides high-res time and sleep functions, as well as unit conversions functions.
Even though ptime_t is expressed in microseconds, it is still recommended that you use the pt_to_usec and pt_from_usec functions should this ever change.
To use this library in your project, add the following
#define PICO_TIME_IMPLEMENTATION #include "pico_time.h"
to a source file (once).
IMPORTANT: On POSIX systems, when defining PICO_TIME_IMPLEMENTATION, one of three conditions must hold:
1) #define _POSIX_C_SOURCE 199309L must precede any header include in the file 2) This library must be included before any other headers 3) The build system must define _POSIX_C_SOURCE 199309L
| #define _POSIX_C_SOURCE 199309L |
| typedef uint64_t ptime_t |
Time value expressed in microseconds.
| ptime_t pt_now | ( | void | ) |
Returns the present high-res clock time.
| void pt_sleep | ( | ptime_t | duration | ) |
Sleeps for at least the specified duration.
Note: On most platforms this function has microsecond resolution, except on Windows where it only has millisecond resoultion.
| int64_t pt_to_usec | ( | ptime_t | time | ) |
Converts time to microseconds.
| int32_t pt_to_msec | ( | ptime_t | time | ) |
Converts time to milliseconds.
| double pt_to_sec | ( | ptime_t | time | ) |
Converts time to seconds.
| ptime_t pt_from_usec | ( | int64_t | usec | ) |
Make time from microseconds.
| ptime_t pt_from_msec | ( | int32_t | msec | ) |
Make time from miliseconds.
| ptime_t pt_from_sec | ( | double | sec | ) |
Make time from seconds.