From d417394ae791e9972fede0665587aa612f93bca0 Mon Sep 17 00:00:00 2001 From: marwik15 Date: Mon, 2 May 2022 11:30:54 +0200 Subject: Add sine wave generator --- library/CMakeLists.txt | 1 + library/include/hwd.h | 11 +++++++++++ library/src/sinewave.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 library/src/sinewave.cpp (limited to 'library') diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 28ccbb1..a454186 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -3,6 +3,7 @@ add_library(${PROJECT_NAME} SHARED src/client.cpp src/gpio.cpp src/memory.cpp + src/sinewave.cpp ) target_link_libraries(${PROJECT_NAME} PUBLIC rpclib::rpc diff --git a/library/include/hwd.h b/library/include/hwd.h index fbd2fef..4ea75fa 100644 --- a/library/include/hwd.h +++ b/library/include/hwd.h @@ -20,4 +20,15 @@ std::vector read(std::size_t len, std::size_t off); bool write(const std::vector data, std::size_t off); } // namespace memory +namespace sinewave +{ + void set_amplitude(double); + void set_frequency(double); + void set_phase(double); + double get_amplitude(); + double get_frequency(); + double get_phase(); + double get_point(); +} // namespace sinewave + } // namespace hwd diff --git a/library/src/sinewave.cpp b/library/src/sinewave.cpp new file mode 100644 index 0000000..3a1d8ec --- /dev/null +++ b/library/src/sinewave.cpp @@ -0,0 +1,44 @@ +#include "hwd.h" + +#include "client.h" + +namespace hwd +{ +namespace sinewave +{ + void set_amplitude(double amplitude) + { + get_client().call("sinewave/set_amplitude", amplitude); + } + + void set_frequency(double frequency) + { + get_client().call("sinewave/set_frequency", frequency); + } + + void set_phase(double phase) + { + get_client().call("sinewave/set_phase", phase); + } + + double get_amplitude() + { + return get_client().call("sinewave/get_amplitude").as(); + } + + double get_frequency() + { + return get_client().call("sinewave/get_frequency").as(); + } + + double get_phase() + { + return get_client().call("sinewave/get_phase").as(); + } + + double get_point() { + return get_client().call("sinewave/get_point").as(); + } + +} // namespace sinewave +} // namespace hwd -- cgit v1.1