PCA9635 16-bit I2C-bus LED driver

Dependents:   digitalThermometer Counter SimpleClock printNumber ... more

Revision:
10:b807470a8b09
Parent:
9:48985b738e5a
Child:
12:c3634dae1506
--- a/PCA9635.cpp	Wed Jun 29 13:39:28 2011 +0000
+++ b/PCA9635.cpp	Wed Jun 29 13:42:04 2011 +0000
@@ -117,6 +117,27 @@
         m_i2c.write(m_addr, cmd, 2);
     }
 }
+//Brightness control for single or all LEDs
+void PCA9635::brightness(char led, char value, int address)
+{
+    setAddress(address);
+    
+    if(led == ALL)
+    {
+        for(char allLeds=0x02; allLeds<0x12; allLeds++)
+        {
+            cmd[0] = allLeds;           
+            cmd[1] = value; 
+            m_i2c.write(m_addr, cmd, 2);
+        }
+    }
+    else
+    {
+        cmd[0] = led + 2;           
+        cmd[1] = value; 
+        m_i2c.write(m_addr, cmd, 2);
+    }
+}