-
Notifications
You must be signed in to change notification settings - Fork 0
/
StepMotorControl.h
60 lines (44 loc) · 1014 Bytes
/
StepMotorControl.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// StepMotorControl.h
#ifndef _STEPMOTORCONTROL_h
#define _STEPMOTORCONTROL_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
class StepMotorControl
{
enum StepMotorStates
{
IDLE,
LEFT,
RIGHT,
AUTOMATIC_IDLE,
AUTOMATIC_LEFT,
AUTOMATIC_RIGHT
};
private:
byte motorId;
byte notEnabledPin;
byte stepPin;
byte directionPin;
unsigned int defaultInterval;
unsigned int interval;
unsigned long lastExecutionTime;
StepMotorStates currentState;
StepMotorStates lastState;
int currentSteps;
void step();
// Vom State abhängige Methoden
void idle_update(byte input);
void left_update(byte input);
void right_update(byte input);
void automatic_idle_update(byte input);
void automatic_left_update(byte input);
void automatic_right_update(byte input);
public:
void init(byte identifier, unsigned int defaultInterval);
void update(byte input);
void setMotorHeadPins(byte notEnabledPin, byte stepPin, byte directionPin);
};
#endif