16-channel, 12-bit PWM Fm I2C-bus LED controller

Embed: (wiki syntax)

« Back to documentation index

PCA9685 Class Reference

PCA9685 Class Reference

Example: More...

#include <PCA9685.h>

Public Types

enum  PCA9685_address_t { PCA9685_ADDRESS_0 = ( 0x40 << 1 ) }
 

DEFAULT ADDRESSES.

More...
enum  PCA9685_registers_t {
  MODE1 = 0x00, MODE2 = 0x01, SUBADR1 = 0x02, SUBADR2 = 0x03,
  SUBADR3 = 0x04, ALLCALLADR = 0x05, LED0_ON_L = 0x06, LED0_ON_H = 0x07,
  LED0_OFF_L = 0x08, LED0_OFF_H = 0x09, LED1_ON_L = 0x0A, LED1_ON_H = 0x0B,
  LED1_OFF_L = 0x0C, LED1_OFF_H = 0x0D, LED2_ON_L = 0x0E, LED2_ON_H = 0x0F,
  LED2_OFF_L = 0x10, LED2_OFF_H = 0x11, LED3_ON_L = 0x12, LED3_ON_H = 0x13,
  LED3_OFF_L = 0x14, LED3_OFF_H = 0x15, LED4_ON_L = 0x16, LED4_ON_H = 0x17,
  LED4_OFF_L = 0x18, LED4_OFF_H = 0x19, LED5_ON_L = 0x1A, LED5_ON_H = 0x1B,
  LED5_OFF_L = 0x1C, LED5_OFF_H = 0x1D, LED6_ON_L = 0x1E, LED6_ON_H = 0x1F,
  LED6_OFF_L = 0x20, LED6_OFF_H = 0x21, LED7_ON_L = 0x22, LED7_ON_H = 0x23,
  LED7_OFF_L = 0x24, LED7_OFF_H = 0x25, LED8_ON_L = 0x26, LED8_ON_H = 0x27,
  LED8_OFF_L = 0x28, LED8_OFF_H = 0x29, LED9_ON_L = 0x2A, LED9_ON_H = 0x2B,
  LED9_OFF_L = 0x2C, LED9_OFF_H = 0x2D, LED10_ON_L = 0x2E, LED10_ON_H = 0x2F,
  LED10_OFF_L = 0x30, LED10_OFF_H = 0x31, LED11_ON_L = 0x32, LED11_ON_H = 0x33,
  LED11_OFF_L = 0x34, LED11_OFF_H = 0x35, LED12_ON_L = 0x36, LED12_ON_H = 0x37,
  LED12_OFF_L = 0x38, LED12_OFF_H = 0x39, LED13_ON_L = 0x3A, LED13_ON_H = 0x3B,
  LED13_OFF_L = 0x3C, LED13_OFF_H = 0x3D, LED14_ON_L = 0x3E, LED14_ON_H = 0x3F,
  LED14_OFF_L = 0x40, LED14_OFF_H = 0x41, LED15_ON_L = 0x42, LED15_ON_H = 0x43,
  LED15_OFF_L = 0x44, LED15_OFF_H = 0x45, ALL_LED_ON_L = 0xFA, ALL_LED_ON_H = 0xFB,
  ALL_LED_OFF_L = 0xFC, ALL_LED_OFF_H = 0xFD, PRE_SCALE = 0xFE, TESTMODE = 0xFF
}
 

REGISTER DEFINITIONS.

More...
enum  PCA9685_subaddresses_t { SUBADR1_REG = ( 0xE2 << 1 ), SUBADR2_REG = ( 0xE4 << 1 ), SUBADR3_REG = ( 0xE8 << 1 ) }
 

SUBADDRESS.

More...
enum  PCA9685_software_reset_t { GENERAL_CALL_ADDRESS = ( 0x00 << 1 ), SWRST = 0x06 }
 

SWRST.

More...
enum  PCA9685_mode1_restart_t { MODE1_RESTART_MASK = ( 1 << 7 ), MODE1_RESTART_ENABLED = ( 1 << 7 ), MODE1_RESTART_DISABLED = ( 0 << 7 ) }
 

RESTART.

