-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_stopwatch.h
41 lines (33 loc) · 933 Bytes
/
simple_stopwatch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
================================================================================
DREAM core / Simple stopwatch module
--------------------------------------------------------------------------------
Simple module for calculating the time of execution of some functions based on
Arduino `millis()` function.
--------------------------------------------------------------------------------
Copyright © 2019-2022 Dmytro Obukhov (DeLy Dreamer)
License: https://www.gnu.org/licenses/gpl-3.0.html
================================================================================
*/
#pragma once
#include <Arduino.h>
namespace dream
{
class SimpleStopwatch
{
private:
unsigned long _start_time = millis();
public:
SimpleStopwatch() {}
// Start calculation
void start()
{
_start_time = millis();
}
// Get elapsed time
unsigned long getTime() const
{
return (millis() - _start_time);
}
};
}