5.9.1f * Upgrade library ArduinoJson to 5.11.2 * Upgrade library IRRemoteEsp8266 to 2.2.1 + 2 commits but tweaked some protocols to keep code usage small * Upgrade library NeoPixelBus to 2.2.9 * Upgrade library OneWire to 2.3.3 + 6 commits * Formalize library PubSubClient to 2.6 + 9 commits and additional delay * Add optional ADS1115 driver as alternative for unsupported I2Cdevlib in esp8266-core 2.4.0-rc2 * Fix wrong response name for command HlwISet (#1214)
34 lines
621 B
C++
34 lines
621 B
C++
// Copyright 2017 David Conran
|
|
|
|
#include "IRtimer.h"
|
|
#ifndef UNIT_TEST
|
|
#include <Arduino.h>
|
|
#endif
|
|
|
|
// This class performs a simple time in useconds since instantiated.
|
|
// Handles when the system timer wraps around (once).
|
|
|
|
IRtimer::IRtimer() {
|
|
reset();
|
|
}
|
|
|
|
void IRtimer::reset() {
|
|
#ifndef UNIT_TEST
|
|
start = micros();
|
|
#else
|
|
start = 0;
|
|
#endif
|
|
}
|
|
|
|
uint32_t IRtimer::elapsed() {
|
|
#ifndef UNIT_TEST
|
|
uint32_t now = micros();
|
|
#else
|
|
uint32_t now = 0;
|
|
#endif
|
|
if (start <= now) // Check if the system timer has wrapped.
|
|
return now - start; // No wrap.
|
|
else
|
|
return UINT32_MAX - start + now; // Has wrapped.
|
|
}
|