GY-63_MS5611/libraries/timing
2021-05-28 13:47:03 +02:00
..
.github/workflows add arduino-lint 2021-05-28 13:17:38 +02:00
examples 0.2.2 timing 2021-05-28 13:47:03 +02:00
test 2021-01-29 2021-01-29 12:31:58 +01:00
.arduino-ci.yml 2021-01-29 2021-01-29 12:31:58 +01:00
keywords.txt 2021-01-29 2021-01-29 12:31:58 +01:00
library.json 0.2.2 timing 2021-05-28 13:47:03 +02:00
library.properties 0.2.2 timing 2021-05-28 13:47:03 +02:00
LICENSE 2021-01-29 2021-01-29 12:31:58 +01:00
README.md 2021-01-29 2021-01-29 12:31:58 +01:00
timing.h 0.2.2 timing 2021-05-28 13:47:03 +02:00

Arduino CI License: MIT GitHub release

Timing

Arduino library with wrappers for seconds millis micros

Description

A request often made on the Arduino forum and otherwise is an option to reset the millis() function to 0 or another value. This library provide wrapper classes around millis() and micros() with the extra function to do this. To implement this only a 4 byte offset is needed.

These classes make it easy to make a simple stopwatch.

Interface

The library has 3 classes that are very similar.

  • microSeconds
  • milliSeconds
  • seconds (wrapper around millis() too)

The interface of all three are very similar, so only one is described

  • milliSeconds() constructor, sets the offset so it starts at 0.
  • now() returs the time elapsed since its 'zero moment', either construction or by a set(0).
  • set(value) sets the offset of the object. As it is possible to set it to a non zero value it is easy to adjust the time.
  • uint32_t getOffset() returns current offset.

The classes are based upon millis() and micros() therefor have the same restrictions as these functions with respect to overflow and accuracy. Depending on e.g. interrupts millis and micros can drift.

class overflow after
seconds 49 days, 17:02:47.297
milliSeconds 49 days, 17:02:47.297
microSeconds 00 days 01:11:34.967296

Future

idea to give it a clock print layout

  • seconds.toClock() -> DD 12:34:56

  • milliSeconds.toClock(3) -> 12:23:45.123

  • milliSeconds.toClock(1) -> 12:23:45.1

  • microSeconds.toCLock() -> 12:23:45.123456 ???

  • rounding effect, describe

Operation

See examples

Todo

  • test on ESP32