A feature complete driver for the PCA9952/55 LED driver from NXP.

Dependents:   PCA9955_HelloWorld

Revision:
8:12a800c51b35
Parent:
7:7dd3cc73e873
Child:
9:a9f91f91633b
--- a/PCA9955.cpp	Tue Apr 08 17:43:57 2014 +0000
+++ b/PCA9955.cpp	Tue Apr 08 20:31:22 2014 +0000
@@ -542,19 +542,7 @@
     }
 }
 
-void PCA9955::allOutputDuties(float duty, int altAddr)
-{
-    //Range check the value
-    if (duty < 0.0f)
-        duty = 0.0f;
-    if (duty > 1.0f)
-        duty = 1.0f;
-
-    //Convert the value to a char and write it
-    allOutputDuties_char((char)(duty * 255.0f), altAddr);
-}
-
-void PCA9955::allOutputDuties(float* duties, int altAddr)
+void PCA9955::setOutputDuties(float* duties, int altAddr)
 {
     char buff[17];
 
@@ -575,19 +563,25 @@
     writeMulti((altAddr == NULL) ? m_ADDR : altAddr, buff, 17);
 }
 
+void PCA9955::allOutputDuties(float duty, int altAddr)
+{
+    //Range check the value
+    if (duty < 0.0f)
+        duty = 0.0f;
+    if (duty > 1.0f)
+        duty = 1.0f;
+
+    //Convert the value to a char and write it
+    allOutputDuties_char((char)(duty * 255.0f), altAddr);
+}
+
 void PCA9955::getOutputDuties_char(char* duties)
 {
     //Read all of the duty cycles at once
     readMulti(REG_PWM0 | REG_AUTO_INC, duties, 16);
 }
 
-void PCA9955::allOutputDuties_char(char duty, int altAddr)
-{
-    //Write the new 8-bit register value
-    write((altAddr == NULL) ? m_ADDR : altAddr, REG_PWMALL, duty);
-}
-
-void PCA9955::allOutputDuties_char(char* duties, int altAddr)
+void PCA9955::setOutputDuties_char(char* duties, int altAddr)
 {
     char buff[17];
 
@@ -599,6 +593,12 @@
     writeMulti((altAddr == NULL) ? m_ADDR : altAddr, buff, 17);
 }
 
+void PCA9955::allOutputDuties_char(char duty, int altAddr)
+{
+    //Write the new 8-bit register value
+    write((altAddr == NULL) ? m_ADDR : altAddr, REG_PWMALL, duty);
+}
+
 void PCA9955::getOutputCurrents(float* irefs)
 {
     char buff[16];
@@ -612,19 +612,7 @@
     }
 }
 
-void PCA9955::allOutputCurrents(float iref, int altAddr)
-{
-    //Range check the value
-    if (iref < 0.0f)
-        iref = 0.0f;
-    if (iref > 1.0f)
-        iref = 1.0f;
-
-    //Convert the value to a char and write it
-    allOutputCurrents_char((char)(iref * 255.0f), altAddr);
-}
-
-void PCA9955::allOutputCurrents(float* irefs, int altAddr)
+void PCA9955::setOutputCurrents(float* irefs, int altAddr)
 {
     char buff[17];
 
@@ -645,19 +633,25 @@
     writeMulti((altAddr == NULL) ? m_ADDR : altAddr, buff, 17);
 }
 
+void PCA9955::allOutputCurrents(float iref, int altAddr)
+{
+    //Range check the value
+    if (iref < 0.0f)
+        iref = 0.0f;
+    if (iref > 1.0f)
+        iref = 1.0f;
+
+    //Convert the value to a char and write it
+    allOutputCurrents_char((char)(iref * 255.0f), altAddr);
+}
+
 void PCA9955::getOutputCurrents_char(char* irefs)
 {
     //Read all of the current references at once
     readMulti(REG_IREF0 | REG_AUTO_INC, irefs, 16);
 }
 
-void PCA9955::allOutputCurrents_char(char iref, int altAddr)
-{
-    //Write the new 8-bit register value
-    write((altAddr == NULL) ? m_ADDR : altAddr, REG_IREFALL, iref);
-}
-
-void PCA9955::allOutputCurrents_char(char* irefs, int altAddr)
+void PCA9955::setOutputCurrents_char(char* irefs, int altAddr)
 {
     char buff[17];
 
@@ -669,6 +663,12 @@
     writeMulti((altAddr == NULL) ? m_ADDR : altAddr, buff, 17);
 }
 
+void PCA9955::allOutputCurrents_char(char iref, int altAddr)
+{
+    //Write the new 8-bit register value
+    write((altAddr == NULL) ? m_ADDR : altAddr, REG_IREFALL, iref);
+}
+
 unsigned short PCA9955::faultTest()
 {
     //Read the current 8-bit register value