PWM based motor driver added from other project
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @file stepperDrv.hpp
|
||||
* @author Gustice
|
||||
* @brief Abstraction for Stepper driver
|
||||
*
|
||||
* @copyright Copyright (c) 2024
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "gpioPort.hpp"
|
||||
#include "pwmPort.hpp"
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
class StepperDriver {
|
||||
public:
|
||||
struct StepCplx {
|
||||
int8_t increment{};
|
||||
uint8_t subPos{};
|
||||
};
|
||||
|
||||
StepperDriver(int resolution)
|
||||
: Resolution(resolution), Quad(Resolution / 4) {}
|
||||
virtual StepCplx fullStep(int8_t cnt) = 0;
|
||||
virtual StepCplx step(int8_t cnt) = 0;
|
||||
virtual StepCplx setPos(uint8_t pos) = 0;
|
||||
uint8_t getSubPos() {
|
||||
return _position;
|
||||
}
|
||||
|
||||
protected:
|
||||
const uint8_t Resolution;
|
||||
const uint8_t Quad;
|
||||
int8_t _position{};
|
||||
virtual void setOutput(uint8_t pos) = 0;
|
||||
};
|
||||
Reference in New Issue
Block a user