An I2C wrapper class for the Arduino Servo library.
More...
An I2C wrapper class for the Arduino Servo library.
This class mimicks the original Servo interface. It replicates most of its methods and transmits each method call via I2C to a slave running the AccelStepperI2C firmware. Functions and parameters without documentation will work just as their original, but you need to take the general restrictions into account (e.g. don't take a return value for valid without error handling).
- Note
- Currently, the implementation is quite dumb, as it passes any Servo library call over I2C, regardless of what it does. Write() e.g. uses WriteMicroseconds(), so that in theory it could be implemented wholly on the master's side.
|
int8_t | myNum = -1 |
| Servo number with myNum >= 0 for successfully added servo. More...
|
|
◆ ServoI2C()
Constructor.
- Parameters
-
w | Wrapper object representing the slave the servo is connected to. |
◆ attach() [1/2]
uint8_t ServoI2C::attach |
( |
int |
pin | ) |
|
Attach and prepare servo for use. Similar to the original, but see below.
- Parameters
-
pin | Hardware pin of the slave the servo is atached to (see note). |
- Returns
- Returns myNum, which should be the same as the servo channel returned by the original Servo libraries, except if you reset your master without resetting the slave. Check for myNum != 255 to see if the slave successfully added the servo.
- Note
- The slave's platform pin names like "D3" or "A1" might not be known to the master's platform, if both platforms are different, or they might be used with a different pin number. So it is safer to use integer equivalents as defined in the respective platform's
pins_arduino.h
, see AccelStepperI2C::attach()
◆ attach() [2/2]
uint8_t ServoI2C::attach |
( |
int |
pin, |
|
|
int |
min, |
|
|
int |
max |
|
) |
| |
◆ attached()
bool ServoI2C::attached |
( |
| ) |
|
◆ detach()
void ServoI2C::detach |
( |
| ) |
|
◆ read()
◆ readMicroseconds()
int ServoI2C::readMicroseconds |
( |
| ) |
|
◆ write()
void ServoI2C::write |
( |
int |
value | ) |
|
◆ writeMicroseconds()
void ServoI2C::writeMicroseconds |
( |
int |
value | ) |
|
◆ myNum
int8_t ServoI2C::myNum = -1 |
Servo number with myNum >= 0 for successfully added servo.
The documentation for this class was generated from the following files: