diff options
author | Aki <please@ignore.pl> | 2022-06-06 18:39:50 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-06-06 18:39:50 +0200 |
commit | c6b1f4414617711798961a618601e959ca3777df (patch) | |
tree | c2809a96d36fc7932d700b01007ead5d82f620e0 /examples | |
parent | 34445feef027ba14cfa461b5efd2b11c41f8211e (diff) | |
download | hwd-c6b1f4414617711798961a618601e959ca3777df.zip hwd-c6b1f4414617711798961a618601e959ca3777df.tar.gz hwd-c6b1f4414617711798961a618601e959ca3777df.tar.bz2 |
Reformatted newly added code to be closer to convention
Diffstat (limited to 'examples')
-rw-r--r-- | examples/sinewave/sinewave_example.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/examples/sinewave/sinewave_example.cpp b/examples/sinewave/sinewave_example.cpp index 8b50804..afffc82 100644 --- a/examples/sinewave/sinewave_example.cpp +++ b/examples/sinewave/sinewave_example.cpp @@ -10,17 +10,22 @@ #include <hwd.h> -volatile sig_atomic_t keep_running{ 1 }; -void termination_handler(int signum){ +volatile sig_atomic_t keep_running {1}; + + +void termination_handler(int signum) +{ keep_running = false; } + using seconds = std::chrono::duration<double>; using Clock = std::chrono::high_resolution_clock; -int main(int argc, char* argv[]) { +int main(int argc, char* argv[]) +{ struct sigaction int_action; int_action.sa_handler = termination_handler; @@ -28,7 +33,6 @@ int main(int argc, char* argv[]) { int_action.sa_flags = 0; sigaction(SIGINT, &int_action, NULL); - seconds interval{ 0.01 }; int i = 0; int samples = 0; @@ -51,19 +55,14 @@ int main(int argc, char* argv[]) { } catch (const std::invalid_argument& ia) { std::cerr << "Invalid argument: " << ia.what() << std::endl; - return 1; } - while (keep_running) { if (i >= samples) break; i++; - const auto endTime = Clock::now() + interval; - std::cout << hwd::sinewave::get_point() << std::endl; - std::this_thread::sleep_until(endTime); } |