Hello world code for PCA9626 class library. The PCA9626 is a 24-channel Fm+ I2C-bus 100mA/40 V LED driver. This program shows its basic operation of PWM output.

Dependencies:   PCA962x mbed

Please refer to the component page for details

8, 16 & 24-channel Fm+ I2C-bus 100mA/40 V LED driver

High-level API is available

A high-level API that can be used as the "PwmOut" of bed-SDK is available.
This API enables to make instances of each LED output pins and control PWM duty cycle by assignment.
For detail information, refer API document of LedPwmOut Class class which is included in PCA962xA class library.

#include "mbed.h"
#include "PCA9626.h"

PCA9626     led_cntlr( p28, p27, 0xC4 );  //  SDA, SCL, Slave_address(option)
LedPwmOut   led( led_cntlr, L0 );

int main()
{
    while( 1 ) {
        for( float p = 0.0f; p < 1.0f; p += 0.1f ) {
            led     = p;
            wait( 0.1 );
        }
    }
}
Committer:
nxp_ip
Date:
Wed Mar 04 08:29:33 2015 +0000
Revision:
2:1feea0f8e521
Parent:
1:4e1fafcd63fa
Child:
3:5625ea2d9be8
Library update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxp_ip 2:1feea0f8e521 1 #if 0
nxp_ip 0:883e8fa760af 2 #include "mbed.h"
nxp_ip 0:883e8fa760af 3
nxp_ip 0:883e8fa760af 4 #include "PCA9626.h"
nxp_ip 0:883e8fa760af 5 PCA9626 led_cntlr( p28, p27, 0x3E ); // SDA, SCL, Slave_address(option)
nxp_ip 0:883e8fa760af 6
nxp_ip 0:883e8fa760af 7 int main()
nxp_ip 0:883e8fa760af 8 {
nxp_ip 0:883e8fa760af 9 while(1) {
nxp_ip 0:883e8fa760af 10 for ( int port = 0; port < led_cntlr.number_of_ports(); port++ ) {
nxp_ip 0:883e8fa760af 11 for ( int i = 1; i <= 100; i++ ) {
nxp_ip 0:883e8fa760af 12 led_cntlr.pwm( port, (float)i / 100.0 );
nxp_ip 0:883e8fa760af 13 wait( 0.01 );
nxp_ip 0:883e8fa760af 14 }
nxp_ip 0:883e8fa760af 15 }
nxp_ip 0:883e8fa760af 16 led_cntlr.pwm( ALLPORTS, 0.0 );
nxp_ip 0:883e8fa760af 17 }
nxp_ip 0:883e8fa760af 18 }
nxp_ip 2:1feea0f8e521 19 #endif
nxp_ip 1:4e1fafcd63fa 20
nxp_ip 1:4e1fafcd63fa 21
nxp_ip 1:4e1fafcd63fa 22
nxp_ip 2:1feea0f8e521 23 #if 1 // Sample of using LedPwmOut API
nxp_ip 1:4e1fafcd63fa 24 #include "mbed.h"
nxp_ip 1:4e1fafcd63fa 25 #include "PCA9626.h"
nxp_ip 1:4e1fafcd63fa 26 #include "PCA9622.h"
nxp_ip 1:4e1fafcd63fa 27 #include "PCA9624.h"
nxp_ip 1:4e1fafcd63fa 28
nxp_ip 1:4e1fafcd63fa 29 PCA9626 led_cntlr( p28, p27, 0x3E ); // SDA, SCL, Slave_address(option)
nxp_ip 1:4e1fafcd63fa 30
nxp_ip 1:4e1fafcd63fa 31 LedPwmOut leds[] = {
nxp_ip 2:1feea0f8e521 32 LedPwmOut( led_cntlr, L13 ),
nxp_ip 2:1feea0f8e521 33 LedPwmOut( led_cntlr, L14 ),
nxp_ip 2:1feea0f8e521 34 LedPwmOut( led_cntlr, L15 ),
nxp_ip 2:1feea0f8e521 35 LedPwmOut( led_cntlr, L16 ),
nxp_ip 2:1feea0f8e521 36 LedPwmOut( led_cntlr, L17 ),
nxp_ip 2:1feea0f8e521 37 LedPwmOut( led_cntlr, L18 ),
nxp_ip 2:1feea0f8e521 38 LedPwmOut( led_cntlr, L19 ),
nxp_ip 2:1feea0f8e521 39 LedPwmOut( led_cntlr, L20 ),
nxp_ip 2:1feea0f8e521 40 LedPwmOut( led_cntlr, L21 ),
nxp_ip 2:1feea0f8e521 41 LedPwmOut( led_cntlr, L22 ),
nxp_ip 2:1feea0f8e521 42 LedPwmOut( led_cntlr, L23 ),
nxp_ip 1:4e1fafcd63fa 43 LedPwmOut( led_cntlr, L0 ),
nxp_ip 1:4e1fafcd63fa 44 LedPwmOut( led_cntlr, L1 ),
nxp_ip 1:4e1fafcd63fa 45 LedPwmOut( led_cntlr, L2 ),
nxp_ip 1:4e1fafcd63fa 46 LedPwmOut( led_cntlr, L3 ),
nxp_ip 1:4e1fafcd63fa 47 LedPwmOut( led_cntlr, L4 ),
nxp_ip 1:4e1fafcd63fa 48 LedPwmOut( led_cntlr, L5 ),
nxp_ip 1:4e1fafcd63fa 49 LedPwmOut( led_cntlr, L6 ),
nxp_ip 1:4e1fafcd63fa 50 LedPwmOut( led_cntlr, L7 ),
nxp_ip 1:4e1fafcd63fa 51 LedPwmOut( led_cntlr, L8 ),
nxp_ip 1:4e1fafcd63fa 52 LedPwmOut( led_cntlr, L9 ),
nxp_ip 1:4e1fafcd63fa 53 LedPwmOut( led_cntlr, L10 ),
nxp_ip 1:4e1fafcd63fa 54 LedPwmOut( led_cntlr, L11 ),
nxp_ip 1:4e1fafcd63fa 55 LedPwmOut( led_cntlr, L12 ),
nxp_ip 1:4e1fafcd63fa 56 };
nxp_ip 1:4e1fafcd63fa 57
nxp_ip 1:4e1fafcd63fa 58 int main()
nxp_ip 1:4e1fafcd63fa 59 {
nxp_ip 1:4e1fafcd63fa 60 while(1) {
nxp_ip 1:4e1fafcd63fa 61 for ( int ch = 0; ch < 24; ch++ ) {
nxp_ip 1:4e1fafcd63fa 62 for ( float p = 0.0; p < 1.0; p += 0.01 ) {
nxp_ip 1:4e1fafcd63fa 63 leds[ ch ] = p;
nxp_ip 1:4e1fafcd63fa 64 wait( 0.01 );
nxp_ip 1:4e1fafcd63fa 65 }
nxp_ip 1:4e1fafcd63fa 66 }
nxp_ip 1:4e1fafcd63fa 67 }
nxp_ip 1:4e1fafcd63fa 68 }
nxp_ip 1:4e1fafcd63fa 69 #endif