Browse Source

Added Lohmann's JSON lib

feature/program_options
Maximilian Stiefel 4 years ago
parent
commit
8ee7ff1c25
  1. 27
      hal/stepper.cpp
  2. 17
      include/stepper.h
  3. 25855
      lib/json.hpp
  4. 9
      main.cpp

27
hal/stepper.cpp

@ -1,11 +1,30 @@
#include<include/stepper.h> #include<include/stepper.h>
#include <thread>
#include <functional>
namespace simon { namespace simon {
namespace stepper { namespace stepper {
c_stepper::c_stepper(const settings_t* const stepper_set, c_stepper::c_stepper(const std::string& axis)
a4988::a4988_settings_t* a4988_set) : m_a4988(&m_a4988_set)
: m_set(stepper_set), m_a4988(a4988_set) /* : m_a4988
{
.gpio_en = 17,
.gpio_step = 18,
.gpio_dir = 22,
.gpio_microsteps{
true, true, true
},
m_stepper
{
.gear_reduction = 64.0f,
.steps_per_revolution = 32.0f
}
*/
{ {
std::thread t1(std::bind(&a4988::c_allegro_4988::run, &m_a4988));
m_a4988.post_move(32768, true, 100);
m_a4988.kill();
t1.join();
} }
} }
} }

17
include/stepper.h

@ -7,18 +7,25 @@ namespace simon {
namespace stepper { namespace stepper {
typedef struct { typedef struct {
const float gear_reduction; float gear_reduction;
const float steps_per_revolution; float steps_per_revolution;
} settings_t; } settings_t;
class c_stepper class c_stepper
{ {
public: public:
c_stepper(const settings_t* const stepper_set, c_stepper(const std::string& axis);
a4988::a4988_settings_t* a4988_set);
private: private:
const settings_t* const m_set; settings_t m_stepper;
a4988::c_allegro_4988 m_a4988; a4988::c_allegro_4988 m_a4988;
a4988::a4988_settings_t m_a4988_set = {
.gpio_en = 17,
.gpio_step = 18,
.gpio_dir = 22,
.gpio_microsteps{
true, true, true
}
};
}; };
} // namespace stepper } // namespace stepper

25855
lib/json.hpp

File diff suppressed because it is too large

9
main.cpp

@ -1,14 +1,10 @@
#include <iostream> #include <iostream>
#include <include/a4988.h>
#include <include/stepper.h> #include <include/stepper.h>
#include <thread>
#include <functional>
#include <memory>
int main() int main()
{ {
using namespace simon; using namespace simon;
a4988::a4988_settings_t a4988_set{ /* a4988::a4988_settings_t a4988_set{
.gpio_en = 17, .gpio_en = 17,
.gpio_step = 18, .gpio_step = 18,
.gpio_dir = 22, .gpio_dir = 22,
@ -20,14 +16,13 @@ int main()
.gear_reduction = 64.0f, .gear_reduction = 64.0f,
.steps_per_revolution = 32.0f .steps_per_revolution = 32.0f
}; };
/*
c_allegro_4988 a4988(&a4988_set); c_allegro_4988 a4988(&a4988_set);
std::thread t1(std::bind(&c_allegro_4988::run, &a4988)); std::thread t1(std::bind(&c_allegro_4988::run, &a4988));
a4988.post_move(32768, true, 100); a4988.post_move(32768, true, 100);
a4988.kill(); a4988.kill();
t1.join(); t1.join();
*/ */
stepper::c_stepper(&stepper_set, &a4988_set); stepper::c_stepper("azimuth");
std::cout << "Hello camera" << std::endl; std::cout << "Hello camera" << std::endl;
return 0; return 0;
} }

Loading…
Cancel
Save