More...
enum  PCA9685_mode1_extclk_t { MODE1_EXTCLK_MASK = ( 1 << 6 ), MODE1_EXTCLK_ENABLED = ( 1 << 6 ), MODE1_EXTCLK_DISABLED = ( 0 << 6 ) }
 

EXTCLK.

More...
enum  PCA9685_mode1_ai_t { MODE1_AI_MASK = ( 1 << 5 ), MODE1_AI_ENABLED = ( 1 << 5 ), MODE1_AI_DISABLED = ( 0 << 5 ) }
 

AI.

More...
enum  PCA9685_mode1_sleep_t { MODE1_SLEEP_MASK = ( 1 << 4 ), MODE1_SLEEP_ENABLED = ( 1 << 4 ), MODE1_SLEEP_DISABLED = ( 0 << 4 ) }
 

SLEEP.

More...
enum  PCA9685_mode1_sub1_t { MODE1_SUB1_MASK = ( 1 << 3 ), MODE1_SUB1_ENABLED = ( 1 << 3 ), MODE1_SUB1_DISABLED = ( 0 << 3 ) }
 

SUB1.

More...
enum  PCA9685_mode1_sub2_t { MODE1_SUB2_MASK = ( 1 << 2 ), MODE1_SUB2_ENABLED = ( 1 << 2 ), MODE1_SUB2_DISABLED = ( 0 << 2 ) }
 

SUB2.

More...
enum  PCA9685_mode1_sub3_t { MODE1_SUB3_MASK = ( 1 << 1 ), MODE1_SUB3_ENABLED = ( 1 << 1 ), MODE1_SUB3_DISABLED = ( 0 << 1 ) }
 

SUB3.

More...
enum  PCA9685_mode1_allcall_t { MODE1_ALLCALL_MASK = ( 1 << 0 ), MODE1_ALLCALL_ENABLED = ( 1 << 0 ), MODE1_ALLCALL_DISABLED = ( 0 << 0 ) }
 

ALLCALL.

More...
enum  PCA9685_mode2_invrt_t { MODE2_INVRT_MASK = ( 1 << 4 ), MODE2_INVRT_ENABLED = ( 1 << 4 ), MODE2_INVRT_DISABLED = ( 0 << 4 ) }
 

INVRT.

More...
enum  PCA9685_mode2_och_t { MODE2_OCH_MASK = ( 1 << 3 ), MODE2_OCH_OUTPUT_CHANGE_STOP_CMD = ( 0 << 3 ), MODE2_OCH_OUTPUT_CHANGE_ACK_CMD = ( 1 << 3 ) }
 

OCH.

More...
enum  PCA9685_mode2_outdrv_t { MODE2_OUTDRV_MASK = ( 1 << 2 ), MODE2_OUTDRV_TOTEM_POLE_STRUCTURE = ( 1 << 2 ), MODE2_OUTDRV_OPEN_DRAIN_STRUCTURE = ( 0 << 2 ) }
 

OUTDRV.

More...
enum  PCA9685_mode2_outne_t { MODE2_OUTNE_MASK = ( 3 << 0 ), MODE2_OUTNE_LEDn_LOW = ( 0 << 0 ), MODE2_OUTNE_LEDn_HIGH = ( 1 << 0 ), MODE2_OUTNE_LEDn_HIGH_IMPEDANCE = ( 2 << 0 ) }
 

OUTNE.

More...
enum  PCA9685_internal_parameters_t { PCA9685_INTERNAL_CLOCK = 25000000, PCA9685_ADC_STEPS = 4096 }
 

INTERNAL CONSTANTS.

More...
enum  PCA9685_led_channel_t {
  PCA9685_LED0 = 0x00, PCA9685_LED1 = 0x01, PCA9685_LED2 = 0x02, PCA9685_LED3 = 0x03,
  PCA9685_LED4 = 0x04, PCA9685_LED5 = 0x05, PCA9685_LED6 = 0x06, PCA9685_LED7 = 0x07,
  PCA9685_LED8 = 0x08, PCA9685_LED9 = 0x09, PCA9685_LED10 = 0x0A, PCA9685_LED11 = 0x0B,
  PCA9685_LED12 = 0x0C, PCA9685_LED13 = 0x0D, PCA9685_LED14 = 0x0E, PCA9685_LED15 = 0x0F
}
enum  PCA9685_status_t { , I2C_SUCCESS = 0 }
 

