Browse Source

Minor changes to wrap up stepper activities

feature/build_system
Maximilian Stiefel 3 years ago
parent
commit
230c7d3155
  1. 10
      hal/stepper.cpp
  2. 2
      include/stepper.h
  3. 22
      main.cpp

10
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();
}

2
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;

22
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;
}

Loading…
Cancel
Save