forked from clearwater/SwitecX25
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSwitecX25.h
executable file
·47 lines (39 loc) · 1.36 KB
/
SwitecX25.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
/*
* SwitecX25 Arduino Library
* Guy Carpenter, Clearwater Software - 2012
*
* Licensed under the BSD2 license, see license.txt for details.
*
* All text above must be included in any redistribution.
*/
#ifndef SwitecX25_h
#define SwitecX25_h
#include <Arduino.h>
class SwitecX25
{
public:
static const unsigned char pinCount = 4;
static const unsigned char stateCount = 6;
unsigned char pins[pinCount];
unsigned char currentState; // 6 steps
unsigned int currentStep; // step we are currently at
unsigned int targetStep; // target we are moving to
unsigned int steps; // total steps available
unsigned long time0; // time when we entered this state
unsigned int microDelay; // microsecs until next state
unsigned short (*accelTable)[2]; // accel table can be modified.
unsigned int maxVel; // fastest vel allowed
unsigned int vel; // steps travelled under acceleration
char dir; // direction -1,0,1
boolean stopped; // true if stopped
SwitecX25(unsigned int steps, unsigned char pin1, unsigned char pin2, unsigned char pin3, unsigned char pin4);
void stepUp();
void stepDown();
void zero();
void update();
void setPosition(unsigned int pos);
private:
void advance();
void writeIO();
};
#endif