INTERNAL CONSTANTS.

More...

Public Member Functions

 PCA9685 (PinName sda, PinName scl, uint32_t addr, uint32_t freq)
 Create an PCA9685 object connected to the specified I2C pins.
 ~PCA9685 ()
 Delete PCA9685 object.
PCA9685_status_t PCA9685_SoftReset (void)
 It resets the device by software.
PCA9685_status_t PCA9685_SetMode (PCA9685_mode1_sleep_t myMode)
 It configures the mode of the device: Sleep or Normal operation mode.
PCA9685_status_t PCA9685_SetPWM_Freq (float myNewFrequency)
 It configures a new PWM frequency.
PCA9685_status_t PCA9685_SetPWM_DutyCycle (PCA9685_led_channel_t myLEDchannel, uint8_t myDelay, uint8_t myPWM_DutyCycle)
 It configures a new PWM duty cycle on a given LED.
PCA9685_status_t PCA9685_SetPWM_DutyCycle_AllLEDs (uint8_t myDelay, uint8_t myPWM_DutyCycle)
 It configures a new PWM duty cycle on all LEDs.
PCA9685_status_t PCA9685_SetLED_ON (PCA9685_led_channel_t myLEDchannel)
 It sets the LEDn ON.
PCA9685_status_t PCA9685_SetLED_OFF (PCA9685_led_channel_t myLEDchannel)
 It sets the LEDn OFF.
PCA9685_status_t PCA9685_SetAllLED_ON (void)
 It sets All LEDs ON.
PCA9685_status_t PCA9685_SetAllLED_OFF (void)
 It sets All LEDs OFF.
PCA9685_status_t PCA9685_SetSUB1 (PCA9685_mode1_sub1_t mySUB1_mode)
 It sets SUB1 mode.
PCA9685_status_t PCA9685_SetSUB2 (PCA9685_mode1_sub2_t mySUB2_mode)
 It sets SUB2 mode.
PCA9685_status_t PCA9685_SetSUB3 (PCA9685_mode1_sub3_t mySUB3_mode)
 It sets SUB3 mode.
PCA9685_status_t PCA9685_SetALLCALL (PCA9685_mode1_allcall_t myALLCALL_mode)
 It sets ALLCALL mode.
PCA9685_status_t PCA9685_SetINVERT (PCA9685_mode2_invrt_t myINVERT_mode)
 It sets INVERT mode.
PCA9685_status_t PCA9685_SetOCH (PCA9685_mode2_och_t myOCH_mode)
 It sets OCH mode.
PCA9685_status_t PCA9685_SetOUTDRV (PCA9685_mode2_outdrv_t myOUTDRV_mode)
 It sets OUTDRV mode.

Detailed Description

Example:

include "mbed.h" include "PCA9685.h"

PCA9685 myPWMSensor ( I2C_SDA, I2C_SCL, PCA9685::PCA9685_ADDRESS_0, 400000 );

Ticker newPWMOutput; DigitalOut myled(LED1);

PCA9685::PCA9685_status_t aux; uint8_t myState = 0;

void changeDATA ( void ) { myState++; }

int main() { Reset the device aux = myPWMSensor.PCA9685_SoftReset (); wait_us ( 5 );

Configure the PWM frequency and wake up the device aux = myPWMSensor.PCA9685_SetPWM_Freq ( 1000 ); // PWM frequency: 1kHz aux = myPWMSensor.PCA9685_SetMode ( PCA9685::MODE1_SLEEP_DISABLED );

newPWMOutput.attach( &changeDATA, 1 ); // the address of the function to be attached ( changeDATA ) and the interval ( 1s )

Let the callbacks take care of everything while(1) { sleep();

myled = 1;

switch ( myState ) { default: case 0: All LEDs: Delay Time = 1% | PWM duty cycle = 99% aux = myPWMSensor.PCA9685_SetPWM_DutyCycle_AllLEDs ( 0, 99 );

myState = 1; break;

case 1: All LEDs: Delay Time = 100% | PWM duty cycle = 1% aux = myPWMSensor.PCA9685_SetPWM_DutyCycle_AllLEDs ( 100, 1 );

myState = 2; break;

case 2: LED1: Delay Time = 10% | PWM duty cycle = 30% aux = myPWMSensor.PCA9685_SetPWM_DutyCycle ( PCA9685::PCA9685_LED1, 10, 30 );

myState = 0; break; }

myled = 0; } }

Library for the PCA9685 16-channel, 12-bit PWM Fm+ I2C-bus LED controller.

Definition at line 96 of file PCA9685.h.


Member Enumeration Documentation

DEFAULT ADDRESSES.

NOTE: There are a maximum of 64 possible programmable addresses using the 6 hardware address pins. Two of these addresses, Software Reset and LED All Call, cannot be used because their default power-up state is ON, leaving a maximum of 62 addresses. Using other reserved addresses, as well as any other subcall address, will reduce the total number of possible addresses even further.

To access to a certain address just use the following method: PCA9685_ADDRESS_0 + Counter_Address Ex: PCA9685_ADDRESS_0 + 1 = 0x40 + 1 = 0x41 ( 0b1000001 ) PCA9685_ADDRESS_0 + 10 = 0x40 + 10 = 0x4A ( 0b1001010 ) and so on...

Enumerator:
PCA9685_ADDRESS_0 

A5 A4 A3 A2 A1 A0: 000 000

Definition at line 112 of file PCA9685.h.

INTERNAL CONSTANTS.

Enumerator:
PCA9685_INTERNAL_CLOCK 

Internal clock frequency

PCA9685_ADC_STEPS 

ADC 12-bits

Definition at line 360 of file PCA9685.h.

Enumerator:
PCA9685_LED0 

LED0 channel

PCA9685_LED1 

LED1 channel

PCA9685_LED2 

LED2 channel

PCA9685_LED3 

LED3 channel

PCA9685_LED4 

LED4 channel

PCA9685_LED5 

LED5 channel

PCA9685_LED6 

LED6 channel

PCA9685_LED7 

LED7 channel

PCA9685_LED8 

LED8 channel

PCA9685_LED9 

LED9 channel

PCA9685_LED10 

LED10 channel

PCA9685_LED11 

LED11 channel

PCA9685_LED12 

LED12 channel

PCA9685_LED13 

LED13 channel

PCA9685_LED14 

LED14 channel

PCA9685_LED15 

LED15 channel

Definition at line 366 of file PCA9685.h.

AI.

Enumerator:
MODE1_AI_MASK 

AI bit mask

MODE1_AI_ENABLED 

Auto-Increment enabled

MODE1_AI_DISABLED 

Auto-Increment disabled ( default )

Definition at line 254 of file PCA9685.h.

ALLCALL.

Enumerator:
MODE1_ALLCALL_MASK 

ALLCALL bit mask

MODE1_ALLCALL_ENABLED 

PCA9685 responds to LED All Call I2C-bus address ( default )

MODE1_ALLCALL_DISABLED 

PCA9685 does not respond to LED All Call I2C-bus address

Definition at line 304 of file PCA9685.h.

EXTCLK.

Enumerator:
MODE1_EXTCLK_MASK 

EXTCLK bit mask

MODE1_EXTCLK_ENABLED 

Use EXTERNAL clock

MODE1_EXTCLK_DISABLED 

Use INTERNAL clock ( default )

Definition at line 244 of file PCA9685.h.

RESTART.

Enumerator:
MODE1_RESTART_MASK 

RESTART bit mask

MODE1_RESTART_ENABLED 

Restart enabled

MODE1_RESTART_DISABLED 

Restart disabled ( default )

Definition at line 234 of file PCA9685.h.

SLEEP.

Enumerator:
MODE1_SLEEP_MASK 

SLEEP bit mask

MODE1_SLEEP_ENABLED 

Low power mode. Oscillator off ( default )

MODE1_SLEEP_DISABLED 

Normal mode

Definition at line 264 of file PCA9685.h.

SUB1.

Enumerator:
MODE1_SUB1_MASK 

SUB1 bit mask

MODE1_SUB1_ENABLED 

PCA9685 responds to I2C-bus subaddress 1

MODE1_SUB1_DISABLED 

PCA9685 does not respond to I2C-bus subaddress 1 ( default )

Definition at line 274 of file PCA9685.h.

SUB2.

Enumerator:
MODE1_SUB2_MASK 

SUB2 bit mask

MODE1_SUB2_ENABLED 

