I2Cwrapper v0.5.0
Generic framework for Arduino I2C target devices
ServoI2C Class Reference

An I2C wrapper class for the Arduino Servo library. More...

Detailed Description

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 target running the I2Cwrapper firmware.ino with the ServoI2C module enabled. 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 controller's side.

Public Member Functions

 ServoI2C (I2Cwrapper *w)
 Constructor. More...
 
uint8_t attach (int pin)
 Attach and prepare servo for use. Similar to the original, but see below. More...
 
uint8_t attach (int pin, int min, int max)
 
void detach ()
 
void write (int value)
 
void writeMicroseconds (int value)
 
int read ()
 
int readMicroseconds ()
 
bool attached ()
 

Public Attributes

int8_t myNum = -1
 Servo number with myNum >= 0 for successfully added servo. More...
 

Constructor & Destructor Documentation

◆ ServoI2C()

ServoI2C::ServoI2C ( I2Cwrapper w)

Constructor.

Parameters
wWrapper object representing the target the servo is connected to.

Member Function Documentation

◆ attach() [1/2]

uint8_t ServoI2C::attach ( int  pin)

Attach and prepare servo for use. Similar to the original, but see below.

Parameters
pinHardware pin of the target 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 controller without resetting the target. Check for myNum != 255 to see if the target successfully added the servo.
Note
The target's platform pin names like "D3" or "A1" might not be known to the controller'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()

int ServoI2C::read ( )

◆ readMicroseconds()

int ServoI2C::readMicroseconds ( )

◆ write()

void ServoI2C::write ( int  value)

◆ writeMicroseconds()

void ServoI2C::writeMicroseconds ( int  value)

Member Data Documentation

◆ 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: