Sample code to demonstrate PCA9955A's gradation control
Revision 2:0cc3bba73370, committed 2022-06-16
- Comitter:
- nxp_ip
- Date:
- Thu Jun 16 23:01:19 2022 +0000
- Parent:
- 1:47c33baeed67
- Child:
- 3:86a75682abfc
- Commit message:
- Demo behavior change (brighter manual blink); + Suppressing warning in KeilStudio and fix of API document
Changed in this revision
| PCA995xA.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/PCA995xA.lib Thu Mar 19 10:50:17 2015 +0000 +++ b/PCA995xA.lib Thu Jun 16 23:01:19 2022 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/nxp_ip/code/PCA995xA/#cb07190e05e7 +http://developer.mbed.org/users/nxp_ip/code/PCA995xA/#5c1762c7610a
--- a/main.cpp Thu Mar 19 10:50:17 2015 +0000
+++ b/main.cpp Thu Jun 16 23:01:19 2022 +0000
@@ -3,10 +3,17 @@
#include "PCA9955A.h"
PCA9955A led_cntlr( p28, p27, 0x02 ); // SDA, SCL, Slave_address(option)
-#define GRADATION_PERIOD 6.0
+#define GRADATION_PERIOD 6.0
+
+#define MANUAL_BLINK_PERIOD 0.1
+#define MANUAL_BLINK_ON_DURATION 0.03
int main()
{
+ // Set current ourput maximum (1.0 = 100%)
+ led_cntlr.current( ALLPORTS, 1.0 );
+
+ // Gradation control grouping
led_cntlr.gradation_group_setting( 0, 1 ); // Port 1 is assigned to group 0
led_cntlr.gradation_group_setting( 0, 5 ); // Port 5 is assigned to group 0
led_cntlr.gradation_group_setting( 0, 9 ); // Port 9 is assigned to group 0
@@ -47,15 +54,14 @@
//
// Next while loop perform manual control for Rest of ports (0, 4, 8 and 12).
// You will see the operation for manual controll ports will be stopped if the I2C line is removed.
- // But it continues the gradation control if only power supply is available
+ // But it continues the gradation control while power supply is available
//
while(1) {
- for ( int i = 1; i <= 100; i++ ) {
- led_cntlr.pwm( 0, (float)i / 100.0 );
- led_cntlr.pwm( 4, (float)i / 100.0 );
- led_cntlr.pwm( 8, (float)i / 100.0 );
- led_cntlr.pwm( 12, (float)i / 100.0 );
- wait( 0.01 );
+ for ( int i = 0; i <= 12; i += 4 ) {
+ led_cntlr.pwm( i, 1.0 );
+ wait( MANUAL_BLINK_ON_DURATION );
+ led_cntlr.pwm( i, 0.0 );
+ wait( MANUAL_BLINK_PERIOD - MANUAL_BLINK_ON_DURATION );
}
}
-}
\ No newline at end of file
+}