-
Notifications
You must be signed in to change notification settings - Fork 64
/
seesaw_servo.h
66 lines (56 loc) · 1.89 KB
/
seesaw_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 _SEESAW_SERVO_H
#define _SEESAW_SERVO_H
#include "Adafruit_seesaw.h"
/**************************************************************************/
/*!
@brief Class that stores state and functions for seesaw servo interface
*/
/**************************************************************************/
class seesaw_Servo {
public:
/**************************************************************************/
/*!
@brief class constructor
@param ss the seesaw object to use
*/
/**************************************************************************/
seesaw_Servo(Adafruit_seesaw *ss) {
_ss = ss;
_attached = false;
}
~seesaw_Servo() {}
bool begin(uint8_t addr = SEESAW_ADDRESS, int8_t flow = -1);
uint8_t attach(int pin);
uint8_t attach(int pin, int min, int max);
/**************************************************************************/
/*!
@brief set attached to false
*/
/**************************************************************************/
void detach() { _attached = false; }
void write(int value);
void writeMicroseconds(int value);
int read();
/**************************************************************************/
/*!
@brief get current value in microseconds
@returns current pulse width in microseconds for this servo
*/
/**************************************************************************/
int readMicroseconds() { return _sval / 3.2768; }
/**************************************************************************/
/*!
@brief check if the servo is attached yet
@returns true if this servo is attached, otherwise false
*/
/**************************************************************************/
bool attached() { return _attached; }
private:
Adafruit_seesaw *_ss;
bool _attached;
uint16_t _sval;
uint8_t _pin;
uint16_t min;
uint16_t max;
};
#endif