mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
51 lines
1001 B
C++
51 lines
1001 B
C++
//
|
|
// FILE: stopwatch_resolution.ino
|
|
// AUTHOR: Rob Tillaart
|
|
// VERSION: 0.1.1
|
|
// PURPOSE: sample demo stopwatch class
|
|
// DATE: 2020-05-08
|
|
// URL: https://github.com/RobTillaart/StopWatch_RT
|
|
//
|
|
|
|
#include <StopWatch.h>
|
|
|
|
StopWatch MySW;
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(115200);
|
|
Serial.println(__FILE__);
|
|
Serial.println(STOPWATCH_LIB_VERSION);
|
|
|
|
MySW.start();
|
|
delay(5000);
|
|
Serial.print("TIME: ");
|
|
Serial.println(MySW.elapsed());
|
|
Serial.print(" RES: ");
|
|
Serial.println(MySW.resolution());
|
|
Serial.println();
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
simple_test(StopWatch::MICROS);
|
|
simple_test(StopWatch::MILLIS);
|
|
simple_test(StopWatch::SECONDS);
|
|
simple_test(StopWatch::MINUTES);
|
|
}
|
|
|
|
|
|
void simple_test(StopWatch::Resolution res)
|
|
{
|
|
MySW.setResolution(res); // note: includes an automatic reset()
|
|
MySW.start();
|
|
delay(2500);
|
|
Serial.print("TIME: ");
|
|
Serial.println(MySW.elapsed());
|
|
Serial.print(" RES: ");
|
|
Serial.println(MySW.resolution());
|
|
Serial.println();
|
|
}
|
|
|
|
// -- END OF FILE --
|