-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathServo.h
66 lines (57 loc) · 1.61 KB
/
Servo.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
60
61
62
63
64
65
66
#ifndef _ServoClass_H
#define _ServoClass_H
#include <time.h>
class EZB;
class ServoClass{
public:
enum ServoPortEnum{
D0 = 0,
D1 = 1,
D2 = 2,
D3 = 3,
D4 = 4,
D5 = 5,
D6 = 6,
D7 = 7,
D8 = 8,
D9 = 9,
D10 = 10,
D11 = 11,
D12 = 12,
D13 = 13,
D14 = 14,
D15 = 15,
D16 = 16,
D17 = 17,
D18 = 18,
D19 = 19,
NA = 20,
};
typedef struct{
unsigned long last_move_time;
char curr_pos;
char curr_speed;
bool isreleased;
}servo_info;
static const unsigned char SERVO_CENTER = 70;
static const unsigned char SERVO_MAX = 140;
static const unsigned char SERVO_MIN = 1;
static const unsigned char SERVO_OFF = 0;
static const unsigned char SERVO_SPEED_FASTEST = 0;
static const unsigned char SERVO_SPEED_SLOWEST = 10;
ServoClass(EZB* ezb);
double GetNumberOfSecondsSinceLastMove(ServoPortEnum servoPort);
int GetServoPosition(ServoPortEnum servoPort);
int GetServoSpeed(ServoPortEnum servoPort);
bool IsServoReleased(ServoPortEnum servoPort);
void SetServoPosition(ServoPortEnum servoPort, int position, int speed=-1);
void SetServoPositionScalar(ServoPortEnum servoPort, int servoMin, int servoMax, int clientWidthMin, int clientWidthMax, int clientPosition, bool invert);
void SetServoPositionScalar(ServoPortEnum servoPort, int servoMin, int servoMax, float clientWidthMin, float clientWidthMax, float clientPosition, bool invert);
void SetServoSpeed(ServoPortEnum servoPort, int speed);
void ReleaseServo(ServoPortEnum servoPort);
void ReleaseAllServos();
private:
EZB* m_ezb;
servo_info m_servos[NA];
};
#endif