#pragma once #include "Gpio.h" #include "Pwm.h" #include #include #include #include "scanservices_utils.h" #include "utilsfunc.h" #include #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 m_mtconfig; SMBType smbtype; public: void start(std::vector &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 speedup_cfg(int finalPeriod, int Fmin, int stepnum, int a, int offset, int finalDelay);