summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authormarwik15 <marwik15@gmail.com>2022-05-02 11:30:54 +0200
committermarwik15 <marwik15@gmail.com>2022-05-02 11:30:54 +0200
commitd417394ae791e9972fede0665587aa612f93bca0 (patch)
tree1087d58f9db079327b9f516157a31b6821b7997f /library
parentac5e26518a780f19483585cd6b5d62de9094c2b8 (diff)
downloadhwd-d417394ae791e9972fede0665587aa612f93bca0.zip
hwd-d417394ae791e9972fede0665587aa612f93bca0.tar.gz
hwd-d417394ae791e9972fede0665587aa612f93bca0.tar.bz2
Add sine wave generator
Diffstat (limited to 'library')
-rw-r--r--library/CMakeLists.txt1
-rw-r--r--library/include/hwd.h11
-rw-r--r--library/src/sinewave.cpp44
3 files changed, 56 insertions, 0 deletions
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<char> read(std::size_t len, std::size_t off);
bool write(const std::vector<char> 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>();
+ }
+
+ double get_frequency()
+ {
+ return get_client().call("sinewave/get_frequency").as<double>();
+ }
+
+ double get_phase()
+ {
+ return get_client().call("sinewave/get_phase").as<double>();
+ }
+
+ double get_point() {
+ return get_client().call("sinewave/get_point").as<double>();
+ }
+
+} // namespace sinewave
+} // namespace hwd