[ion] add missing ussleep function

This commit is contained in:
Damien Nicolet
2018-11-09 01:43:16 +01:00
parent 9b818bd963
commit 4640b67bc8
2 changed files with 16 additions and 0 deletions

View File

@@ -3,3 +3,6 @@
void Ion::mssleep(long ms) {
}
void Ion::ussleep(long us) {
}

View File

@@ -116,3 +116,16 @@ void Ion::mssleep(long ms) {
}
}
}
void Ion::ussleep(long us) {
auto start = std::chrono::high_resolution_clock::now();
while (true) {
sDisplay->redraw();
Fl::wait(0);
auto elapsed = std::chrono::high_resolution_clock::now() - start;
long long microseconds = std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count();
if (microseconds >= us) {
break;
}
}
}