forked from k-ross/indi-wmh-focuser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmraamotor.cpp
45 lines (38 loc) · 1.02 KB
/
mraamotor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "mraamotor.h"
MraaMotor::MraaMotor(int enablePin, int directionPin, int stepPin)
{
_enableLine = std::make_unique<mraa::Gpio>(enablePin);
_directionLine = std::make_unique<mraa::Gpio>(directionPin);
_stepLine = std::make_unique<mraa::Gpio>(stepPin);
_enableLine->dir(mraa::DIR_OUT);
_directionLine->dir(mraa::DIR_OUT);
_stepLine->dir(mraa::DIR_OUT);
}
MraaMotor::~MraaMotor()
{
}
void MraaMotor::Enable(Direction dir)
{
if (_revision == BoardRevision::Rev21)
_enableLine->write (1);
else
_enableLine->write (0);
if (dir == Direction::Forward)
_directionLine->write (0);
else
_directionLine->write (1);
}
void MraaMotor::Disable()
{
if (_revision == BoardRevision::Rev21)
_enableLine->write (0);
else
_enableLine->write (1);
}
void MraaMotor::SingleStep(int stepDelayMicroseconds)
{
_stepLine->write (1);
_Delay (stepDelayMicroseconds);
_stepLine->write (0);
_Delay (stepDelayMicroseconds);
}