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: SPI, *, pixel_count: int = 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/output must be set, the MISO/input is unused. Maximal data clock frequency is: - TLC59711: 10MHz - TLC5971: 20MHz

  • pixel_count (int) – Number of RGB-LEDs (=Pixels) that are connected. (default=4)

static calculate_BCData(*, Ioclmax: float = 18, IoutR: float = 17, IoutG: float = 15, IoutB: float = 9) Tuple[float, float, float][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: float = 2.48) float[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 float:

Ioclmax (mA)

static calculate_Riref(*, Ioclmax: float = 20) float[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 float:

Riref (kΩ)

chip_set_BCData(chip_index: int, bcr: int = 127, bcg: int = 127, bcb: int = 127) None[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() None[source]

Set all pixels to black.

set_channel(channel_index: int, value: int) None[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: int = 0, part_bit_offset: int = 0, field: Dict[str, int] | None = None, value: int = 0) None[source]

Set chip header bits in buffer.

set_pixel(pixel_index: int, value: Tuple[float, float, float]) None[source]

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

this function 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: int, color: Tuple[int, int, int]) None[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: int, value_r: int, value_g: int, value_b: int) None[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: Tuple[float, float, float]) None[source]

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

Parameters:

color (tuple) – 3-tuple of R, G, B; each int 0..65535 or float 0..1

set_pixel_all_16bit_value(value_r: int, value_g: int, value_b: int) None[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: int, color: Tuple[float, float, float]) None[source]

Set color for pixel.

This is a Fast UNPROTECTED function: no error / range checking is done. it’s 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: int, value_r: int, value_g: int, value_b: int) None[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() None[source]

Write out the current LED PWM state to the chip.

update_BCData() None[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() None[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: SPI, pixel_count: int = 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 useful 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/output must be set, the MISO/input is unused. Maximal data clock frequency is: - TLC59711: 10MHz - TLC5971: 20MHz

  • pixel_count (int) – Number of RGB-LEDs (=Pixels) that are connected.

set_all_black() None[source]

Set all pixels to black.

set_channel(channel_index: int, value: int) None[source]

Set the value for the provided channel.

Parameters:
  • channel_index (int) – 0..channel_count

  • value (int) – 0..65535

set_pixel(pixel_index: int, value: Tuple[float, float, float]) None[source]

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

this function 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: Tuple[float, float, float]) None[source]

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

Parameters:

color (tuple) – 3-tuple of R, G, B; each int 0..65535 or float 0..1