API

s-light CircuitPython TLC5957 library.

CircuitPython library for TI TLC5957 48-channel 16bit LED-Driver

  • Author(s): Stefan Krüger

Implementation Notes

Hardware:

Software and Dependencies:

class slight_tlc5957.TLC5957(spi, spi_clock, spi_mosi, spi_miso, latch, gsclk, pixel_count=16)

TLC5957 16-bit 48 channel LED PWM driver.

This chip is designed to drive 16 RGB LEDs with 16-bit PWM per Color. The class has an interface compatible with FancyLED. and with this 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 must be set the MISO (input) is currently unused. Maximal data clock frequence is: - TLC5957: 33MHz
  • latch (DigitalInOut) – The chip LAT (latch) pin object that implements the DigitalInOut API.
  • gsclk (PWMOut) – The chip Grayscale Clock pin object that implements the PWMOut API.
  • pixel_count (bool) – Number of RGB-LEDs (=Pixels) are connected.
get_fc_bits_in_buffer(*, chip_index=0, part_bit_offset=0, field={'default': 0, 'length': 0, 'mask': 0, 'offset': 0})

Get function control bits in buffer.

print_buffer_fc()

Print internal function_command buffer content.

print_buffer_fc_raw()

Print internal function_command buffer content as raw binary.

set_all_black()

Set all pixels to black.

static set_bit(value, index, value_new)

Set bit - return new value.

Set the index:th bit of value to 1 if value_new is truthy, else to 0, and return the new value. https://stackoverflow.com/a/12174051/574981

static set_bit_with_mask(value, mask, value_new)

Set bit with help of mask.

set_channel(channel_index, value)

Set the value for the provided channel.

Parameters:
  • channel_index (int) – 0..channel_count
  • value (int) – 0..65535
set_fc_BC(chip_index=0, BC=4)

Set brightness control.

set_fc_BC_all(BC=4)

Set brightness control for all chips.

set_fc_CC(chip_index=0, CCR=256, CCG=256, CCB=256)

Set color control for R, G, B.

set_fc_CC_all(CCR=256, CCG=256, CCB=256)

Set color control for R, G, B for all chips.

set_fc_ESPWM(chip_index=0, enable=False)

Set ESPWM.

set_fc_ESPWM_all(enable=False)

Set ESPWM for all chips.

set_fc_bits_in_buffer(*, chip_index=0, part_bit_offset=0, field={'default': 0, 'length': 0, 'mask': 0, 'offset': 0}, value=0)

Set function control bits in buffer.

set_pixel(pixel_index, value)

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)

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)

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)

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)

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)

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)

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()

Write out Grayscale Values to chips.

update_fc()

Write out Function_Command Values to chips.