upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Classes | Public Member Functions | List of all members

API for the PCA9685 16-channel, 12-bit PWM LED Controller. More...

Detailed Description

This controller is also used on the Adafruit* Motor Shield v2.3 board to control up to 4 DC motors, 2 stepper motors, and 2 servo motors.

This module was tested with the Adafruit Motor Shield v2.3

pca9685.jpg

Classes

class  PCA9685_MODE1_T
 
class  PCA9685_MODE2_T
 
class  PCA9685_REG_T
 

Public Member Functions

synchronized void delete ()
 
 PCA9685 (int bus, short address, boolean raw)
 
 PCA9685 (int bus, short address)
 
 PCA9685 (int bus)
 
boolean writeByte (short reg, short arg1)
 
boolean writeWord (short reg, int word)
 
short readByte (short reg)
 
int readWord (short reg)
 
boolean setModeSleep (boolean sleep)
 
boolean ledFullOn (short led, boolean val)
 
boolean ledFullOff (short led, boolean val)
 
boolean ledOnTime (short led, int time)
 
boolean ledOffTime (short led, int time)
 
boolean setPrescale (short prescale)
 
boolean setPrescaleFromHz (float hz, float oscFreq)
 
boolean setPrescaleFromHz (float hz)
 
void enableRestart (boolean enabled)
 

Constructor & Destructor Documentation

PCA9685 ( int  bus,
short  address,
boolean  raw 
)

PCA9685 constructor

Parameters
busI2C bus to use
addressAddress for this device

Member Function Documentation

void enableRestart ( boolean  enabled)

Enables or disables the restart capability of the controller

Parameters
enabledTrue to enable, false to disable It is enabled by default.
boolean ledFullOff ( short  led,
boolean  val 
)

Sets or clears the FULL OFF bit for a given LED. If the FULL ON bit is also set, FULL OFF has precedence.

Parameters
ledLED number; valid values are 0-15, PCA9685_ALL_LED
valTrue to set the bit, false to clear it
Returns
True if successful
boolean ledFullOn ( short  led,
boolean  val 
)

Sets or clears the FULL ON bit for a given LED

Parameters
ledLED number; valid values are 0-15, PCA9685_ALL_LED
valTrue to set the bit, false to clear it
Returns
True if successful
boolean ledOffTime ( short  led,
int  time 
)

Sets the 'LED off' time (0-4,095). See the PCA9685 datasheet for details.

Parameters
ledLED number; valid values are 0-15, PCA9685_ALL_LED
time12-bit value at which point the LED turns off
Returns
True if successful
boolean ledOnTime ( short  led,
int  time 
)

Sets the 'LED on' time (0-4,095). See the PCA9685 datasheet for details.

Parameters
ledLED number; valid values are 0-15, PCA9685_ALL_LED
time12-bit value at which point the LED turns on
Returns
True if successful
short readByte ( short  reg)

Reads a byte value from a register

Parameters
regRegister location to read from
Returns
Value in a specified register
int readWord ( short  reg)

Reads a word value from a register. Note: the device must have the auto-increment bit set in the MODE1 register to work.

Parameters
regRegister location to read from
Returns
Value in a specified register
boolean setModeSleep ( boolean  sleep)

Puts the device in or out of the sleep mode. The device is always in the sleep mode upon power-up.

Parameters
sleepTrue to put the device in the sleep mode, false to put out
Returns
True if successful
boolean setPrescale ( short  prescale)

Sets the prescale value. See the PCA9685 datasheet for details. The prescale can only be set when the device is in the sleep mode.

Parameters
prescalePrescale value
Returns
True if successful
boolean setPrescaleFromHz ( float  hz,
float  oscFreq 
)

Sets the prescale value based on a desired frequency in Hz. The prescale can only be set when the device is in the sleep mode.

Parameters
hzDesired frequency in Hz
oscFreqOscillator frequency; default is 25 MHz
Returns
True if successful
boolean writeByte ( short  reg,
short  arg1 
)

Writes a byte value into a register

Parameters
regRegister location to write into
byteByte to write
Returns
True if successful
boolean writeWord ( short  reg,
int  word 
)

Writes a word value into a register. Note: the device must have the auto-increment bit set in the MODE1 register to work.

Parameters
regRegister location to write into
wordWord to write
Returns
True if successful

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