Browse Source

Beginning of bigger refactoring process

feature/program_options
Maximilian Stiefel 4 years ago
parent
commit
5d0534df47
  1. 11
      hal/stepper.cpp
  2. 2
      include/a4988.h
  3. 27
      include/stepper.h
  4. 12
      main.cpp

11
hal/stepper.cpp

@ -0,0 +1,11 @@
#include<include/stepper.h>
namespace simon {
namespace stepper {
c_stepper::c_stepper(const settings_t* const stepper_set,
a4988::a4988_settings_t* a4988_set)
: m_set(stepper_set), m_a4988(a4988_set)
{
}
}
}

2
include/a4988.h

@ -60,7 +60,7 @@ namespace simon {
class c_allegro_4988 class c_allegro_4988
{ {
public: public:
c_allegro_4988(a4988_settings_t* set); explicit c_allegro_4988(a4988_settings_t* set);
int enable(void); int enable(void);
int disable(void); int disable(void);
void kill(void); void kill(void);

27
include/stepper.h

@ -0,0 +1,27 @@
#ifndef INCLUDED_HAL_STEPPER
#define INCLUDED_HAL_STEPPER
#include <include/a4988.h>
namespace simon {
namespace stepper {
typedef struct {
const float gear_reduction;
const float steps_per_revolution;
} settings_t;
class c_stepper
{
public:
c_stepper(const settings_t* const stepper_set,
a4988::a4988_settings_t* a4988_set);
private:
const settings_t* const m_set;
a4988::c_allegro_4988 m_a4988;
};
} // namespace stepper
} // namespace simon
#endif /*INCLUDED_HAL_STEPPER*/

12
main.cpp

@ -1,13 +1,14 @@
#include <iostream> #include <iostream>
#include <include/a4988.h> #include <include/a4988.h>
#include <include/stepper.h>
#include <thread> #include <thread>
#include <functional> #include <functional>
#include <memory> #include <memory>
int main() int main()
{ {
using namespace simon::a4988; using namespace simon;
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,
@ -15,11 +16,18 @@ int main()
true, true, true true, true, true
} }
}; };
stepper::settings_t stepper_set{
.gear_reduction = 64.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);
std::cout << "Hello camera" << std::endl; std::cout << "Hello camera" << std::endl;
return 0; return 0;
} }

Loading…
Cancel
Save