PCA9685 responds to I2C-bus subaddress 2

MODE1_SUB2_DISABLED 

PCA9685 does not respond to I2C-bus subaddress 2 ( default )

Definition at line 284 of file PCA9685.h.

SUB3.

Enumerator:
MODE1_SUB3_MASK 

SUB1 bit mask

MODE1_SUB3_ENABLED 

PCA9685 responds to I2C-bus subaddress 3

MODE1_SUB3_DISABLED 

PCA9685 does not respond to I2C-bus subaddress 3 ( default )

Definition at line 294 of file PCA9685.h.

INVRT.

Enumerator:
MODE2_INVRT_MASK 

INVRT bit mask

MODE2_INVRT_ENABLED 

Output logic state inverted. Value to use when no external driver used. Applicable when OE = 0

MODE2_INVRT_DISABLED 

Output logic state not inverted. Value to use when external driver used. Applicable when OE = 0. ( default )

Definition at line 316 of file PCA9685.h.

OCH.

Enumerator:
MODE2_OCH_MASK 

ALLCALL bit mask

MODE2_OCH_OUTPUT_CHANGE_STOP_CMD 

Outputs change on STOP command ( default )

MODE2_OCH_OUTPUT_CHANGE_ACK_CMD 

Outputs change on ACK

Definition at line 326 of file PCA9685.h.

OUTDRV.

Enumerator:
MODE2_OUTDRV_MASK 

OUTDRV bit mask

MODE2_OUTDRV_TOTEM_POLE_STRUCTURE 

The 16 LEDn outputs are configured with a totem pole structure ( default )

MODE2_OUTDRV_OPEN_DRAIN_STRUCTURE 

The 16 LEDn outputs are configured with an open-drain structure

Definition at line 336 of file PCA9685.h.

OUTNE.

Enumerator:
MODE2_OUTNE_MASK 

OUTNE bit mask

MODE2_OUTNE_LEDn_LOW 

When OE = 1 (output drivers not enabled), LEDn = 0 ( default )

MODE2_OUTNE_LEDn_HIGH 

When OE = 1 (output drivers not enabled): LEDn = 1 when OUTDRV = 1 LEDn = high-impedance when OUTDRV = 0 (same as OUTNE[1:0] = 10)

MODE2_OUTNE_LEDn_HIGH_IMPEDANCE 

When OE = 1 (output drivers not enabled), LEDn = high-impedance

Definition at line 346 of file PCA9685.h.

REGISTER DEFINITIONS.

Enumerator:
MODE1 

Mode register 1

MODE2 

Mode register 2

SUBADR1 

I2C-bus subaddress 1

SUBADR2 

I2C-bus subaddress 2

SUBADR3 

I2C-bus subaddress 3

ALLCALLADR 

LED All Call I2C-bus address

LED0_ON_L 

LED0 output and brightness control byte 0

LED0_ON_H 

LED0 output and brightness control byte 1

LED0_OFF_L 

LED0 output and brightness control byte 2

LED0_OFF_H 

LED0 output and brightness control byte 3

LED1_ON_L 

LED1 output and brightness control byte 0

LED1_ON_H 

LED1 output and brightness control byte 1

LED1_OFF_L 

LED1 output and brightness control byte 2

LED1_OFF_H 

LED1 output and brightness control byte 3

LED2_ON_L 

LED2 output and brightness control byte 0

LED2_ON_H 

LED2 output and brightness control byte 1

LED2_OFF_L 

LED2 output and brightness control byte 2

LED2_OFF_H 

LED2 output and brightness control byte 3

LED3_ON_L 

LED3 output and brightness control byte 0

LED3_ON_H 

LED3 output and brightness control byte 1

LED3_OFF_L 

LED3 output and brightness control byte 2

LED3_OFF_H 

LED3 output and brightness control byte 3

LED4_ON_L 

LED4 output and brightness control byte 0

LED4_ON_H 

LED4 output and brightness control byte 1

LED4_OFF_L 

LED4 output and brightness control byte 2

LED4_OFF_H 

LED4 output and brightness control byte 3

LED5_ON_L 

LED5 output and brightness control byte 0

LED5_ON_H 

LED5 output and brightness control byte 1

LED5_OFF_L 

LED5 output and brightness control byte 2

