Skip to content

ardnew/cronos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cronos1

A std::chrono wrapper for target system's native tick count

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.

Usage

This library is provided as a single C++17 header file.

See the example for general usage and notes until proper documentation is written.

Targets

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

Integration

ManualA

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
ManualB

Fetch repository, copy src/cronos.h into your project, add #include "cronos.h" to your sources.

PlatformIO

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"
  }
}
Arduino

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.

ESP-IDF TODO
  • Add support files required to implement an ESP-IDF library/component.

Footnotes

  1. Not a typo; an empathetic nod to Jesús Gris.

  2. 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.