InetrfaceProducts NXP / Mbed 2 deprecated PCA9956A_Hello

Dependencies:   PCA995xA mbed

Committer:
nxp_ip
Date:
Wed Mar 04 10:30:26 2015 +0000
Revision:
1:fd208c007499
Parent:
0:11740e097e7b
Child:
2:9b700bf94085
Library updated

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxp_ip 1:fd208c007499 1 #include "mbed.h"
nxp_ip 0:11740e097e7b 2
nxp_ip 1:fd208c007499 3 #include "PCA9956A.h"
nxp_ip 0:11740e097e7b 4 PCA9956A led_cntlr( p28, p27, 0x02 ); // SDA, SCL, Slave_address(option)
nxp_ip 0:11740e097e7b 5
nxp_ip 0:11740e097e7b 6 int main()
nxp_ip 0:11740e097e7b 7 {
nxp_ip 0:11740e097e7b 8 led_cntlr.current( ALLPORTS, 1.0 ); // Set all ports output current 100%
nxp_ip 0:11740e097e7b 9
nxp_ip 0:11740e097e7b 10 while(1) {
nxp_ip 0:11740e097e7b 11 for ( int port = 0; port < led_cntlr.number_of_ports(); port++ ) {
nxp_ip 0:11740e097e7b 12 for ( int i = 1; i <= 100; i++ ) {
nxp_ip 0:11740e097e7b 13 led_cntlr.pwm( port, (float)i / 100.0 );
nxp_ip 0:11740e097e7b 14 wait( 0.01 );
nxp_ip 0:11740e097e7b 15 }
nxp_ip 0:11740e097e7b 16 }
nxp_ip 0:11740e097e7b 17 led_cntlr.pwm( ALLPORTS, 0.0 ); // Set all ports output PWM 0%
nxp_ip 0:11740e097e7b 18 }
nxp_ip 0:11740e097e7b 19 }
nxp_ip 1:fd208c007499 20
nxp_ip 1:fd208c007499 21
nxp_ip 1:fd208c007499 22
nxp_ip 1:fd208c007499 23
nxp_ip 1:fd208c007499 24
nxp_ip 1:fd208c007499 25
nxp_ip 1:fd208c007499 26 #if 0 // Sample of using LedPwmOut API
nxp_ip 1:fd208c007499 27 #include "mbed.h"
nxp_ip 1:fd208c007499 28 #include "PCA9956A.h"
nxp_ip 1:fd208c007499 29
nxp_ip 1:fd208c007499 30 PCA9956A led_cntlr( p28, p27, 0x02 );
nxp_ip 1:fd208c007499 31 LedPwmOutCC leds[] = {
nxp_ip 1:fd208c007499 32 LedPwmOutCC( led_cntlr, L2 ),
nxp_ip 1:fd208c007499 33 LedPwmOutCC( led_cntlr, L5 ),
nxp_ip 1:fd208c007499 34 LedPwmOutCC( led_cntlr, L8 ),
nxp_ip 1:fd208c007499 35 LedPwmOutCC( led_cntlr, L11 ),
nxp_ip 1:fd208c007499 36 LedPwmOutCC( led_cntlr, L14 ),
nxp_ip 1:fd208c007499 37 LedPwmOutCC( led_cntlr, L17 ),
nxp_ip 1:fd208c007499 38 LedPwmOutCC( led_cntlr, L20 ),
nxp_ip 1:fd208c007499 39 LedPwmOutCC( led_cntlr, L23 ),
nxp_ip 1:fd208c007499 40
nxp_ip 1:fd208c007499 41 LedPwmOutCC( led_cntlr, L0 ),
nxp_ip 1:fd208c007499 42 LedPwmOutCC( led_cntlr, L3 ),
nxp_ip 1:fd208c007499 43 LedPwmOutCC( led_cntlr, L6 ),
nxp_ip 1:fd208c007499 44 LedPwmOutCC( led_cntlr, L9 ),
nxp_ip 1:fd208c007499 45 LedPwmOutCC( led_cntlr, L12 ),
nxp_ip 1:fd208c007499 46 LedPwmOutCC( led_cntlr, L15 ),
nxp_ip 1:fd208c007499 47 LedPwmOutCC( led_cntlr, L18 ),
nxp_ip 1:fd208c007499 48 LedPwmOutCC( led_cntlr, L21 ),
nxp_ip 1:fd208c007499 49
nxp_ip 1:fd208c007499 50 LedPwmOutCC( led_cntlr, L1 ),
nxp_ip 1:fd208c007499 51 LedPwmOutCC( led_cntlr, L4 ),
nxp_ip 1:fd208c007499 52 LedPwmOutCC( led_cntlr, L7 ),
nxp_ip 1:fd208c007499 53 LedPwmOutCC( led_cntlr, L10 ),
nxp_ip 1:fd208c007499 54 LedPwmOutCC( led_cntlr, L13 ),
nxp_ip 1:fd208c007499 55 LedPwmOutCC( led_cntlr, L16 ),
nxp_ip 1:fd208c007499 56 LedPwmOutCC( led_cntlr, L19 ),
nxp_ip 1:fd208c007499 57 LedPwmOutCC( led_cntlr, L22 ),
nxp_ip 1:fd208c007499 58
nxp_ip 1:fd208c007499 59 };
nxp_ip 1:fd208c007499 60
nxp_ip 1:fd208c007499 61 int main()
nxp_ip 1:fd208c007499 62 {
nxp_ip 1:fd208c007499 63 for ( int ch = 0; ch < 24; ch++ )
nxp_ip 1:fd208c007499 64 leds[ ch ] = 1.0;
nxp_ip 1:fd208c007499 65 for ( int ch = 0; ch < 24; ch++ )
nxp_ip 1:fd208c007499 66 leds[ ch ].current( 0.0 );
nxp_ip 1:fd208c007499 67
nxp_ip 1:fd208c007499 68 while(1) {
nxp_ip 1:fd208c007499 69 for ( int ch = 0; ch < 24; ch++ ) {
nxp_ip 1:fd208c007499 70 for ( float p = 0.0; p < 1.0; p += 0.01 ) {
nxp_ip 1:fd208c007499 71 // leds[ ch ] = p;
nxp_ip 1:fd208c007499 72 leds[ ch ].current( p );
nxp_ip 1:fd208c007499 73 wait( 0.01 );
nxp_ip 1:fd208c007499 74 }
nxp_ip 1:fd208c007499 75 }
nxp_ip 1:fd208c007499 76 for ( float c = 1.0; c > 0.0; c -= 0.01 ) {
nxp_ip 1:fd208c007499 77 for ( int ch = 0; ch < 24; ch++ ) {
nxp_ip 1:fd208c007499 78 leds[ ch ].current( c );
nxp_ip 1:fd208c007499 79
nxp_ip 1:fd208c007499 80 }
nxp_ip 1:fd208c007499 81 wait( 0.01 );
nxp_ip 1:fd208c007499 82 }
nxp_ip 1:fd208c007499 83 }
nxp_ip 1:fd208c007499 84 }
nxp_ip 1:fd208c007499 85 #endif