Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: RWR_Utils.cpp
- Revision:
- 6:66889ef7193a
- Parent:
- 5:6cd52beadb7c
- Child:
- 8:7433f35f0338
diff -r 6cd52beadb7c -r 66889ef7193a RWR_Utils.cpp
--- a/RWR_Utils.cpp Sat Jul 24 14:46:20 2021 +0300
+++ b/RWR_Utils.cpp Sat Jul 24 22:30:13 2021 +0300
@@ -139,3 +139,26 @@
// return line position as a float between -1.0 (left) and 1.0 (right)
return returnValue;
}
+
+TimerWrapper::TimerWrapper(Timer &_timer):
+ timer(_timer),
+ lastReset(0)
+{
+ timer.start();
+ lastReset = timer.read_us();
+}
+
+int32_t TimerWrapper::read_ms()
+{
+ return (timer.read_us() - lastReset) / 1000;
+}
+
+int32_t TimerWrapper::read_us()
+{
+ return timer.read_us() - lastReset;
+}
+
+void TimerWrapper::reset()
+{
+ lastReset = timer.read_us();
+}