upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Public Member Functions
adafruitss Class Reference

API for the Adafruit Servo Shield. More...

Detailed Description

UPM library for the PCA9685-based Adafruit 16-channel servo shield. If 3 or more GWS servos are attached, results could be unpredictable. Adafruit Industries recommend installing a capacitor on the board, which should alleviate the issue. Sizing depends on servos and their number.

adafruitss.jpg
upm::adafruitss* servos = new upm::adafruitss(6,0x40);
for (;;)
{
cout << "Setting all to 0" << endl;
for (n = 0; n < 16; n++)
servos->servo(n, 1, 0); // GWS Mini Servo = Type 1.
usleep(1000000); // Wait 1 second
cout << "Setting all to 45" << endl;
for (n = 0; n < 16; n++)
servos->servo(n, 1, 45);
usleep(1000000); // Wait 1 second
cout << "Setting all to 90" << endl;
for (n = 0; n < 16; n++)
servos->servo(n, 1, 90);
usleep(1000000); // Wait 1 second
cout << "Setting all to 135" << endl;
for (n = 0; n < 16; n++)
servos->servo(n, 1, 135);
usleep(1000000); // Wait 1 second
cout << "Setting all to 180" << endl;
for (n = 0; n < 16; n++)
servos->servo(n, 1, 160);
usleep(2000000); // Wait 1 second
}

Public Member Functions

 adafruitss (int bus, int i2c_address)
 
int update (void)
 
void setPWMFreq (float freq)
 
void servo (uint8_t port, uint8_t servo_type, float degrees)
 

Constructor & Destructor Documentation

adafruitss ( int  bus,
int  i2c_address 
)

Creates an adafruitss object

Parameters
busNumber of the used I2C bus
i2c_addressAddress of the servo shield on the I2C bus

Here is the call graph for this function:

Member Function Documentation

void setPWMFreq ( float  freq)

Sets the frequency of the servos

Parameters
freqFrequency at which the servos operate

Here is the caller graph for this function:

void servo ( uint8_t  port,
uint8_t  servo_type,
float  degrees 
)

Moves one of the servos to a specified angle

Parameters
portPort of the servo on the shield (servo number)
servo_typeCan be 0 = standard (1ms to 2ms), 1 = extended (0.6ms to 2.4ms), or 2 = extended (0.8ms to 2.2ms)
degreesAngle to set the servo to

The documentation for this class was generated from the following files: