adafruit_tlc59711

CircuitPython module for the TLC59711 or TLC5971 16-bit 12 channel LED PWM driver. See examples/tlc59711_simpletest.py for a demo of the usage.

  • Author(s): Tony DiCola, Stefan Kruger

Implementation Notes

Hardware:

Software and Dependencies:

  • The API is mostly compatible to the DotStar / NeoPixel Libraries
    and is therefore also compatible with FancyLED.
  • Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
class adafruit_tlc59711.TLC59711(spi, *, pixel_count=4)[source]

TLC5971 & TLC59711 16-bit 12 channel LED PWM driver.

The TLC59711 & TLC5971 chip is designed to drive 4 RGB LEDs with 16-bit PWM per Color. This Library can control 1..many chips. The class has an interface compatible with the FancyLED library - and the API is similar to the NeoPixel and DotStar Interfaces.

Parameters:
  • spi (SPI) – An instance of the SPI bus connected to the chip. The clock and MOSI/outout must be set, the MISO/input is unused. Maximal data clock frequence is: - TLC59711: 10MHz - TLC5971: 20MHz
  • pixel_count (bool) – Number of RGB-LEDs (=Pixels) that are connected. (default=4)
static calculate_BCData(*, Ioclmax=18, IoutR=17, IoutG=15, IoutB=9)[source]

Calculate Global Brightness Control Values.

see: 8.5.1 Global Brightness Control (BC) Function (Sink Current Control) http://www.ti.com/lit/ds/symlink/tlc5971.pdf#page=19&zoom=200,0,697

Iout = Ioclmax * (BCX / 127) BCX = Iout / Ioclmax * 127

Parameters:
  • Ioclmax (float) – max output current set by Riref (mA) (default=20)
  • IoutR (float) – max output current for red color group (mA) (default=9)
  • IoutG (float) – max output current for green color (mA) (default=15)
  • IoutB (float) – max output current for blue color (mA) (default=17)
Return tuple:

(bcr, bcg, bcb)

static calculate_Ioclmax(*, Riref=2.48)[source]

Calculate Maximum Constant Sink Current Value.

see: 8.4.1 Maximum Constant Sink Current Setting http://www.ti.com/lit/ds/symlink/tlc5971.pdf#page=18&zoom=160,0,524

Riref = (Viref / Ioclmax) * 41 Ioclmax = (41 / Riref) * Viref

Parameters:Riref (float) – resistor value (kΩ) (default=20)
Return tuple:Ioclmax (mA)
static calculate_Riref(*, Ioclmax=20)[source]

Calculate Maximum Constant Sink Current Value.

see: 8.4.1 Maximum Constant Sink Current Setting http://www.ti.com/lit/ds/symlink/tlc5971.pdf#page=19&zoom=200,0,697

Riref = (Viref / Ioclmax) * 41

Parameters:Ioclmax (float) – target max output current (mA) (default=20)
Return tuple:Riref (kΩ)
chip_set_BCData(chip_index, bcr=127, bcg=127, bcb=127)[source]

Set BC-Data.

Parameters:
  • chip_index (int) – Index of Chip to set.
  • bcr (int) – 7-bit value from 0-127 (default=127)
  • bcg (int) – 7-bit value from 0-127 (default=127)
  • bcb (int) – 7-bit value from 0-127 (default=127)
set_all_black()[source]

Set all pixels to black.

set_channel(channel_index, value)[source]

Set the value for the provided channel.

Parameters:
  • channel_index (int) – 0..channel_count
  • value (int) – 0..65535
set_chipheader_bits_in_buffer(*, chip_index=0, part_bit_offset=0, field=None, value=0)[source]

Set chip header bits in buffer.

set_pixel(pixel_index, value)[source]

Set the R, G, B values for the pixel.

this funciton hase some advanced error checking. it is much slower than the other provided ‘bare’ variants.. but therefor gives clues to what is going wrong.. ;-)

Parameters:
  • pixel_index (int) – 0..(pixel_count)
  • value (tuple) – 3-tuple of R, G, B; each int 0..65535 or float 0..1
set_pixel_16bit_color(pixel_index, color)[source]

Set color for pixel.

This is a Fast UNPROTECTED function: no error / range checking is done. its a little bit slower as set_pixel_16bit_value

Parameters:
  • pixel_index (int) – 0..(pixel_count)
  • color (int) – 3-tuple of R, G, B; 0..65535
set_pixel_16bit_value(pixel_index, value_r, value_g, value_b)[source]

Set the value for pixel.

This is a Fast UNPROTECTED function: no error / range checking is done.

Parameters:
  • pixel_index (int) – 0..(pixel_count)
  • value_r (int) – 0..65535
  • value_g (int) – 0..65535
  • value_b (int) – 0..65535
set_pixel_all(color)[source]

Set the R, G, B values for all pixels.

:param tuple 3-tuple of R, G, B; each int 0..65535 or float 0..1

set_pixel_all_16bit_value(value_r, value_g, value_b)[source]

Set the R, G, B values for all pixels.

fast. without error checking.

Parameters:
  • value_r (int) – 0..65535
  • value_g (int) – 0..65535
  • value_b (int) – 0..65535
set_pixel_float_color(pixel_index, color)[source]

Set color for pixel.

This is a Fast UNPROTECTED function: no error / range checking is done. its a little bit slower as set_pixel_16bit_value

Parameters:
  • pixel_index (int) – 0..(pixel_count)
  • color (tuple/float) – 3-tuple of R, G, B; 0..1
set_pixel_float_value(pixel_index, value_r, value_g, value_b)[source]

Set the value for pixel.

This is a Fast UNPROTECTED function: no error / range checking is done.

Parameters:
  • pixel_index (int) – 0..(pixel_count)
  • value_r (int) – 0..1
  • value_g (int) – 0..1
  • value_b (int) – 0..1
show()[source]

Write out the current LED PWM state to the chip.

update_BCData()[source]

Update BC-Data for all Chips in Buffer.

need to be called after you changed on of the BC-Data Parameters. (bcr, bcg, bcb)

update_fc()[source]

Update Function Control Bits for all Chips in Buffer.

need to be called after you changed on of the Function Control Bit Parameters. (outtmg, extgck, tmgrst, dsprpt, blank)

class adafruit_tlc59711.TLC59711AutoShow(spi, pixel_count=4)[source]

TLC59711 16-bit 12 channel LED PWM driver with Auto-Show.

This chip is designed to drive 4 RGB LEDs with 16-bit PWM per Color. The class has an interface compatible with the FancyLED library. and with this is similar to the NeoPixel and DotStar Interfaces.

this TLC59711AutoShow is a subclass of TLC59711 that adds automatically sending changed data to the chips. this creates very slows responses on big changes. It is mainly usefull if you only have a very small number of pixels.

Parameters:
  • spi (SPI) – An instance of the SPI bus connected to the chip. The clock and MOSI/outout must be set, the MISO/input is unused. Maximal data clock frequence is: - TLC59711: 10MHz - TLC5971: 20MHz
  • pixel_count (bool) – Number of RGB-LEDs (=Pixels) that are connected.
set_all_black()[source]

Set all pixels to black.

set_channel(channel_index, value)[source]

Set the value for the provided channel.

Parameters:
  • channel_index (int) – 0..channel_count
  • value (int) – 0..65535
set_pixel(pixel_index, value)[source]

Set the R, G, B values for the pixel.

this funciton hase some advanced error checking. it is much slower than the other provided ‘bare’ variants.. but therefor gives clues to what is going wrong.. ;-)

Parameters:
  • pixel_index (int) – 0..(pixel_count)
  • value (tuple) – 3-tuple of R, G, B; each int 0..65535 or float 0..1
set_pixel_all(color)[source]

Set the R, G, B values for all pixels.

:param tuple 3-tuple of R, G, B; each int 0..65535 or float 0..1