AccelStepperI2C  v 0.1
I2C wrapper (and a bit more) for the AccelStepper Arduino library
ServoI2C.h
Go to the documentation of this file.
1 
20 #ifndef ServoI2C_h
21 #define ServoI2C_h
22 
23 #define DEBUG // uncomment for debug output to Serial (which has to be begun() in the main sketch)
24 
25 #include <Arduino.h>
26 #include <I2Cwrapper.h>
27 #include <SimpleBuffer.h>
28 
29 #ifdef DEBUG
30 #define log(...) Serial.print(__VA_ARGS__)
31 #else
32 #define log(...)
33 #endif // DEBUG
34 
35 const uint8_t ServoI2CmaxBuf = 20; // upper limit of send and receive buffer(s)
36 
37 // Servo commands
38 const uint8_t servoAttach1Cmd = 60; const uint8_t servoAttachResult = 1; // 1 uint8_t
39 const uint8_t servoAttach2Cmd = 61; // uses servoAttachResult as well.
40 const uint8_t servoDetachCmd = 62;
41 const uint8_t servoWriteCmd = 63;
42 const uint8_t servoWriteMicrosecondsCmd = 64;
43 const uint8_t servoReadCmd = 65; const uint8_t servoReadResult = 2; // 1 int
44 const uint8_t servoReadMicrosecondsCmd = 66; const uint8_t servoReadMicrosecondsResult = 2; // 1 int
45 const uint8_t servoAttachedCmd = 67; const uint8_t servoAttachedResult = 1; // 1 bool
46 
47 
65 class ServoI2C
66 {
67 public:
72  ServoI2C(I2Cwrapper* w);
73 
87  uint8_t attach(int pin);
88  uint8_t attach(int pin, int min, int max);
89  void detach();
90  void write(int value);
91  void writeMicroseconds(int value);
92  int read();
93  int readMicroseconds();
94  bool attached();
95 
96  int8_t myNum = -1;
97 
98 private:
99  I2Cwrapper* wrapper;
100 
101 };
102 
103 
104 #endif
ServoI2C::read
int read()
Definition: ServoI2C.cpp:67
servoWriteMicrosecondsCmd
const uint8_t servoWriteMicrosecondsCmd
Definition: ServoI2C.h:42
I2Cwrapper
A helper class for the AccelStepperI2C (and ServoI2C) library.
Definition: I2Cwrapper.h:79
ServoI2C::attached
bool attached()
Definition: ServoI2C.cpp:87
ServoI2C::myNum
int8_t myNum
Servo number with myNum >= 0 for successfully added servo.
Definition: ServoI2C.h:96
ServoI2CmaxBuf
const uint8_t ServoI2CmaxBuf
Definition: ServoI2C.h:35
servoDetachCmd
const uint8_t servoDetachCmd
Definition: ServoI2C.h:40
ServoI2C::writeMicroseconds
void writeMicroseconds(int value)
Definition: ServoI2C.cpp:60
ServoI2C::write
void write(int value)
Definition: ServoI2C.cpp:53
servoReadMicrosecondsResult
const uint8_t servoReadMicrosecondsResult
Definition: ServoI2C.h:44
servoReadMicrosecondsCmd
const uint8_t servoReadMicrosecondsCmd
Definition: ServoI2C.h:44
servoAttachResult
const uint8_t servoAttachResult
Definition: ServoI2C.h:38
servoReadCmd
const uint8_t servoReadCmd
Definition: ServoI2C.h:43
ServoI2C
An I2C wrapper class for the Arduino Servo library.
Definition: ServoI2C.h:65
servoAttach2Cmd
const uint8_t servoAttach2Cmd
Definition: ServoI2C.h:39
ServoI2C::ServoI2C
ServoI2C(I2Cwrapper *w)
Constructor.
Definition: ServoI2C.cpp:18
I2Cwrapper.h
A helper class for the AccelStepperI2C (and ServoI2C) library.
ServoI2C::readMicroseconds
int readMicroseconds()
Definition: ServoI2C.cpp:77
ServoI2C::attach
uint8_t attach(int pin)
Attach and prepare servo for use. Similar to the original, but see below.
Definition: ServoI2C.cpp:24
servoReadResult
const uint8_t servoReadResult
Definition: ServoI2C.h:43
SimpleBuffer.h
Simple and ugly serialization buffer for any data type. Template technique and CRC8 adapted from Nick...
servoAttachedResult
const uint8_t servoAttachedResult
Definition: ServoI2C.h:45
servoAttachedCmd
const uint8_t servoAttachedCmd
Definition: ServoI2C.h:45
servoAttach1Cmd
const uint8_t servoAttach1Cmd
Definition: ServoI2C.h:38
ServoI2C::detach
void detach()
Definition: ServoI2C.cpp:47
servoWriteCmd
const uint8_t servoWriteCmd
Definition: ServoI2C.h:41