-
Notifications
You must be signed in to change notification settings - Fork 1
/
MrlServo.h
44 lines (39 loc) · 1.08 KB
/
MrlServo.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
#ifndef MrlServo_h
#define MrlServo_h
// servo event types
// ===== published sub-types based on device type begin ===
#define SERVO_EVENT_STOPPED 1
#define SERVO_EVENT_POSITION_UPDATE 2
// ===== published sub-types based on device type begin ===
/**
* Servo Device
*/
class MrlServo : public Device {
private:
Servo* servo; // servo pointer - in case our device is a servo
int pin;
bool isMoving;
bool isSweeping;
int targetPos;
float currentPos;
int min;
int max;
unsigned long lastUpdate;
int velocity; // in deg/sec | velocity < 0 == no speed control
int sweepStep;
unsigned int maxVelocity;
public:
MrlServo(int deviceId);
~MrlServo();
bool attach(byte pin, byte initPos, int initVelocity);
void enablePwm(int pin);
void disablePwm();
void update();
void servoWrite(int position);
void servoWriteMicroseconds(int position);
void startSweep(int min, int max, int step);
void stopSweep();
void setMaxVelocity(unsigned int velocity);
void setVelocity(unsigned int velocity);
};
#endif