From 3493020ce91d38c8d84ea7b7487fab849e23be77 Mon Sep 17 00:00:00 2001 From: Maximilian Stiefel Date: Sat, 20 Feb 2021 23:56:09 +0100 Subject: [PATCH] Minor changes to wrap up stepper activities --- hal/stepper.cpp | 10 ++++++---- include/stepper.h | 2 +- main.cpp | 22 ++-------------------- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/hal/stepper.cpp b/hal/stepper.cpp index 536d9d6..57988ea 100644 --- a/hal/stepper.cpp +++ b/hal/stepper.cpp @@ -8,9 +8,9 @@ namespace simon { namespace stepper { - c_stepper::c_stepper(const std::string& axis) + c_stepper::c_stepper(const std::string& axis, const std::string& fname) { - auto file_content = read_file("settings.json"); + auto file_content = read_file(fname); auto j_set = json::parse(file_content); if (!j_set["axis_configurations"].is_array()) { std::cout << "Expected an array in the configuration below \"axis_configurations\"." << "\n"; @@ -18,8 +18,10 @@ namespace simon { } extract_settings(j_set, axis); m_thread = std::thread(std::bind(&a4988::c_allegro_4988::run, &(*m_ptr_a4988))); - rotate(180); - rotate(-180); + for (int i=0; i<10; i++) { + rotate(90); + rotate(-90); + } m_ptr_a4988->kill(); m_thread.join(); } diff --git a/include/stepper.h b/include/stepper.h index c627f2e..8d48264 100644 --- a/include/stepper.h +++ b/include/stepper.h @@ -19,7 +19,7 @@ namespace simon { class c_stepper { public: - c_stepper(const std::string& axis); + c_stepper(const std::string& axis, const std::string& fname); float rotate(const float& degrees); private: settings_t m_stepper; diff --git a/main.cpp b/main.cpp index 050802b..bdc7df7 100644 --- a/main.cpp +++ b/main.cpp @@ -4,25 +4,7 @@ int main() { using namespace simon; -/* a4988::a4988_settings_t a4988_set{ - .gpio_en = 17, - .gpio_step = 18, - .gpio_dir = 22, - .gpio_microsteps{ - true, true, true - } - }; - stepper::settings_t stepper_set{ - .gear_reduction = 64.0f, - .steps_per_revolution = 32.0f - }; - c_allegro_4988 a4988(&a4988_set); - std::thread t1(std::bind(&c_allegro_4988::run, &a4988)); - a4988.post_move(32768, true, 100); - a4988.kill(); - t1.join(); -*/ - stepper::c_stepper("azimuth"); - std::cout << "Hello camera" << std::endl; + stepper::c_stepper("azimuth", "settings.json"); + std::cout << "Hello camera :*" << std::endl; return 0; }