zynq_7010/zynq_7010_code/Motor.h

75 lines
1.2 KiB
C++

#pragma once
#include "Gpio.h"
#include "Pwm.h"
#include <vector>
#include <thread>
#include <iostream>
#include "scanservices_utils.h"
#include "utilsfunc.h"
#include <exception>
#include "Motordef.h"
#include "MotorConfig.h"
struct MotorPorts
{
int power;
int reset;
int sleep;
int enable;
int dir;
int decay;
int home;
int fault;
int mode0;
int mode1;
int mode2;
int pwm;
};
extern const MotorPorts motorPorts_Zouzhi;
extern const MotorPorts motorPorts_Cuozhi;
class Motor
{
public:
Motor(MotorPorts motorPorts);
virtual ~Motor();
protected:
//static GpioOut powerPin;
Gpio motor_power;
Gpio resetPin;
Gpio sleepPin;
Gpio enablePin;
Gpio dirPin;
Pwm pwm;
std::shared_ptr<MotorConfig> m_mtconfig;
SMBType smbtype;
public:
void start(std::vector<int> &delay_s, const MotorSpeedParam &msp);
virtual void start();
void stop();
void pause();
void setMode(int mode_input);
void setDirection(int dir);
void setSpeed(int value);
static void enablePower(bool bEnable);
static int isPowerOn()
{
return 0;//powerPin.getValue();
};
};
extern std::vector<int> speedup_cfg(int finalPeriod, int Fmin, int stepnum, int a, int offset, int finalDelay);