LED5_OFF_H 

LED5 output and brightness control byte 3

LED6_ON_L 

LED6 output and brightness control byte 0

LED6_ON_H 

LED6 output and brightness control byte 1

LED6_OFF_L 

LED6 output and brightness control byte 2

LED6_OFF_H 

LED6 output and brightness control byte 3

LED7_ON_L 

LED7 output and brightness control byte 0

LED7_ON_H 

LED7 output and brightness control byte 1

LED7_OFF_L 

LED7 output and brightness control byte 2

LED7_OFF_H 

LED7 output and brightness control byte 3

LED8_ON_L 

LED8 output and brightness control byte 0

LED8_ON_H 

LED8 output and brightness control byte 1

LED8_OFF_L 

LED8 output and brightness control byte 2

LED8_OFF_H 

LED8 output and brightness control byte 3

LED9_ON_L 

LED9 output and brightness control byte 0

LED9_ON_H 

LED9 output and brightness control byte 1

LED9_OFF_L 

LED9 output and brightness control byte 2

LED9_OFF_H 

LED9 output and brightness control byte 3

LED10_ON_L 

LED10 output and brightness control byte 0

LED10_ON_H 

LED10 output and brightness control byte 1

LED10_OFF_L 

LED10 output and brightness control byte 2

LED10_OFF_H 

LED10 output and brightness control byte 3

LED11_ON_L 

LED11 output and brightness control byte 0

LED11_ON_H 

LED11 output and brightness control byte 1

LED11_OFF_L 

LED11 output and brightness control byte 2

LED11_OFF_H 

LED11 output and brightness control byte 3

LED12_ON_L 

LED12 output and brightness control byte 0

LED12_ON_H 

LED12 output and brightness control byte 1

LED12_OFF_L 

LED12 output and brightness control byte 2

LED12_OFF_H 

LED12 output and brightness control byte 3

LED13_ON_L 

LED13 output and brightness control byte 0

LED13_ON_H 

LED13 output and brightness control byte 1

LED13_OFF_L 

LED13 output and brightness control byte 2

LED13_OFF_H 

LED13 output and brightness control byte 3

LED14_ON_L 

LED14 output and brightness control byte 0

LED14_ON_H 

LED14 output and brightness control byte 1

LED14_OFF_L 

LED14 output and brightness control byte 2

LED14_OFF_H 

LED14 output and brightness control byte 3

LED15_ON_L 

LED15 output and brightness control byte 0

LED15_ON_H 

LED15 output and brightness control byte 1

LED15_OFF_L 

LED15 output and brightness control byte 2

LED15_OFF_H 

LED15 output and brightness control byte 3

ALL_LED_ON_L 

load all the LEDn_ON registers, byte 0

ALL_LED_ON_H 

load all the LEDn_ON registers, byte 1

ALL_LED_OFF_L 

load all the LEDn_OFF registers, byte 0

ALL_LED_OFF_H 

load all the LEDn_OFF registers, byte 1

PRE_SCALE 

prescaler for PWM output frequency

TESTMODE 

defines the test mode to be entered

Definition at line 121 of file PCA9685.h.

SWRST.

NOTE: The Software Reset address (SWRST Call) must be used with R/W = logic 0. If R/W = logic 1, the PCA9685 does not acknowledge the SWRST.

Enumerator:
GENERAL_CALL_ADDRESS 

Software reset

SWRST 

Software reset

Definition at line 222 of file PCA9685.h.

INTERNAL CONSTANTS.

Enumerator:
I2C_SUCCESS 

I2C communication was fine

Definition at line 392 of file PCA9685.h.

SUBADDRESS.

NOTE: At power-up, Sub Call I2C-bus addresses are disabled. PCA9685 does not send an ACK when E2h (R/W = 0) or E3h (R/W = 1), E4h (R/W = 0) or E5h (R/W = 1), or E8h (R/W = 0) or E9h (R/W = 1) is sent by the master.

Enumerator:
SUBADR1_REG 

Subaddress 1

SUBADR2_REG 

Subaddress 2

SUBADR3_REG 

Subaddress 3

Definition at line 208 of file PCA9685.h.


Constructor & Destructor Documentation

PCA9685 ( PinName  sda,
PinName  scl,
uint32_t  addr,
uint32_t  freq 
)

