I bought a Sparkfun BOB-13884 LP55231 breakout board as filler on a recent Digikey order. The LP55231 is quite an interesting chip. It drives only 9 LEDs, but has a pile of capabilities. And with the onboard charge pump it does it all on low power and very efficiently. Way too much to type, so here's the description page of the datasheet:
The board has three onboard WS2801 RGB LEDs. It also has pads with cuttable traces so you can disable the onboard LEDs and use the onboard solder pads to connect 9 outboard LEDs, which is what I did after playing with the included RGB LEDs for a while.
There are four available i2c addresses, so you can run four LP55231 chips on one i2c, for a total of 12 RGB LEDs or 36 LEDs.
At this point I have only barely scratched the surface of what this chip can do. I'm still reading about the three program execution engines. Quite an impressive little IC.
Some super simple MicroPython demo source code:
# ghmicro.com
# LP55231 LED driver - hardware I2c
import time
from machine import I2C, Pin
i2c = machine.I2C(1,freq=400000)
byt = bytearray(2)
temp = bytearray(1)
dely = 50
def writebyte(address,value):
byt[0] = address
byt[1] = value
i2c.writeto(0x32,byt)
writebyte(0x00,0x40) #enable lp55231
pyb.delay(50) #wait to enter normal mode
writebyte(0x36,0x5b) #enable auto inc, auto charge pump, internal clock
#set PWM outputs
for i in range(0x16,0x1f):
writebyte(i,0xff)
#set current outputs
for i in range(0x26,0x2f):
writebyte(i,0xaf)
#config temp sensor
writebyte(0x3e,0x06) #continuous conversion
#start with all leds off
writebyte(0x04,0x00) #D9 led controlled by bit 0 here
writebyte(0x05,0x00) #D1-D8 controlled by eight bits here
#cylon cycle through all leds
while 1:
writebyte(0x05,0x02) #2
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x01) #1
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x40) #7
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x08) #4
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x04) #3
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x80) #8
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x20) #6
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x10) #5
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x04,0x01) #9
pyb.delay(dely)
writebyte(0x04,0x00)
writebyte(0x05,0x10) #5
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x20) #6
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x80) #8
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x04) #3
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x08) #4
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x40) #7
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x01) #1
pyb.delay(dely)
writebyte(0x05,0x00)
writebyte(0x05,0x02) #2
pyb.delay(dely)
writebyte(0x05,0x00)
i2c.readfrom_mem_into(0x32,0x3f,temp)
print("Temp is",temp[0],"C")
writebyte(0x05,0xff) #turn on all LEDs
writebyte(0x04,0x01)
for i in range(255): #pwm brighten & dim all LEDs
for j in range(0x16,0x1f):
writebyte(j,i) #set PWMs
pyb.delay(4)
for i in range(255,0,-1):
for j in range(0x16,0x1f):
writebyte(j,i) #set PWMs
pyb.delay(4)
pyb.delay(200)
writebyte(0x05,0x00) #turn off all LEDs
writebyte(0x04,0x00)
for i in range(0x16,0x1f):
writebyte(i,0xff) #set PWMs