-
Notifications
You must be signed in to change notification settings - Fork 0
/
VisionStepper.h
46 lines (41 loc) · 1.33 KB
/
VisionStepper.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
#ifndef VisionStepper_h
#define VisionStepper_h
#include "Arduino.h"
#include <elapsedMillis.h>
class VisionStepper {
public:
void init();
void initPins(int enablePin, int directionPin, int stepPin);
void initDelays(int startSpeedDelay, int highPhaseDelay, int maxSpeedDelay);
void initSizes(float wheelDiameter, int wheelRevolutionSteps, float distanceBetweenWheels);
void initStepCmRatio(float stepCmRatio);
void doLoop();
void toggleDirection();
void setDirectionForward();
void setTargetDelay(int targetDelay);
boolean isOff();
boolean isAtTargetSpeed();
void doSteps(int stepNumber);
void doDistanceInCm(float distance);
void doRotationInAngle(float angle);
void emergencyStop();
void setMaxSpeed();
void pause();
void unpause();
private:
void doSetup();
private:
int enablePin, directionPin, stepPin;
int enablePinState, directionPinState, stepPinState;
int globalState;
unsigned long stepsMadeSoFar, stepsRemaining;
float maxSpeedDelay, startSpeedDelay, currentDelay, targetDelay, highPhaseDelay;
int stepSpeedCounter;
int old_state;
boolean foundTargetSpeed, raiseSpeed;
elapsedMicros stepTimer;
elapsedMillis stopTimer;
float stepCmRatio; // steps for a cm
float degreeStepRatio; //steps for a degree turn;
};
#endif