Create an PCA9685 object connected to the specified I2C pins.

PCA9685.h.

Parameters:
sdaI2C data pin
sclI2C clock pin
addrI2C slave address
freqI2C frequency in Hz.

16-channel, 12-bit PWM Fm+ I2C-bus LED controller. Functions file.

Returns:
NA
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN
Precondition:
This code belongs to AqueronteBlog ( http://unbarquero.blogspot.com ).

Definition at line 20 of file PCA9685.cpp.

~PCA9685 (  )

Delete PCA9685 object.

Definition at line 28 of file PCA9685.cpp.


Member Function Documentation

PCA9685::PCA9685_status_t PCA9685_SetALLCALL ( PCA9685_mode1_allcall_t  myALLCALL_mode )

It sets ALLCALL mode.

PCA9685_SetALLCALL ( PCA9685_mode1_allcall_t )

The device responds ( Enabled ) or not ( Disabled ) to LED All Call I2C-bus address.

Parameters:
[in]myALLCALL_mode,:ALLCALL Enabled/Disabled.
[out]NaN.
Returns:
Status of PCA9685_SetALLCALL.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 796 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SetAllLED_OFF ( void   )

It sets All LEDs OFF.

PCA9685_SetAllLED_OFF ( void )

It sets All LEDs OFF.

Parameters:
[in]NaN.
[out]NaN.
Returns:
Status of PCA9685_SetAllLED_OFF.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
Update on ACK requires all 4 PWM channel registers to be loaded before outputs will change on the last ACK.
Warning:
NaN.

Definition at line 596 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SetAllLED_ON ( void   )

It sets All LEDs ON.

PCA9685_SetAllLED_ON ( void )

It sets All LEDs ON.

Parameters:
[in]NaN.
[out]NaN.
Returns:
Status of PCA9685_SetAllLED_ON.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
Update on ACK requires all 4 PWM channel registers to be loaded before outputs will change on the last ACK.
Warning:
NaN.

Definition at line 530 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SetINVERT ( PCA9685_mode2_invrt_t  myINVERT_mode )

It sets INVERT mode.

PCA9685_SetINVERT ( PCA9685_mode2_invrt_t )

Output logic state inverted ( Enabled ) or not ( Disabled ). Value to use when external driver used. Applicable when OE = 0

Parameters:
[in]myINVERT_mode,:INVERT Enabled/Disabled.
[out]NaN.
Returns:
Status of PCA9685_SetINVERT.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 842 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SetLED_OFF ( PCA9685_led_channel_t  myLEDchannel )

It sets the LEDn OFF.

PCA9685_SetLED_OFF ( PCA9685_led_channel_t )

It sets LEDn OFF.

Parameters:
[in]myLEDchannel,:Chosen LED ( channel ).
[out]NaN.
Returns:
Status of PCA9685_SetLED_OFF.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
Update on ACK requires all 4 PWM channel registers to be loaded before outputs will change on the last ACK.
Warning:
NaN.

Definition at line 464 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SetLED_ON ( PCA9685_led_channel_t  myLEDchannel )

It sets the LEDn ON.

PCA9685_SetLED_ON ( PCA9685_led_channel_t )

It sets LEDn ON.

Parameters:
[in]myLEDchannel,:Chosen LED ( channel ).
[out]NaN.
Returns:
Status of PCA9685_SetLED_ON.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
Update on ACK requires all 4 PWM channel registers to be loaded before outputs will change on the last ACK.
Warning:
NaN.

Definition at line 398 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SetMode ( PCA9685_mode1_sleep_t  myMode )

It configures the mode of the device: Sleep or Normal operation mode.

PCA9685_SetMode ( PCA9685_mode1_sleep_t )

It configures the device in Low power mode or in Normal operation mode.

Parameters:
[in]myMode,:Sleep or Normal mode.
[out]NaN.
Returns:
Status of PCA9685_SetMode.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 94 of file PCA9685.cpp.

PCA9685_status_t PCA9685_SetOCH ( PCA9685_mode2_och_t  myOCH_mode )

It sets OCH mode.

PCA9685::PCA9685_status_t PCA9685_SetOUTDRV ( PCA9685_mode2_outdrv_t  myOUTDRV_mode )

It sets OUTDRV mode.

PCA9685_SetOUTDRV ( PCA9685_mode2_outdrv_t )

It sets the 16 LEDn as open-drain or totem pole structure.

Parameters:
[in]myOUTDRV_mode,:OUTDRV mode.
[out]NaN.
Returns:
Status of PCA9685_SetOUTDRV.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 887 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SetPWM_DutyCycle ( PCA9685_led_channel_t  myLEDchannel,
uint8_t  myDelay,
uint8_t  myPWM_DutyCycle 
)

It configures a new PWM duty cycle on a given LED.

PCA9685_SetPWM_DutyCycle ( PCA9685_led_channel_t , uint8_t , uint8_t )

It sets a new PWM duty cycle on the given LED ( channel ).

Parameters:
[in]myLEDchannel,:Chosen LED ( channel ).
[in]myDelay,:PWM delay.
[in]myPWM_DutyCycle,:PWM duty cycle.
[out]NaN.
Returns:
Status of PCA9685_SetPWM_DutyCycle.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
Datasheet p.17 ( Example 1 and Example 2).
Warning:
NaN.

Definition at line 207 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SetPWM_DutyCycle_AllLEDs ( uint8_t  myDelay,
uint8_t  myPWM_DutyCycle 
)

It configures a new PWM duty cycle on all LEDs.

PCA9685_SetPWM_DutyCycle_AllLEDs ( uint8_t , uint8_t )

It sets a new PWM duty cycle on all LEDs ( all channels ).

Parameters:
[in]myDelay,:PWM delay.
[in]myPWM_DutyCycle,:PWM duty cycle.
[out]NaN.
Returns:
Status of PCA9685_SetPWM_DutyCycle_AllLEDs.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
Datasheet p.17 ( Example 1 and Example 2).
Warning:
NaN.

Definition at line 303 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SetPWM_Freq ( float  myNewFrequency )

It configures a new PWM frequency.

PCA9685_SetPWM_Freq ( float )

It sets a new PWM frequency.

Parameters:
[in]myNewFrequency,:New PWM frequency.
[out]NaN.
Returns:
Status of PCA9685_SetPWM_Freq.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
This library can ONLY work with the internal clock, otherwise PCA9685_INTERNAL_CLOCK must be changed in the header file.
Warning:
NaN.

Definition at line 139 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SetSUB1 ( PCA9685_mode1_sub1_t  mySUB1_mode )

It sets SUB1 mode.

PCA9685_SetSUB1 ( PCA9685_mode1_sub1_t )

The device responds ( Enabled ) or not ( Disabled ) to I2C-bus subaddress 1.

Parameters:
[in]mySUB1_mode,:SUB1 Enabled/Disabled.
[out]NaN.
Returns:
Status of PCA9685_SetSUB1.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 661 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SetSUB2 ( PCA9685_mode1_sub2_t  mySUB2_mode )

It sets SUB2 mode.

PCA9685_SetSUB2 ( PCA9685_mode1_sub2_t )

The device responds ( Enabled ) or not ( Disabled ) to I2C-bus subaddress 2.

Parameters:
[in]mySUB2_mode,:SUB2 Enabled/Disabled.
[out]NaN.
Returns:
Status of PCA9685_SetSUB2.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 706 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SetSUB3 ( PCA9685_mode1_sub3_t  mySUB3_mode )

It sets SUB3 mode.

PCA9685_SetSUB3 ( PCA9685_mode1_sub3_t )

The device responds ( Enabled ) or not ( Disabled ) to I2C-bus subaddress 3.

Parameters:
[in]mySUB3_mode,:SUB3 Enabled/Disabled.
[out]NaN.
Returns:
Status of PCA9685_SetSUB3.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 751 of file PCA9685.cpp.

PCA9685::PCA9685_status_t PCA9685_SoftReset ( void   )

It resets the device by software.

PCA9685_SoftReset ( void )

It performs a software reset.

Parameters:
[in]NaN.
[out]NaN.
Returns:
Status of PCA9685_SoftReset.
Author:
Manuel Caballero
Date:
7/November/2017
Version:
7/November/2017 The ORIGIN
Precondition:
The device will be ready to be addressed again within the specified bus free time ( t_BUF ).
Warning:
NaN.

Definition at line 54 of file PCA9685.cpp.