cronos1
This abstraction allows applications to hide the exact data type representation and period of the system's native ticker. This provides a consistent interface for specifying delays, timeouts, etc., regardless of the target system.
This library is provided as a single C++17 header file.
See the example for general usage and notes until proper documentation is written.
The native system tick capability is used on the following target platforms. The default C++ API at the bottom of the table is used for all other platforms.
Header | API | Representation | Period | |
---|---|---|---|---|
Arduino | Arduino.h |
unsigned long millis() |
unsigned long |
Milliseconds |
ESP-IDF | esp_timer.h |
int64_t esp_timer_get_time(void) |
int64_t |
Microseconds |
C++ | std::chrono |
std::chrono::steady_clock |
int64_t |
Microseconds2 |
Fetch repository, add #include <cronos.h>
to your sources, and modify your compiler's includes — with a Makefile, for example:
CFLAGS += -I/foo/cronos/src -g -Wall
CXXFLAGS += $(CFLAGS) -std=gnu++17
Fetch repository, copy src/cronos.h
into your project, add #include "cronos.h"
to your sources.
For bare-metal applications using platformio.ini
, add the following to lib_deps
for your environment:
[env]
lib_deps =
https://github.com/ardnew/cronos.git#v0.2.1
For library project using library.json
, add the following to "dependencies":
{
"dependencies": {
"ardnew/cronos": "^0.2.1"
}
}
This library conforms to the Arduino Library Specification (1.5). Install using the Library Manager via IDE (or GUI) or with command arduino-cli lib install cronos
using the CLI.
- Add support files required to implement an ESP-IDF library/component.
Footnotes
-
Not a typo; an empathetic nod to Jesús Gris. ↩
-
Actual resolution may be less. The LSBs of the 64-bit system tick count will be padded with
0
if the system does not support microsecond resolution. ↩