|
|
|
#ifndef INCLUDED_HAL_STEPPER
|
|
|
|
#define INCLUDED_HAL_STEPPER
|
|
|
|
|
|
|
|
#include <a4988.h>
|
|
|
|
#include <json.hpp>
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
namespace simon {
|
|
|
|
namespace stepper {
|
|
|
|
|
|
|
|
using json = nlohmann::json;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float gear_reduction;
|
|
|
|
float steps_per_revolution;
|
|
|
|
bool clockwise;
|
|
|
|
} settings_t;
|
|
|
|
|
|
|
|
class c_stepper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
c_stepper(const std::string& axis, const std::string& fname);
|
|
|
|
~c_stepper();
|
|
|
|
float rotate(const float& degrees);
|
|
|
|
private:
|
|
|
|
settings_t m_stepper;
|
|
|
|
std::unique_ptr<a4988::c_allegro_4988> m_ptr_a4988;
|
|
|
|
std::thread m_driver_thread;
|
|
|
|
private:
|
|
|
|
std::string read_file(const std::string& fname) const;
|
|
|
|
void extract_settings(const json& j_set, const std::string& axis);
|
|
|
|
};
|
|
|
|
} // namespace stepper
|
|
|
|
} // namespace simon
|
|
|
|
|
|
|
|
#endif /*INCLUDED_HAL_STEPPER*/
|