36 lines
804 B
C++
36 lines
804 B
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include "shiftregister.h"
|
|
|
|
class Motor {
|
|
public:
|
|
enum Direction : byte{
|
|
None,
|
|
Left,
|
|
Right
|
|
};
|
|
|
|
Motor(ShiftRegister* shiftRegister, uint8_t pwmPin, uint8_t dirPinA, uint8_t dirPinB);
|
|
Motor(uint8_t pwmPin, uint8_t dirPinA, uint8_t dirPinB);
|
|
|
|
void stop();
|
|
virtual bool start();
|
|
|
|
void setDirection(Direction direction) { this->direction = direction; };
|
|
void setSpeed(uint8_t speed) { this->speed = speed; }
|
|
|
|
protected:
|
|
Direction direction = Direction::None;
|
|
void configureMotor();
|
|
|
|
private:
|
|
ShiftRegister* shiftRegister = nullptr;
|
|
|
|
|
|
uint8_t pwmPin;
|
|
uint8_t dirPinA;
|
|
uint8_t dirPinB;
|
|
uint8_t speed = 0;
|
|
}; |