From ad9bf20fee855b819f99171e116d7889d8f85754 Mon Sep 17 00:00:00 2001 From: marwik15 Date: Sat, 7 May 2022 17:19:06 +0200 Subject: Simplify code structure --- examples/sinewave/sinewave_example.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/sinewave/sinewave_example.cpp b/examples/sinewave/sinewave_example.cpp index b76639c..2f7c47e 100644 --- a/examples/sinewave/sinewave_example.cpp +++ b/examples/sinewave/sinewave_example.cpp @@ -9,13 +9,16 @@ #include +using seconds = std::chrono::duration; using Clock = std::chrono::high_resolution_clock; int main(int argc, char* argv[]) { - std::chrono::milliseconds interval{ 10 }; - int samples, opt, i = 1; + seconds interval{ 10.0 }; bool end = false; + int i = 1; + int samples; + int opt; const std::function infinite = []() {}; const std::function limited = [&end, &i, &samples]() { @@ -29,7 +32,7 @@ int main(int argc, char* argv[]) { while ((opt = getopt(argc, argv, "n:i:")) != -1) { switch (opt) { case 'i': - interval = std::chrono::milliseconds(std::stoi(optarg)); + interval = seconds{ std::stod(optarg) }; break; case 'n': samples = std::stoi(optarg); -- cgit v1.1