-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServoManager.h
More file actions
47 lines (32 loc) · 971 Bytes
/
Copy pathServoManager.h
File metadata and controls
47 lines (32 loc) · 971 Bytes
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
#pragma once
#include <Arduino.h>
#include <Servo.h>
#include "TimeManager.h"
struct ServoMotor{
public:
ServoMotor(uint8_t pin);
///1.0 degree per second.
void setMaxSpeed(float maxSpeed);
void setAcceleration(float accel);
void moveTo(int loc);
void setCurrentPosition(int newPos);
int distanceToGo();
int currentPosition();
void run();
private:
float maxSpeed, accel; // must always positive
float speed, floatPos; // Signed speed (can be positive or negative), floatPos stores the slowly (relative to delta time) increasing position
int pos, desiredPos; // Positions (signed integers)
Servo servo; // Servo object
uint8_t pin; // Servos pin
};
class ServoManager{
public:
virtual ~ServoManager();
static ServoManager* getInstance();
void run();
static ServoMotor* servos[];
private:
ServoManager();
static ServoManager* s_Instance;
};