Simon's and Max' camera steering software. https://stiefel.tech
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.6 KiB

4 years ago
#ifndef INCLUDED_DRIVER_ALLEGRO_4988
#define INCLUDED_DRIVER_ALLEGRO_4988
#define CFG_SAMPLE_RATE_US 5
#define CFG_PERIPHERAL_SRC_PCM 1
#define CFG_DEPRECATED_ARG 0
#include <queue>
#include <string>
#include <memory>
4 years ago
namespace simon {
namespace a4988 {
typedef struct
{
const unsigned gpio_en;
const unsigned gpio_step;
const unsigned gpio_dir;
const bool gpio_microsteps[3];
} a4988_settings_t;
4 years ago
class c_cmd
{
public:
explicit c_cmd(const std::string cmd) : m_cmd(cmd) {}
bool operator==(const std::string& vgl) {
return (vgl==m_cmd ? true : false);
}
virtual ~c_cmd(void) noexcept {}
private:
const std::string m_cmd;
};
4 years ago
class c_move : public c_cmd
{
public:
unsigned steps;
bool dir;
unsigned period_us;
explicit c_move(void) : c_cmd("move"){}
};
class c_enable : public c_cmd
{
public:
bool enabled;
explicit c_enable(void) : c_cmd("enable"){}
};
class c_allegro_4988
{
public:
c_allegro_4988(a4988_settings_t* set);
int enable(void);
int disable(void);
void post(std::shared_ptr<c_cmd> cmd);
void run(void);
private:
a4988_settings_t* m_pset;
bool m_initialized;
std::queue<std::shared_ptr<c_cmd>> m_queue;
unsigned m_pwm_freq;
bool m_alive;
private:
void initialize(void);
int set_pwm_freq(const unsigned pwm_freq);
};
} // namespace a4988
4 years ago
} // namespace simon
#endif /*INCLUDED_DRIVER_ALLEGRO_4988*/