Fork of original Pulse libary from NickRyder.
Revision 1:4b723dd0881e, committed 2022-01-24
- Comitter:
- pmic
- Date:
- Mon Jan 24 10:11:33 2022 +0000
- Parent:
- 0:fb79a4637a64
- Commit message:
- Replaced read_us() with proper std::chrono::duration_cast.
Changed in this revision
| Pulse.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Pulse.cpp Wed Jul 04 15:56:06 2012 +0000
+++ b/Pulse.cpp Mon Jan 24 10:11:33 2022 +0000
@@ -53,7 +53,7 @@
while (io == 1) {
}
pulsetime.stop();
- return pulsetime.read_us();
+ return std::chrono::duration_cast<std::chrono::microseconds>(pulsetime.elapsed_time()).count();
}
int PulseInOut::read_high_us(int timeout) {
@@ -62,17 +62,17 @@
pulsetime.reset();
io.input();
while (io == 1) {
- if (runtime.read_us() > timeout) return -1;
+ if (std::chrono::duration_cast<std::chrono::microseconds>(runtime.elapsed_time()).count() > timeout) return -1;
}
while (io == 0) {
- if (runtime.read_us() > timeout) return -1;
+ if (std::chrono::duration_cast<std::chrono::microseconds>(runtime.elapsed_time()).count() > timeout) return -1;
}
pulsetime.start();
while (io == 1) {
- if (runtime.read_us() > timeout) return -1;
+ if (std::chrono::duration_cast<std::chrono::microseconds>(runtime.elapsed_time()).count() > timeout) return -1;
}
pulsetime.stop();
- return pulsetime.read_us();
+ return std::chrono::duration_cast<std::chrono::microseconds>(pulsetime.elapsed_time()).count();
}
int PulseInOut::read_low_us() {
@@ -86,7 +86,7 @@
while (io == 0) {
}
pulsetime.stop();
- return pulsetime.read_us();
+ return std::chrono::duration_cast<std::chrono::microseconds>(pulsetime.elapsed_time()).count();
}
int PulseInOut::read_low_us(int timeout) {
@@ -95,17 +95,17 @@
pulsetime.reset();
io.input();
while (io == 0) {
- if (runtime.read_us() > timeout) return -1;
+ if (std::chrono::duration_cast<std::chrono::microseconds>(runtime.elapsed_time()).count() > timeout) return -1;
}
while (io == 1) {
- if (runtime.read_us() > timeout) return -1;
+ if (std::chrono::duration_cast<std::chrono::microseconds>(runtime.elapsed_time()).count() > timeout) return -1;
}
pulsetime.start();
while (io == 0) {
- if (runtime.read_us() > timeout) return -1;
+ if (std::chrono::duration_cast<std::chrono::microseconds>(runtime.elapsed_time()).count() > timeout) return -1;
}
pulsetime.stop();
- return pulsetime.read_us();
+ return std::chrono::duration_cast<std::chrono::microseconds>(pulsetime.elapsed_time()).count();
}
int PulseInOut::read_us() {
@@ -118,7 +118,7 @@
while (io != startval) {
}
pulsetime.stop();
- return pulsetime.read_us();
+ return std::chrono::duration_cast<std::chrono::microseconds>(pulsetime.elapsed_time()).count();
}
int PulseInOut::read_us(int timeout) {
@@ -128,12 +128,12 @@
io.input();
startval = io;
while (io == startval) {
- if (runtime.read_us() > timeout) return -1;
+ if (std::chrono::duration_cast<std::chrono::microseconds>(runtime.elapsed_time()).count() > timeout) return -1;
}
pulsetime.start();
while (io != startval) {
- if (runtime.read_us() > timeout) return -1;
+ if (std::chrono::duration_cast<std::chrono::microseconds>(runtime.elapsed_time()).count() > timeout) return -1;
}
pulsetime.stop();
- return pulsetime.read_us();
+ return std::chrono::duration_cast<std::chrono::microseconds>(pulsetime.elapsed_time()).count();
}
\ No newline at end of file