summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authormarwik15 <marwik15@gmail.com>2022-05-07 17:19:06 +0200
committermarwik15 <marwik15@gmail.com>2022-05-07 17:19:06 +0200
commitad9bf20fee855b819f99171e116d7889d8f85754 (patch)
tree328c00a1a5e4683802b82862ab27814c2bafc2f7 /examples
parentc4b39038ed566eddab1b1746af62000ab1c37c91 (diff)
downloadhwd-ad9bf20fee855b819f99171e116d7889d8f85754.zip
hwd-ad9bf20fee855b819f99171e116d7889d8f85754.tar.gz
hwd-ad9bf20fee855b819f99171e116d7889d8f85754.tar.bz2
Simplify code structure
Diffstat (limited to 'examples')
-rw-r--r--examples/sinewave/sinewave_example.cpp9
1 files changed, 6 insertions, 3 deletions
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 <hwd.h>
+using seconds = std::chrono::duration<double>;
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);